solargraph 0.8.6 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/solargraph/api_map.rb +34 -22
- data/lib/solargraph/api_map/config.rb +37 -0
- data/lib/solargraph/server.rb +4 -0
- data/lib/solargraph/shell.rb +11 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +10 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de6f8c27644254cbf44fabf999b5e7d9c54361d5
|
4
|
+
data.tar.gz: e823050e40e151659b89be427a8039165c5a315c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1312f30cabb2d18635ea4e48900226318476ac7d53022b46b72afcc2696451154e9fc9718b1f74026ceb2cae6c4afc04b2904f28d3b9c02d555ef410904c53d2
|
7
|
+
data.tar.gz: 2c05df4a956bdb87868e6d624c72fc232a35599d0abd8763286b0db389f559e4b160747f6c6a3c43b1a2c2d7d8659b840ddd00465a69e57f327e2b0858dd4663
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -5,6 +5,8 @@ require 'yaml'
|
|
5
5
|
|
6
6
|
module Solargraph
|
7
7
|
class ApiMap
|
8
|
+
autoload :Config, 'solargraph/api_map/config'
|
9
|
+
|
8
10
|
KEYWORDS = [
|
9
11
|
'__ENCODING__', '__LINE__', '__FILE__', 'BEGIN', 'END', 'alias', 'and',
|
10
12
|
'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
|
@@ -26,20 +28,11 @@ module Solargraph
|
|
26
28
|
@workspace = workspace.gsub(/\\/, '/') unless workspace.nil?
|
27
29
|
clear
|
28
30
|
unless @workspace.nil?
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
opts = yard_options
|
35
|
-
(opts[:include] - opts[:exclude]).each { |glob|
|
36
|
-
files += Dir[File.join @workspace, glob]
|
37
|
-
}
|
38
|
-
opts[:exclude].each { |glob|
|
39
|
-
files -= Dir[File.join @workspace, glob]
|
40
|
-
}
|
41
|
-
files.uniq.each { |f|
|
42
|
-
append_file f if File.file?(f)
|
31
|
+
config = ApiMap::Config.new(@workspace)
|
32
|
+
config.included.each { |f|
|
33
|
+
unless config.excluded.include?(f)
|
34
|
+
append_file f
|
35
|
+
end
|
43
36
|
}
|
44
37
|
end
|
45
38
|
end
|
@@ -62,8 +55,13 @@ module Solargraph
|
|
62
55
|
end
|
63
56
|
|
64
57
|
def append_source text, filename = nil
|
65
|
-
|
66
|
-
|
58
|
+
begin
|
59
|
+
node, comments = Parser::CurrentRuby.parse_with_comments(text)
|
60
|
+
append_node(node, comments, filename)
|
61
|
+
rescue Parser::SyntaxError => e
|
62
|
+
STDERR.puts "Error parsing '#{filename}': #{e.message}"
|
63
|
+
nil
|
64
|
+
end
|
67
65
|
end
|
68
66
|
|
69
67
|
def append_node node, comments, filename = nil
|
@@ -82,11 +80,23 @@ module Solargraph
|
|
82
80
|
yard_hash = {}
|
83
81
|
comment_hash.each_pair { |k, v|
|
84
82
|
ctxt = ''
|
83
|
+
num = nil
|
84
|
+
started = false
|
85
85
|
v.each { |l|
|
86
|
-
|
86
|
+
# Trim the comment and minimum leading whitespace
|
87
|
+
p = l.text.gsub(/^#/, '')
|
88
|
+
if num.nil? and !p.strip.empty?
|
89
|
+
num = p.index(/[^ ]/)
|
90
|
+
started = true
|
91
|
+
elsif started and !p.strip.empty?
|
92
|
+
cur = p.index(/[^ ]/)
|
93
|
+
num = cur if cur < num
|
94
|
+
end
|
95
|
+
if started
|
96
|
+
ctxt += "#{p[num..-1]}\n"
|
97
|
+
end
|
87
98
|
}
|
88
|
-
|
89
|
-
yard_hash[k] = parser.parse(ctxt).to_docstring
|
99
|
+
yard_hash[k] = YARD::Docstring.parser.parse(ctxt).to_docstring
|
90
100
|
}
|
91
101
|
yard_hash
|
92
102
|
end
|
@@ -405,7 +415,6 @@ module Solargraph
|
|
405
415
|
}
|
406
416
|
return args if list.nil?
|
407
417
|
list.children.each { |c|
|
408
|
-
STDERR.puts "Args child is #{c.type}"
|
409
418
|
if c.type == :arg
|
410
419
|
args.push c.children[0]
|
411
420
|
elsif c.type == :optarg
|
@@ -480,7 +489,7 @@ module Solargraph
|
|
480
489
|
if workspace.nil?
|
481
490
|
STDERR.puts "No workspace specified for yardoc update."
|
482
491
|
else
|
483
|
-
Thread.new
|
492
|
+
Thread.new do
|
484
493
|
Dir.chdir(workspace) do
|
485
494
|
STDERR.puts "Updating the yardoc for #{workspace}..."
|
486
495
|
cmd = "yardoc -e #{Solargraph::YARD_EXTENSION_FILE}"
|
@@ -490,7 +499,7 @@ module Solargraph
|
|
490
499
|
STDERR.puts "There was an error processing the workspace yardoc."
|
491
500
|
end
|
492
501
|
end
|
493
|
-
|
502
|
+
end
|
494
503
|
end
|
495
504
|
end
|
496
505
|
|
@@ -563,6 +572,9 @@ module Solargraph
|
|
563
572
|
# TODO: Determine the current scope so we can decide whether to
|
564
573
|
# exclude protected or private methods. Right now we're just
|
565
574
|
# assuming public only
|
575
|
+
elsif c.kind_of?(AST::Node) and c.type == :send and c.children[1] == :include
|
576
|
+
fqmod = find_fully_qualified_namespace(const_from(c.children[2]), root)
|
577
|
+
meths += get_instance_methods(fqmod) unless fqmod.nil? or skip.include?(fqmod)
|
566
578
|
elsif current_scope == :public
|
567
579
|
if c.kind_of?(AST::Node) and c.type == :def
|
568
580
|
cmnt = get_comment_for(c)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Solargraph
|
2
|
+
class ApiMap
|
3
|
+
class Config
|
4
|
+
attr_reader :workspace
|
5
|
+
attr_reader :included
|
6
|
+
attr_reader :excluded
|
7
|
+
|
8
|
+
def initialize workspace = nil
|
9
|
+
@workspace = workspace
|
10
|
+
@included = []
|
11
|
+
@excluded = []
|
12
|
+
include_globs = ['**/*.rb']
|
13
|
+
exclude_globs = ['spec/**/*']
|
14
|
+
unless @workspace.nil?
|
15
|
+
sfile = File.join(@workspace, '.solargraph.yml')
|
16
|
+
if File.file?(sfile)
|
17
|
+
conf = YAML.load(File.read(sfile))
|
18
|
+
include_globs = conf['include'] || include_globs
|
19
|
+
exclude_globs = conf['exclude'] || []
|
20
|
+
end
|
21
|
+
end
|
22
|
+
include_globs.each { |g| @included.concat process_glob(g) }
|
23
|
+
exclude_globs.each { |g| @excluded.concat process_glob(g) }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def process_glob glob
|
29
|
+
result = []
|
30
|
+
Dir[glob].each do |f|
|
31
|
+
result.push File.realdirpath(f)
|
32
|
+
end
|
33
|
+
result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/solargraph/server.rb
CHANGED
data/lib/solargraph/shell.rb
CHANGED
@@ -79,5 +79,16 @@ module Solargraph
|
|
79
79
|
STDOUT.puts result
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
desc 'config [DIRECTORY]', 'Create or overwrite a default configuration file'
|
84
|
+
def config(directory = '.')
|
85
|
+
File.open(File.join(directory, '.solargraph'), 'w') do |file|
|
86
|
+
file.puts "include:",
|
87
|
+
" - ./**/*.rb",
|
88
|
+
"exclude:",
|
89
|
+
" - spec/**/*"
|
90
|
+
end
|
91
|
+
STDOUT.puts "Configuration file initialized."
|
92
|
+
end
|
82
93
|
end
|
83
94
|
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -37,10 +37,16 @@ module Solargraph
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def load_yardoc y
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
begin
|
41
|
+
if y.kind_of?(Array)
|
42
|
+
YARD::Registry.load y, true
|
43
|
+
else
|
44
|
+
YARD::Registry.load! y
|
45
|
+
end
|
46
|
+
rescue Exception => e
|
47
|
+
STDERR.puts "Error loading yardoc '#{y}' #{e.class} #{e.message}"
|
48
|
+
yardocs.delete y
|
49
|
+
nil
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
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.
|
4
|
+
version: 0.9.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-06
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- bin/solargraph
|
137
137
|
- lib/solargraph.rb
|
138
138
|
- lib/solargraph/api_map.rb
|
139
|
+
- lib/solargraph/api_map/config.rb
|
139
140
|
- lib/solargraph/code_map.rb
|
140
141
|
- lib/solargraph/mapper.rb
|
141
142
|
- lib/solargraph/node_methods.rb
|