solargraph 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f57a44dce57b4e3362168c2bc89aa6ddf989ed34
4
- data.tar.gz: 146c7b72052a876bc2028a86a8d0058c1eacce5e
3
+ metadata.gz: 5d9772edc47881d8e944c68b737e4b065fb2fb30
4
+ data.tar.gz: 1f2dbd2d6ec31e1d94c485a87e8a247b4ed49fe0
5
5
  SHA512:
6
- metadata.gz: 8b57d51bb651ad3abd0b65b5fe873fb02f944e28443cb46a658c73c9416903ac45d5e7677c78df4db6f29999a0f41c81ab246d0de5d595684104a46def6f931e
7
- data.tar.gz: 7bedbcd9f10e87598ce66e2811023977fe63bdfe22e1e55a4774dde096cc824c80bde3f431a361d251b0638a3982964542ffc46891461c5c8d6a22b2f183a4ed
6
+ metadata.gz: b4d94536db05855102ea393348a8a6d589ad76f119d2205aecbb0f4f666e654fc748c1c6890037b44edf028050c6a46faac90c2dcbe6187702498dcb9d34f16e
7
+ data.tar.gz: 57223756d8581d876d77026e14397e50ab3d08913a2b15515081d05b2ec1ecf092741bd933078e22a106b4067c0745da14227f9b0ce0bed0e7bf4d1e8ecf61db
data/lib/solargraph.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'solargraph/version'
2
2
  require 'rubygems/package'
3
- require 'yard'
3
+ require 'yard-solargraph'
4
4
 
5
5
  module Solargraph
6
6
  autoload :Analyzer, 'solargraph/analyzer'
@@ -15,7 +15,8 @@ module Solargraph
15
15
  autoload :Server, 'solargraph/server'
16
16
  autoload :YardMap, 'solargraph/yard_map'
17
17
 
18
- YARDOC_PATH = File.realpath(File.dirname(__FILE__) + "/../yardoc")
18
+ YARDOC_PATH = File.join(File.realpath(File.dirname(__FILE__)), '..', 'yardoc')
19
+ YARD_EXTENSION_FILE = File.join(File.realpath(File.dirname(__FILE__)), 'yard-solargraph.rb')
19
20
  end
20
21
 
21
22
  # Make sure the core and stdlib documentation is available
@@ -39,6 +40,3 @@ unless File.exist?(version_dir)
39
40
  tar_extract.close
40
41
  #FileUtils.rm File.join(cache_dir, '2.0.0.tar.gz')
41
42
  end
42
-
43
- # Define a @type tag to be used for documenting variables
44
- YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
@@ -14,9 +14,8 @@ module Solargraph
14
14
  ]
15
15
 
16
16
  MAPPABLE_METHODS = [
17
- :include, :extend, :require, :autoload, :attr_reader, :attr_writer, :attr_accessor, :private, :public, :protected,
18
- :solargraph_include_public_methods
19
- ]
17
+ :include, :extend, :require, :autoload, :attr_reader, :attr_writer, :attr_accessor, :private, :public, :protected
18
+ ] # @todo Not including solargraph_include_public_methods (an experimental thing)
20
19
 
21
20
  include NodeMethods
22
21
 
@@ -463,6 +462,21 @@ module Solargraph
463
462
  arr
464
463
  end
465
464
 
465
+ def update_yardoc
466
+ if workspace.nil?
467
+ STDERR.puts "No workspace specified for yardoc update."
468
+ else
469
+ Dir.chdir(workspace) do
470
+ #YARD::Registry.load(yard_options[:include] - yard_options[:exclude], true)
471
+ #YARD::Registry.save
472
+ `yardoc -e #{Solargraph::YARD_EXTENSION_FILE} #{yard_options[:all]}`
473
+ unless $?.success?
474
+ STDERR.puts "There was an error processing the workspace yardoc."
475
+ end
476
+ end
477
+ end
478
+ end
479
+
466
480
  private
467
481
 
468
482
  def inner_get_methods(namespace, root = '', skip = [])
@@ -501,9 +515,9 @@ module Solargraph
501
515
  # from an include, or only from an extend?
502
516
  i = unpack_name(c.children[2])
