solargraph 0.34.1 → 0.34.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -5
- data/README.md +1 -1
- data/lib/solargraph.rb +1 -0
- data/lib/solargraph/api_map.rb +3 -2
- data/lib/solargraph/api_map/bundler_methods.rb +4 -8
- data/lib/solargraph/api_map/source_to_yard.rb +1 -0
- data/lib/solargraph/convention/rspec.rb +1 -0
- data/lib/solargraph/documentor.rb +46 -26
- data/lib/solargraph/shell.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace.rb +12 -9
- data/lib/solargraph/yard_map.rb +22 -21
- data/travis-bundler.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e432b35fd7f9c1466edf9d2f3ae54bcf210ebfaaa79473458b33ba700c6bf902
|
4
|
+
data.tar.gz: a4bb6dbe4b7e6ce15bf1177c75ecce9fe13fc10a499527622b5675893bdb0053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d05491b24576660461f939eb763d10b6247ec47140ecceef8e0c4f1387074a427850c0d25c0a3624641b42e66e4964782e369c89738aec2ee067d9d2c9aafdb4
|
7
|
+
data.tar.gz: b0f8d060d9f19810789f1b4190758afe45b608cc4da25e92eed3797550f096f9fa2352723a9c3954e2b3b3bcc3368ca505903476cb36991c337b654fd1fd2ce4
|
data/.travis.yml
CHANGED
@@ -4,14 +4,12 @@ rvm:
|
|
4
4
|
- 2.2
|
5
5
|
- 2.3
|
6
6
|
- 2.4
|
7
|
-
- 2.5
|
8
|
-
- 2.
|
9
|
-
- 2.6.0
|
10
|
-
- 2.6.1
|
7
|
+
- 2.5
|
8
|
+
- 2.6
|
11
9
|
- jruby-9.2
|
12
10
|
matrix:
|
13
11
|
include:
|
14
|
-
- rvm: 2.
|
12
|
+
- rvm: 2.5
|
15
13
|
os: osx
|
16
14
|
# Update RubyGems and Bundler due to error with Bundler 1.16.1 and RubyGems 2.7.3
|
17
15
|
# See https://github.com/travis-ci/travis-ci/issues/8978
|
data/README.md
CHANGED
@@ -85,7 +85,7 @@ See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips
|
|
85
85
|
|
86
86
|
### Bug Reports and Feature Requests
|
87
87
|
|
88
|
-
[https://github.com/castwide/solargraph/issues
|
88
|
+
[GitHub Issues](https://github.com/castwide/solargraph/issues) are the best place to ask questions, report problems, and suggest improvements.
|
89
89
|
|
90
90
|
### Development
|
91
91
|
|
data/lib/solargraph.rb
CHANGED
@@ -15,6 +15,7 @@ module Solargraph
|
|
15
15
|
class SourceNotAvailableError < StandardError; end
|
16
16
|
class ComplexTypeError < StandardError; end
|
17
17
|
class WorkspaceTooLargeError < RuntimeError; end
|
18
|
+
class BundleNotFoundError < StandardError; end
|
18
19
|
|
19
20
|
autoload :Position, 'solargraph/position'
|
20
21
|
autoload :Range, 'solargraph/range'
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -116,8 +116,9 @@ module Solargraph
|
|
116
116
|
end
|
117
117
|
reqs.concat implicit.requires
|
118
118
|
pins.concat implicit.overrides
|
119
|
-
reqs.
|
120
|
-
|
119
|
+
br = reqs.include?('bundler/require') ? require_from_bundle(bundle.workspace.directory) : {}
|
120
|
+
reqs.concat br.keys
|
121
|
+
yard_map.change(reqs, br)
|
121
122
|
new_store = Store.new(pins + yard_map.pins)
|
122
123
|
@mutex.synchronize {
|
123
124
|
@cache.clear
|
@@ -9,14 +9,10 @@ module Solargraph
|
|
9
9
|
def require_from_bundle directory
|
10
10
|
@require_from_bundle ||= begin
|
11
11
|
Solargraph.logger.info "Loading gems for bundler/require"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
else
|
17
|
-
[]
|
18
|
-
end
|
19
|
-
end
|
12
|
+
Documentor.specs_from_bundle(directory)
|
13
|
+
rescue BundleNotFoundError => e
|
14
|
+
Solargraph.logger.warn e.message
|
15
|
+
{}
|
20
16
|
end
|
21
17
|
end
|
22
18
|
|
@@ -13,6 +13,7 @@ module Solargraph
|
|
13
13
|
domains: ['RSpec::Matchers', 'RSpec::ExpectationGroups'],
|
14
14
|
# This override is necessary due to an erroneous @return tag in
|
15
15
|
# rspec's YARD documentation.
|
16
|
+
# @todo The return types have been fixed (https://github.com/rspec/rspec-expectations/pull/1121)
|
16
17
|
overrides: [
|
17
18
|
Solargraph::Pin::Reference::Override.method_return('RSpec::Matchers#expect', 'RSpec::Expectations::ExpectationTarget')
|
18
19
|
]
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'bundler'
|
4
|
+
require 'json'
|
5
|
+
require 'open3'
|
6
|
+
require 'shellwords'
|
7
|
+
require 'yard'
|
4
8
|
|
5
9
|
module Solargraph
|
6
10
|
class Documentor
|
@@ -9,45 +13,61 @@ module Solargraph
|
|
9
13
|
activejob activemodel activerecord activestorage activesupport railties
|
10
14
|
]
|
11
15
|
|
12
|
-
def initialize directory, rebuild: false
|
16
|
+
def initialize directory, rebuild: false, out: File.new(File::NULL, 'w')
|
13
17
|
@directory = directory
|
14
18
|
@rebuild = rebuild
|
19
|
+
@out = out
|
15
20
|
end
|
16
21
|
|
17
22
|
# @return [Boolean] True if all specs were found and documented.
|
18
23
|
def document
|
19
24
|
failures = 0
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# @
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if RDOC_GEMS.include?(spec.name)
|
38
|
-
cache = File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{real.name}-#{real.version}", 'yardoc')
|
39
|
-
next if File.exist?(cache) && !@rebuild
|
40
|
-
puts "Caching custom documentation for #{real.name} #{real.version}"
|
41
|
-
Solargraph::YardMap::RdocToYard.run(real)
|
42
|
-
end
|
25
|
+
Documentor.specs_from_bundle(@directory).each_pair do |name, version|
|
26
|
+
yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
|
27
|
+
if !yd || @rebuild
|
28
|
+
@out.puts "Documenting #{name} #{version}"
|
29
|
+
`yard gems #{name} #{version} #{@rebuild ? '--rebuild' : ''}`
|
30
|
+
yd = YARD::Registry.yardoc_file_for_gem(name, "= #{version}")
|
31
|
+
if !yd
|
32
|
+
@out.puts "#{name} #{version} YARD documentation failed"
|
33
|
+
failures += 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
if yd && RDOC_GEMS.include?(name)
|
37
|
+
cache = File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{name}-#{version}", 'yardoc')
|
38
|
+
if !File.exist?(cache) || @rebuild
|
39
|
+
@out.puts "Caching custom documentation for #{name} #{version}"
|
40
|
+
spec = Gem::Specification.find_by_name(name, "= #{version}")
|
41
|
+
Solargraph::YardMap::RdocToYard.run(spec)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
46
|
-
Bundler.reset!
|
47
45
|
if failures > 0
|
48
|
-
puts "#{failures}
|
46
|
+
@out.puts "#{failures} gem#{failures == 1 ? '' : 's'} could not be documented. You might need to run `bundle install`."
|
49
47
|
end
|
50
48
|
failures == 0
|
49
|
+
rescue Solargraph::BundleNotFoundError => e
|
50
|
+
@out.puts "[#{e.class}] #{e.message}"
|
51
|
+
@out.puts "No bundled gems are available in #{@directory}"
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.specs_from_bundle directory
|
56
|
+
Bundler.with_clean_env do
|
57
|
+
Dir.chdir directory do
|
58
|
+
cmd = [
|
59
|
+
'bundle', 'exec', 'ruby', '-e',
|
60
|
+
"require 'bundler'; require 'json'; puts Bundler.definition.specs_for([:default]).map { |spec| [spec.name, spec.version] }.to_h.to_json"
|
61
|
+
]
|
62
|
+
o, e, s = Open3.capture3(*cmd)
|
63
|
+
if s.success?
|
64
|
+
o && !o.empty? ? JSON.parse(o) : {}
|
65
|
+
else
|
66
|
+
Solargraph.logger.warn e
|
67
|
+
raise BundleNotFoundError, "Failed to load gems from bundle at #{directory}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
51
71
|
end
|
52
72
|
end
|
53
73
|
end
|
data/lib/solargraph/shell.rb
CHANGED
@@ -183,7 +183,7 @@ module Solargraph
|
|
183
183
|
option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.'
|
184
184
|
option :rebuild, type: :boolean, aliases: :r, desc: 'Rebuild existing documentation', default: false
|
185
185
|
def bundle
|
186
|
-
Documentor.new(options[:directory]).document
|
186
|
+
Documentor.new(options[:directory], rebuild: options[:rebuild], out: STDOUT).document
|
187
187
|
end
|
188
188
|
|
189
189
|
desc 'rdoc GEM [VERSION]', 'Use RDoc to cache documentation'
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/workspace.rb
CHANGED
@@ -159,15 +159,18 @@ module Solargraph
|
|
159
159
|
# HACK: Evaluating gemspec files violates the goal of not running
|
160
160
|
# workspace code, but this is how Gem::Specification.load does it
|
161
161
|
# anyway.
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
162
|
+
Dir.chdir base do
|
163
|
+
begin
|
164
|
+
# @type [Gem::Specification]
|
165
|
+
spec = eval(File.read(file), binding, file)
|
166
|
+
next unless Gem::Specification === spec
|
167
|
+
result.concat(spec.require_paths.map { |path| File.join(base, path) })
|
168
|
+
rescue Exception => e
|
169
|
+
# Don't die if we have an error during eval-ing a gem spec.
|
170
|
+
# Concat the default lib directory instead.
|
171
|
+
Solargraph.logger.warn "Error reading #{file}: [#{e.class}] #{e.message}"
|
172
|
+
result.push File.join(base, 'lib')
|
173
|
+
end
|
171
174
|
end
|
172
175
|
end
|
173
176
|
result.concat config.require_paths
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -30,14 +30,18 @@ module Solargraph
|
|
30
30
|
|
31
31
|
attr_writer :with_dependencies
|
32
32
|
|
33
|
+
attr_reader :gemset
|
34
|
+
|
33
35
|
# @param required [Array<String>]
|
36
|
+
# @param gemset [Hash{String => String}]
|
34
37
|
# @param with_dependencies [Boolean]
|
35
|
-
def initialize(required: [], with_dependencies: true)
|
38
|
+
def initialize(required: [], gemset: {}, with_dependencies: true)
|
36
39
|
# HACK: YardMap needs its own copy of this array
|
37
40
|
@required = required.clone
|
38
41
|
@with_dependencies = with_dependencies
|
39
42
|
@gem_paths = {}
|
40
43
|
@stdlib_namespaces = []
|
44
|
+
@gemset = gemset
|
41
45
|
process_requires
|
42
46
|
yardocs.uniq!
|
43
47
|
end
|
@@ -54,12 +58,13 @@ module Solargraph
|
|
54
58
|
|
55
59
|
# @param new_requires [Array<String>]
|
56
60
|
# @return [Boolean]
|
57
|
-
def change new_requires
|
58
|
-
if new_requires.uniq.sort == required.uniq.sort
|
61
|
+
def change new_requires, new_gemset
|
62
|
+
if new_requires.uniq.sort == required.uniq.sort && new_gemset == gemset
|
59
63
|
false
|
60
64
|
else
|
61
65
|
required.clear
|
62
66
|
required.concat new_requires
|
67
|
+
@gemset = new_gemset
|
63
68
|
process_requires
|
64
69
|
true
|
65
70
|
end
|
@@ -120,7 +125,7 @@ module Solargraph
|
|
120
125
|
# @return [Location]
|
121
126
|
def require_reference path
|
122
127
|
# @type [Gem::Specification]
|
123
|
-
spec =
|
128
|
+
spec = spec_for_require(path)
|
124
129
|
spec.full_require_paths.each do |rp|
|
125
130
|
file = File.join(rp, "#{path}.rb")
|
126
131
|
next unless File.file?(file)
|
@@ -165,7 +170,7 @@ module Solargraph
|
|
165
170
|
end
|
166
171
|
result = []
|
167
172
|
begin
|
168
|
-
spec =
|
173
|
+
spec = spec_for_require(r)
|
169
174
|
ver = spec.version.to_s
|
170
175
|
ver = ">= 0" if ver.empty?
|
171
176
|
yd = yardoc_file_for_spec(spec)
|
@@ -271,24 +276,20 @@ module Solargraph
|
|
271
276
|
Solargraph.logger.info "Using cached documentation for #{spec.name} at #{cache_dir}"
|
272
277
|
cache_dir
|
273
278
|
else
|
274
|
-
YARD::Registry.yardoc_file_for_gem(spec.name, spec.version)
|
279
|
+
YARD::Registry.yardoc_file_for_gem(spec.name, "= #{spec.version}")
|
275
280
|
end
|
276
281
|
end
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
282
|
+
|
283
|
+
def spec_for_require path
|
284
|
+
spec = Gem::Specification.find_by_path(path) || Gem::Specification.find_by_name(path.split('/').first)
|
285
|
+
if @gemset[spec.name]
|
286
|
+
begin
|
287
|
+
return Gem::Specification.find_by_name(spec.name, "= #{@gemset[spec.name]}")
|
288
|
+
rescue Gem::LoadError
|
289
|
+
Solargraph.logger.warn "Unable to load #{spec.name} #{@gemset[spec.name]} specified by workspace, using #{spec.version} instead"
|
290
|
+
end
|
291
|
+
end
|
292
|
+
spec
|
286
293
|
end
|
287
|
-
specs.map(&:name)
|
288
294
|
end
|
289
|
-
Bundler.reset!
|
290
|
-
result
|
291
|
-
rescue Bundler::GemfileNotFound => e
|
292
|
-
Solargraph.logger.info "Ignoring bundler/require: #{e.message}"
|
293
|
-
[]
|
294
295
|
end
|
data/travis-bundler.rb
CHANGED
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.34.
|
4
|
+
version: 0.34.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|