503
517
  meths += inner_get_methods(i, root, skip) unless i == 'Kernel'
504
- elsif c.type == :send and c.children[1] == :solargraph_include_public_methods
505
- i = unpack_name(c.children[2])
506
- meths += get_instance_methods(i, root, visibility: [:public])
518
+ #elsif c.type == :send and c.children[1] == :solargraph_include_public_methods
519
+ # i = unpack_name(c.children[2])
520
+ # meths += get_instance_methods(i, root, visibility: [:public])
507
521
  else
508
522
  meths += inner_get_methods_from_node(c, root, skip)
509
523
  end
@@ -15,6 +15,7 @@ module Solargraph
15
15
  filename = filename.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
16
16
  workspace = CodeMap.find_workspace(filename)
17
17
  end
18
+ @filename = filename
18
19
  @api_map = api_map
19
20
  if @api_map.nil?
20
21
  @api_map = ApiMap.new(workspace)
@@ -200,6 +201,12 @@ module Solargraph
200
201
  end
201
202
  result += @api_map.namespaces_in('')
202
203
  result += @api_map.get_instance_methods('Kernel')
204
+ unless @filename.nil? or @api_map.yardoc_has_file?(@filename)
205
+ m = @code.match(/# +@bind \[([a-z0-9_:]*)/i)
206
+ unless m.nil?
207
+ @api_map.get_instance_methods(m[1])
208
+ end
209
+ end
203
210
  end
204
211
  result = reduce_starting_with(result, word_at(index)) if filtered
205
212
  result.uniq{|s| s.path}
@@ -67,7 +67,9 @@ module Solargraph
67
67
  if @yard_options.nil?
68
68
  @yard_options = {
69
69
  include: [],
70
- exclude: []
70
+ exclude: [],
71
+ flags: [],
72
+ all: []
71
73
  }
72
74
  unless workspace.nil?
73
75
  yardopts_file = File.join(workspace, '.yardopts')
@@ -75,7 +77,10 @@ module Solargraph
75
77
  yardopts = File.read(yardopts_file)
76
78
  yardopts.lines.each { |line|
77
79
  arg = line.strip
78
- if !arg.start_with?('-')
80
+ @yard_options[:all].push arg
81
+ if arg.start_with?('-')
82
+ @yard_options[:flags].push arg
83
+ else
79
84
  @yard_options[:include].push arg
80
85
  end
81
86
  }
@@ -75,6 +75,9 @@ module Solargraph
75
75
  @@semaphore.synchronize {
76
76
  @@api_hash[directory] = api_map
77
77
  }
78
+ #Thread.new {
79
+ api_map.update_yardoc
80
+ #}
78
81
  end
79
82
 
80
83
  def constant_updates
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.6.1'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -11,6 +11,8 @@ module Solargraph
11
11
  unless workspace.nil?
12
12
  wsy = File.join(workspace, '.yardoc')
13
13
  yardocs.push wsy if File.exist?(wsy)
14
+ #wsy = Dir[File.join workspace, '**/*.rb']
15
+ #yardocs.push(wsy)
14
16
  end
15
17
  used = []
16
18
  required.each { |r|
@@ -41,10 +43,18 @@ module Solargraph
41
43
  @yardocs ||= []
42
44
  end
43
45
 
46
+ def load_yardoc y
47
+ if y.kind_of?(Array)
48
+ YARD::Registry.load y, true
49
+ else
50
+ YARD::Registry.load! y
51
+ end
52
+ end
53
+
44
54
  def search query
45
55
  found = []
46
56
  yardocs.each { |y|
47
- yard = YARD::Registry.load! y
57
+ yard = load_yardoc(y)
48
58
  unless yard.nil?
49
59
  yard.paths.each { |p|
50
60
  found.push p if p.downcase.include?(query.downcase)
@@ -57,7 +67,7 @@ module Solargraph
57
67
  def document query
58
68
  found = []
59
69
  yardocs.each { |y|
60
- yard = YARD::Registry.load! y
70
+ yard = load_yardoc(y)
61
71
  unless yard.nil?
62
72
  obj = yard.at query
63
73
  found.push obj unless obj.nil?
@@ -73,8 +83,19 @@ module Solargraph
73
83
  consts = []
74
84
  result = []
75
85
  yardocs.each { |y|
76
- yard = YARD::Registry.load! y
86
+ yard = load_yardoc(y)
77
87
  unless yard.nil?
88
+ if namespace == '' and scope == ''
89
+ # Check for a bind tag in the yardoc root. If it exists, treat
90
+ # workspace code as a DSL that uses public instance methods in the
91
+ # specified namespaces.
92
+ b = yard.root.tag(:bind)
93
+ unless b.nil?
94
+ b.types.each { |t|
95
+ consts += get_instance_methods(t, '', visibility: :public)
96
+ }
97
+ end
98
+ end
78
99
  ns = nil
79
100
  if scope == ''
80
101
  ns = yard.at(namespace)
@@ -102,7 +123,7 @@ module Solargraph
102
123
 
103
124
  def at signature
104
125
  yardocs.each { |y|
105
- yard = YARD::Registry.load! y
126
+ yard = load_yardoc(y)
106
127
  unless yard.nil?
107
128
  obj = yard.at(signature)
108
129
  return obj unless obj.nil?
@@ -113,7 +134,7 @@ module Solargraph
113
134
 
114
135
  def resolve signature, scope
115
136
  yardocs.each { |y|
116
- yard = YARD::Registry.load! y
137
+ yard = load_yardoc(y)
117
138
  unless yard.nil?
118
139
  obj = yard.resolve(P(scope), signature)
119
140
  return obj unless obj.nil?
@@ -128,7 +149,7 @@ module Solargraph
128
149
  return cached unless cached.nil?
129
150
  meths = []
130
151
  yardocs.each { |y|
131
- yard = YARD::Registry.load! y
152
+ yard = load_yardoc(y)
132
153
  unless yard.nil?
133
154
  ns = nil
134
155
  ns = find_first_resolved_namespace(yard, namespace, scope)
@@ -160,7 +181,7 @@ module Solargraph
160
181
  return cached unless cached.nil?
161
182
  meths = []
162
183
  yardocs.each { |y|
163
- yard = YARD::Registry.load! y
184
+ yard = load_yardoc(y)
164
185
  unless yard.nil?
165
186
  ns = nil
166
187
  ns = find_first_resolved_namespace(yard, namespace, scope)
@@ -190,7 +211,7 @@ module Solargraph
190
211
 
191
212
  def find_fully_qualified_namespace namespace, scope
192
213
  yardocs.each { |y|
193
- yard = YARD::Registry.load! y
214
+ yard = load_yardoc(y)
194
215
  unless yard.nil?
195
216
  obj = find_first_resolved_namespace(yard, namespace, scope)
196
217
  return obj.path unless obj.nil? or !obj.kind_of?(YARD::CodeObjects::NamespaceObject)
@@ -0,0 +1,27 @@
1
+ require 'yard'
2
+ require 'yard/handlers/ruby/base'
3
+
4
+ class YardHandlerExtension < YARD::Handlers::Ruby::HandlesExtension
5
+ def matches? node
6
+ if node.docstring and node.docstring.include?(name)
7
+ true
8
+ else
9
+ false
10
+ end
11
+ end
12
+ end
13
+
14
+ class MyHandler < YARD::Handlers::Ruby::CommentHandler
15
+ handles YardHandlerExtension.new("@bind")
16
+
17
+ process do
18
+ if owner.type == :root
19
+ d = YARD::Docstring.new(statement.docstring)
20
+ owner.add_tag d.tag(:bind)
21
+ end
22
+ end
23
+ end
24
+
25
+ # Define a @type tag to be used for documenting variables
26
+ YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
27
+ YARD::Tags::Library.define_tag("Bind", :bind, :with_types)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2017-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -150,6 +150,7 @@ files:
150
150
  - lib/solargraph/views/search.erb
151
151
  - lib/solargraph/yard_map.rb
152
152
  - lib/solargraph/yard_map/cache.rb
153
+ - lib/yard-solargraph.rb
153
154
  - yardoc/2.0.0.tar.gz
154
155
  homepage: http://castwide.com
155
156
  licenses: