solargraph 0.47.2 → 0.53.3
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/.github/FUNDING.yml +1 -0
- data/.github/workflows/plugins.yml +40 -0
- data/.github/workflows/rspec.yml +4 -8
- data/.github/workflows/typecheck.yml +34 -0
- data/.yardopts +2 -2
- data/CHANGELOG.md +137 -3
- data/LICENSE +1 -1
- data/README.md +19 -16
- data/SPONSORS.md +2 -9
- data/lib/solargraph/api_map/cache.rb +60 -20
- data/lib/solargraph/api_map/source_to_yard.rb +17 -10
- data/lib/solargraph/api_map/store.rb +60 -12
- data/lib/solargraph/api_map.rb +171 -99
- data/lib/solargraph/bench.rb +3 -2
- data/lib/solargraph/cache.rb +77 -0
- data/lib/solargraph/complex_type/type_methods.rb +61 -12
- data/lib/solargraph/complex_type/unique_type.rb +193 -16
- data/lib/solargraph/complex_type.rb +113 -10
- data/lib/solargraph/convention/rakefile.rb +17 -0
- data/lib/solargraph/convention.rb +2 -3
- data/lib/solargraph/converters/dd.rb +5 -0
- data/lib/solargraph/converters/dl.rb +3 -0
- data/lib/solargraph/converters/dt.rb +3 -0
- data/lib/solargraph/diagnostics/rubocop.rb +23 -8
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/diagnostics/type_check.rb +1 -0
- data/lib/solargraph/diagnostics.rb +2 -2
- data/lib/solargraph/doc_map.rb +171 -0
- data/lib/solargraph/gem_pins.rb +64 -0
- data/lib/solargraph/language_server/host/cataloger.rb +2 -1
- data/lib/solargraph/language_server/host/diagnoser.rb +2 -2
- data/lib/solargraph/language_server/host/dispatch.rb +15 -5
- data/lib/solargraph/language_server/host/message_worker.rb +4 -0
- data/lib/solargraph/language_server/host/sources.rb +7 -4
- data/lib/solargraph/language_server/host.rb +50 -26
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +3 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +13 -1
- data/lib/solargraph/language_server/message/extended/download_core.rb +1 -5
- data/lib/solargraph/language_server/message/initialize.rb +13 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/document_symbol.rb +4 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +4 -4
- data/lib/solargraph/language_server/message/text_document/hover.rb +2 -0
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +1 -6
- data/lib/solargraph/language_server/message/text_document/type_definition.rb +24 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -1
- data/lib/solargraph/language_server/message/workspace/did_change_configuration.rb +5 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +10 -3
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/transport/adapter.rb +16 -1
- data/lib/solargraph/language_server/transport/data_reader.rb +2 -0
- data/lib/solargraph/library.rb +124 -37
- data/lib/solargraph/location.rb +1 -0
- data/lib/solargraph/page.rb +6 -0
- data/lib/solargraph/parser/comment_ripper.rb +4 -0
- data/lib/solargraph/parser/node_methods.rb +47 -7
- data/lib/solargraph/parser/node_processor/base.rb +9 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/class_methods.rb +31 -5
- data/lib/solargraph/parser/{legacy → parser_gem}/flawed_builder.rb +3 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_chainer.rb +57 -41
- data/lib/solargraph/parser/parser_gem/node_methods.rb +499 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/alias_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors/args_node.rb +53 -0
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/begin_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/block_node.rb +3 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/casgn_node.rb +14 -4
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/cvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{rubyvm → parser_gem}/node_processors/def_node.rb +7 -20
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/defs_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/gvasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/ivasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/lvasgn_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/namespace_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/orasgn_node.rb +1 -1
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/resbody_node.rb +3 -3
- data/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +42 -0
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/send_node.rb +2 -2
- data/lib/solargraph/parser/{legacy → parser_gem}/node_processors/sym_node.rb +1 -1
- data/lib/solargraph/parser/parser_gem/node_processors.rb +54 -0
- data/lib/solargraph/parser/parser_gem.rb +12 -0
- data/lib/solargraph/parser/region.rb +1 -1
- data/lib/solargraph/parser/snippet.rb +2 -0
- data/lib/solargraph/parser.rb +9 -10
- data/lib/solargraph/pin/base.rb +69 -11
- data/lib/solargraph/pin/base_variable.rb +8 -4
- data/lib/solargraph/pin/block.rb +21 -28
- data/lib/solargraph/pin/closure.rb +17 -2
- data/lib/solargraph/pin/common.rb +7 -3
- data/lib/solargraph/pin/conversions.rb +34 -8
- data/lib/solargraph/pin/delegated_method.rb +97 -0
- data/lib/solargraph/pin/documenting.rb +25 -34
- data/lib/solargraph/pin/instance_variable.rb +4 -0
- data/lib/solargraph/pin/local_variable.rb +13 -1
- data/lib/solargraph/pin/method.rb +270 -16
- data/lib/solargraph/pin/namespace.rb +17 -1
- data/lib/solargraph/pin/parameter.rb +52 -17
- data/lib/solargraph/pin/reference/override.rb +2 -2
- data/lib/solargraph/pin/reference.rb +8 -0
- data/lib/solargraph/pin/search.rb +4 -4
- data/lib/solargraph/pin/signature.rb +143 -0
- data/lib/solargraph/pin.rb +2 -1
- data/lib/solargraph/range.rb +4 -6
- data/lib/solargraph/rbs_map/conversions.rb +601 -0
- data/lib/solargraph/rbs_map/core_fills.rb +47 -0
- data/lib/solargraph/rbs_map/core_map.rb +28 -0
- data/lib/solargraph/rbs_map/stdlib_map.rb +33 -0
- data/lib/solargraph/rbs_map.rb +84 -0
- data/lib/solargraph/shell.rb +69 -48
- data/lib/solargraph/source/chain/array.rb +32 -0
- data/lib/solargraph/source/chain/block_symbol.rb +13 -0
- data/lib/solargraph/source/chain/call.rb +125 -61
- data/lib/solargraph/source/chain/constant.rb +15 -1
- data/lib/solargraph/source/chain/if.rb +23 -0
- data/lib/solargraph/source/chain/link.rb +8 -2
- data/lib/solargraph/source/chain/or.rb +1 -1
- data/lib/solargraph/source/chain/z_super.rb +3 -3
- data/lib/solargraph/source/chain.rb +44 -14
- data/lib/solargraph/source/change.rb +3 -0
- data/lib/solargraph/source/cursor.rb +2 -0
- data/lib/solargraph/source/source_chainer.rb +8 -5
- data/lib/solargraph/source.rb +18 -19
- data/lib/solargraph/source_map/clip.rb +30 -23
- data/lib/solargraph/source_map/mapper.rb +20 -5
- data/lib/solargraph/source_map.rb +28 -13
- data/lib/solargraph/type_checker/checks.rb +10 -2
- data/lib/solargraph/type_checker.rb +201 -98
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +2 -2
- data/lib/solargraph/workspace/config.rb +14 -11
- data/lib/solargraph/workspace.rb +28 -17
- data/lib/solargraph/yard_map/cache.rb +6 -0
- data/lib/solargraph/yard_map/helpers.rb +1 -1
- data/lib/solargraph/yard_map/mapper/to_method.rb +18 -5
- data/lib/solargraph/yard_map/mapper.rb +1 -1
- data/lib/solargraph/yard_map/to_method.rb +11 -4
- data/lib/solargraph/yard_map.rb +1 -443
- data/lib/solargraph/yard_tags.rb +20 -0
- data/lib/solargraph/yardoc.rb +52 -0
- data/lib/solargraph.rb +8 -6
- data/solargraph.gemspec +19 -8
- metadata +162 -98
- data/.travis.yml +0 -19
- data/lib/solargraph/api_map/bundler_methods.rb +0 -22
- data/lib/solargraph/compat.rb +0 -37
- data/lib/solargraph/convention/rspec.rb +0 -30
- data/lib/solargraph/documentor.rb +0 -76
- data/lib/solargraph/parser/legacy/node_methods.rb +0 -325
- data/lib/solargraph/parser/legacy/node_processors/alias_node.rb +0 -23
- data/lib/solargraph/parser/legacy/node_processors/args_node.rb +0 -35
- data/lib/solargraph/parser/legacy/node_processors/begin_node.rb +0 -15
- data/lib/solargraph/parser/legacy/node_processors/def_node.rb +0 -63
- data/lib/solargraph/parser/legacy/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/legacy/node_processors.rb +0 -54
- data/lib/solargraph/parser/legacy.rb +0 -12
- data/lib/solargraph/parser/rubyvm/class_methods.rb +0 -144
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +0 -160
- data/lib/solargraph/parser/rubyvm/node_methods.rb +0 -315
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +0 -85
- data/lib/solargraph/parser/rubyvm/node_processors/block_node.rb +0 -42
- data/lib/solargraph/parser/rubyvm/node_processors/casgn_node.rb +0 -22
- data/lib/solargraph/parser/rubyvm/node_processors/cvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/defs_node.rb +0 -57
- data/lib/solargraph/parser/rubyvm/node_processors/gvasgn_node.rb +0 -23
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +0 -38
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/lit_node.rb +0 -20
- data/lib/solargraph/parser/rubyvm/node_processors/lvasgn_node.rb +0 -27
- data/lib/solargraph/parser/rubyvm/node_processors/namespace_node.rb +0 -39
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +0 -26
- data/lib/solargraph/parser/rubyvm/node_processors/orasgn_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/resbody_node.rb +0 -45
- data/lib/solargraph/parser/rubyvm/node_processors/sclass_node.rb +0 -21
- data/lib/solargraph/parser/rubyvm/node_processors/scope_node.rb +0 -15
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +0 -277
- data/lib/solargraph/parser/rubyvm/node_processors/sym_node.rb +0 -18
- data/lib/solargraph/parser/rubyvm/node_processors.rb +0 -63
- data/lib/solargraph/parser/rubyvm.rb +0 -40
- data/lib/solargraph/yard_map/core_docs.rb +0 -170
- data/lib/solargraph/yard_map/core_fills.rb +0 -208
- data/lib/solargraph/yard_map/core_gen.rb +0 -76
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +0 -140
- data/lib/solargraph/yard_map/stdlib_fills.rb +0 -43
- data/lib/yard-solargraph.rb +0 -33
- data/yardoc/2.2.2.tar.gz +0 -0
@@ -1,208 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
class YardMap
|
3
|
-
module CoreFills
|
4
|
-
Override = Pin::Reference::Override
|
5
|
-
|
6
|
-
KEYWORDS = [
|
7
|
-
'__ENCODING__', '__LINE__', '__FILE__', 'BEGIN', 'END', 'alias', 'and',
|
8
|
-
'begin', 'break', 'case', 'class', 'def', 'defined?', 'do', 'else',
|
9
|
-
'elsif', 'end', 'ensure', 'false', 'for', 'if', 'in', 'module', 'next',
|
10
|
-
'nil', 'not', 'or', 'redo', 'rescue', 'retry', 'return', 'self', 'super',
|
11
|
-
'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield'
|
12
|
-
].map { |k| Pin::Keyword.new(k) }
|
13
|
-
|
14
|
-
methods_with_yieldparam_subtypes = %w[
|
15
|
-
Array#each Array#map Array#map! Array#any? Array#all? Array#index
|
16
|
-
Array#keep_if Array#delete_if
|
17
|
-
Enumerable#each_entry Enumerable#map Enumerable#any? Enumerable#all?
|
18
|
-
Enumerable#select Enumerable#reject
|
19
|
-
Set#each
|
20
|
-
]
|
21
|
-
|
22
|
-
OVERRIDES = [
|
23
|
-
Override.method_return('Array#concat', 'Array'),
|
24
|
-
Override.method_return('Array#keep_if', 'self'),
|
25
|
-
Override.method_return('Array#delete_if', 'self'),
|
26
|
-
Override.from_comment('Array#map', %(
|
27
|
-
@overload map(&block)
|
28
|
-
@return [Array]
|
29
|
-
@overload map()
|
30
|
-
@return [Enumerator]
|
31
|
-
)),
|
32
|
-
Override.from_comment('Array#reject', %(
|
33
|
-
@overload reject(&block)
|
34
|
-
@return [self]
|
35
|
-
@overload reject()
|
36
|
-
@return [Enumerator]
|
37
|
-
)),
|
38
|
-
Override.method_return('Array#reverse', 'self', delete: ['overload']),
|
39
|
-
Override.from_comment('Array#select', %(
|
40
|
-
@overload select(&block)
|
41
|
-
@return [self]
|
42
|
-
@overload select()
|
43
|
-
@return [Enumerator]
|
44
|
-
)),
|
45
|
-
Override.from_comment('Array#[]', %(
|
46
|
-
@overload [](range)
|
47
|
-
@param range [Range]
|
48
|
-
@return [self]
|
49
|
-
@overload [](num1, num2)
|
50
|
-
@param num1 [Integer]
|
51
|
-
@param num2 [Integer]
|
52
|
-
@return [self]
|
53
|
-
@overload [](num)
|
54
|
-
@param num [Integer]
|
55
|
-
@return_single_parameter
|
56
|
-
@return_single_parameter
|
57
|
-
)),
|
58
|
-
Override.from_comment('Array#first', %(
|
59
|
-
@overload first(num)
|
60
|
-
@param num [Integer]
|
61
|
-
@return [self]
|
62
|
-
@return_single_parameter
|
63
|
-
)),
|
64
|
-
Override.from_comment('Array#last', %(
|
65
|
-
@overload last(num)
|
66
|
-
@param num [Integer]
|
67
|
-
@return [self]
|
68
|
-
@return_single_parameter
|
69
|
-
)),
|
70
|
-
Override.method_return('Array#map', 'Array'),
|
71
|
-
Override.method_return('Array#uniq', 'self'),
|
72
|
-
Override.method_return('Array#zip', 'Array, nil'),
|
73
|
-
|
74
|
-
Override.from_comment('BasicObject#==', %(
|
75
|
-
@param other [BasicObject]
|
76
|
-
@return [Boolean]
|
77
|
-
)),
|
78
|
-
Override.method_return('BasicObject#initialize', 'void'),
|
79
|
-
|
80
|
-
Override.method_return('Class#new', 'self'),
|
81
|
-
Override.method_return('Class.new', 'Class<Object>'),
|
82
|
-
Override.method_return('Class#allocate', 'self'),
|
83
|
-
Override.method_return('Class.allocate', 'Class<Object>'),
|
84
|
-
|
85
|
-
Override.from_comment('Enumerable#detect', %(
|
86
|
-
@overload detect(&block)
|
87
|
-
@return_single_parameter
|
88
|
-
@overload detect()
|
89
|
-
@return [Enumerator]
|
90
|
-
)),
|
91
|
-
Override.from_comment('Enumerable#find', %(
|
92
|
-
@overload find(&block)
|
93
|
-
@return_single_parameter
|
94
|
-
@overload find()
|
95
|
-
@return [Enumerator]
|
96
|
-
)),
|
97
|
-
Override.method_return('Enumerable#select', 'self'),
|
98
|
-
|
99
|
-
Override.method_return('File.absolute_path', 'String'),
|
100
|
-
Override.method_return('File.basename', 'String'),
|
101
|
-
Override.method_return('File.dirname', 'String'),
|
102
|
-
Override.method_return('File.extname', 'String'),
|
103
|
-
Override.method_return('File.join', 'String'),
|
104
|
-
Override.method_return('File.open', 'File'),
|
105
|
-
|
106
|
-
Override.from_comment('Float#+', %(
|
107
|
-
@param y [Numeric]
|
108
|
-
@return [Numeric]
|
109
|
-
)),
|
110
|
-
|
111
|
-
Override.from_comment('Hash#[]', %(
|
112
|
-
@return_value_parameter
|
113
|
-
)),
|
114
|
-
# @todo This override isn't robust enough. It needs to allow for
|
115
|
-
# parameterized Hash types, e.g., [Hash{Symbol => String}].
|
116
|
-
Override.from_comment('Hash#[]=', %(
|
117
|
-
@param_tuple
|
118
|
-
)),
|
119
|
-
Override.method_return('Hash#merge', 'Hash'),
|
120
|
-
Override.from_comment('Hash#store', %{
|
121
|
-
@overload store(key, value)
|
122
|
-
}),
|
123
|
-
|
124
|
-
Override.from_comment('Integer#+', %(
|
125
|
-
@param y [Numeric]
|
126
|
-
@return [Numeric]
|
127
|
-
)),
|
128
|
-
Override.from_comment('Integer#times', %(
|
129
|
-
@overload times(&block)
|
130
|
-
@return [Integer]
|
131
|
-
@overload times()
|
132
|
-
@return [Enumerator]
|
133
|
-
)),
|
134
|
-
|
135
|
-
Override.method_return('Kernel#puts', 'nil'),
|
136
|
-
|
137
|
-
Override.from_comment('Numeric#+', %(
|
138
|
-
@param y [Numeric]
|
139
|
-
@return [Numeric]
|
140
|
-
)),
|
141
|
-
|
142
|
-
Override.method_return('Object#!', 'Boolean'),
|
143
|
-
Override.method_return('Object#clone', 'self', delete: [:overload]),
|
144
|
-
Override.method_return('Object#dup', 'self', delete: [:overload]),
|
145
|
-
Override.method_return('Object#freeze', 'self', delete: [:overload]),
|
146
|
-
Override.method_return('Object#inspect', 'String'),
|
147
|
-
Override.method_return('Object#taint', 'self'),
|
148
|
-
Override.method_return('Object#to_s', 'String'),
|
149
|
-
Override.method_return('Object#untaint', 'self'),
|
150
|
-
Override.from_comment('Object#tap', %(
|
151
|
-
@return [self]
|
152
|
-
@yieldparam [self]
|
153
|
-
)),
|
154
|
-
|
155
|
-
Override.from_comment('STDERR', %(
|
156
|
-
@type [IO]
|
157
|
-
)),
|
158
|
-
|
159
|
-
Override.from_comment('STDIN', %(
|
160
|
-
@type [IO]
|
161
|
-
)),
|
162
|
-
|
163
|
-
Override.from_comment('STDOUT', %(
|
164
|
-
@type [IO]
|
165
|
-
)),
|
166
|
-
|
167
|
-
Override.method_return('String#freeze', 'self'),
|
168
|
-
Override.method_return('String#split', 'Array<String>'),
|
169
|
-
Override.method_return('String#lines', 'Array<String>'),
|
170
|
-
Override.from_comment('String#each_line', %(
|
171
|
-
@yieldparam [String]
|
172
|
-
)),
|
173
|
-
Override.from_comment('String.new', %(
|
174
|
-
@overload new(*)
|
175
|
-
@return [self]
|
176
|
-
))
|
177
|
-
].concat(
|
178
|
-
methods_with_yieldparam_subtypes.map do |path|
|
179
|
-
Override.from_comment(path, %(
|
180
|
-
@yieldparam_single_parameter
|
181
|
-
))
|
182
|
-
end
|
183
|
-
)
|
184
|
-
|
185
|
-
PINS = [
|
186
|
-
# HACK: Extending Hash is not accurate to the implementation, but
|
187
|
-
# accurate enough to the behavior
|
188
|
-
Pin::Reference::Extend.new(closure: Pin::Namespace.new(name: 'ENV'), name: 'Hash'),
|
189
|
-
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'File'), name: 'IO'),
|
190
|
-
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Integer'), name: 'Numeric'),
|
191
|
-
Pin::Reference::Superclass.new(closure: Pin::Namespace.new(name: 'Float'), name: 'Numeric')
|
192
|
-
].concat(
|
193
|
-
# HACK: Add Errno exception classes
|
194
|
-
begin
|
195
|
-
errno = Solargraph::Pin::Namespace.new(name: 'Errno')
|
196
|
-
result = []
|
197
|
-
Errno.constants.each do |const|
|
198
|
-
result.push Solargraph::Pin::Namespace.new(type: :class, name: const.to_s, closure: errno)
|
199
|
-
result.push Solargraph::Pin::Reference::Superclass.new(closure: result.last, name: 'SystemCallError')
|
200
|
-
end
|
201
|
-
result
|
202
|
-
end
|
203
|
-
)
|
204
|
-
|
205
|
-
ALL = KEYWORDS + PINS + OVERRIDES
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tmpdir'
|
5
|
-
require 'pathname'
|
6
|
-
require 'rubygems/package'
|
7
|
-
require 'shellwords'
|
8
|
-
|
9
|
-
module Solargraph
|
10
|
-
class YardMap
|
11
|
-
# Tools for generating core documentation.
|
12
|
-
#
|
13
|
-
module CoreGen
|
14
|
-
class << self
|
15
|
-
# Generate documentation from the specified Ruby source directory.
|
16
|
-
#
|
17
|
-
# @param ruby_dir [String] The Ruby source directory
|
18
|
-
# @param dest_dir [String] The destination directory for the yardocs
|
19
|
-
# @return [void]
|
20
|
-
def generate_docs ruby_dir, dest_dir
|
21
|
-
path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
|
22
|
-
FileUtils.mkdir_p path_name
|
23
|
-
Dir.chdir(ruby_dir) do
|
24
|
-
`yardoc -b "#{File.join(path_name, 'yardoc')}" -n *.c`
|
25
|
-
raise 'An error occurred generating the core yardoc.' unless $?.success?
|
26
|
-
`yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
|
27
|
-
raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Generate a gzip of documentation from the specified Ruby source
|
32
|
-
# directory.
|
33
|
-
#
|
34
|
-
# This method is designed to generate the directory architecture that
|
35
|
-
# YardMap core docs expect.
|
36
|
-
#
|
37
|
-
# @param ruby_dir [String] The Ruby source directory
|
38
|
-
# @param ver_name [String, nil] The version name
|
39
|
-
# @param dest_dir [String] The destination directory
|
40
|
-
# @return [void]
|
41
|
-
def generate_gzip ruby_dir, ver_name = nil, dest_dir = Dir.pwd
|
42
|
-
Dir.mktmpdir do |tmp|
|
43
|
-
base_name = ver_name || begin
|
44
|
-
match = ruby_dir.match(/\d+\.\d+\.\d+$/)
|
45
|
-
raise "Unable to determine version name from #{ruby_dir}" if match.nil?
|
46
|
-
match[0]
|
47
|
-
end
|
48
|
-
path_name = Pathname.new(tmp).join(base_name).to_s
|
49
|
-
generate_docs ruby_dir, path_name
|
50
|
-
gzip path_name, Pathname.new(dest_dir).join("#{base_name}.tar.gz").to_s
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
# @param dir [String] The directory to compress
|
57
|
-
# @param dst [String] The destination file
|
58
|
-
def gzip dir, dst
|
59
|
-
File.open(dst, 'wb') do |file|
|
60
|
-
Zlib::GzipWriter.wrap(file) do |gzip|
|
61
|
-
Gem::Package::TarWriter.new(gzip) do |tar|
|
62
|
-
Dir["#{dir}/**/*"].each do |filename|
|
63
|
-
next if File.directory?(filename)
|
64
|
-
relname = File.join(File.basename(dir), filename[dir.length+1..-1])
|
65
|
-
tar.add_file_simple(relname, 0o644, File.size(filename)) do |io|
|
66
|
-
io.write File.read_binary(filename)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rdoc'
|
4
|
-
require 'rdoc/rdoc'
|
5
|
-
require 'tmpdir'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
module Solargraph
|
9
|
-
class YardMap
|
10
|
-
module RdocToYard
|
11
|
-
extend ApiMap::SourceToYard
|
12
|
-
|
13
|
-
# @param spec [Gem::Specification]
|
14
|
-
# @param cache_dir [String]
|
15
|
-
# @return [void]
|
16
|
-
def self.run spec, cache_dir: nil
|
17
|
-
Dir.mktmpdir do |tmpdir|
|
18
|
-
rdir = File.join(tmpdir, 'sg_tmp_rdoc')
|
19
|
-
FileUtils.cp_r Dir.glob(File.join(spec.full_gem_path, '*')), tmpdir
|
20
|
-
Dir.chdir tmpdir do
|
21
|
-
pins = []
|
22
|
-
pins.push Solargraph::Pin::ROOT_PIN
|
23
|
-
name_hash = {}
|
24
|
-
|
25
|
-
argv = ['-q', '-r', '-N', '-o', rdir]
|
26
|
-
spec.load_paths.each do |path|
|
27
|
-
argv.concat ['-i', path]
|
28
|
-
end
|
29
|
-
rdoc = RDoc::RDoc.new
|
30
|
-
rdoc.document argv
|
31
|
-
# @type [RDoc::Store]
|
32
|
-
store = rdoc.store
|
33
|
-
store.path = rdir
|
34
|
-
store.cache[:modules].each do |mod|
|
35
|
-
# @type [RDoc::NormalClass]
|
36
|
-
mod = store.find_class_or_module(mod)
|
37
|
-
closure = pins.select { |pin| pin.path == mod.full_name.split('::')[0..-2].join('::') }.first || pins.first
|
38
|
-
namepin = Solargraph::Pin::Namespace.new(
|
39
|
-
type: (mod.module? ? :module : :class),
|
40
|
-
name: mod.name,
|
41
|
-
comments: commentary(mod.comment),
|
42
|
-
closure: closure,
|
43
|
-
location: locate(mod)
|
44
|
-
)
|
45
|
-
mod.parse(mod.comment_location)
|
46
|
-
# @param inc [RDoc::Include]
|
47
|
-
mod.includes.each do |inc|
|
48
|
-
pins.push Solargraph::Pin::Reference::Include.new(
|
49
|
-
location: locate(inc),
|
50
|
-
name: inc.name,
|
51
|
-
closure: namepin
|
52
|
-
)
|
53
|
-
end
|
54
|
-
# @param ext [RDoc::Extend]
|
55
|
-
mod.extends.each do |ext|
|
56
|
-
pins.push Solargraph::Pin::Reference::Extend.new(
|
57
|
-
location: locate(ext),
|
58
|
-
name: ext.name,
|
59
|
-
closure: namepin
|
60
|
-
)
|
61
|
-
end
|
62
|
-
pins.push namepin
|
63
|
-
name_hash[mod.full_name] = namepin
|
64
|
-
# @param met [RDoc::AnyMethod]
|
65
|
-
mod.each_method do |met|
|
66
|
-
pin = Solargraph::SourceMap.load_string("def Object.tmp#{met.param_seq};end").first_pin('Object.tmp') || Solargraph::Pin::Method.new
|
67
|
-
pins.push Solargraph::Pin::Method.new(
|
68
|
-
name: met.name,
|
69
|
-
closure: namepin,
|
70
|
-
comments: commentary(met.comment),
|
71
|
-
scope: met.type.to_sym,
|
72
|
-
parameters: pin.parameters,
|
73
|
-
visibility: met.visibility,
|
74
|
-
location: locate(met)
|
75
|
-
)
|
76
|
-
end
|
77
|
-
# @param const [RDoc::Constant]
|
78
|
-
mod.each_constant do |const|
|
79
|
-
pins.push Solargraph::Pin::Constant.new(
|
80
|
-
name: const.name,
|
81
|
-
closure: namepin,
|
82
|
-
comments: commentary(const.comment),
|
83
|
-
location: locate(const)
|
84
|
-
)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
mapstore = Solargraph::ApiMap::Store.new(pins)
|
88
|
-
rake_yard(mapstore)
|
89
|
-
YARD::Registry.clear
|
90
|
-
code_object_map.values.each do |co|
|
91
|
-
YARD::Registry.register(co)
|
92
|
-
end
|
93
|
-
cache_dir ||= File.join(Solargraph::YardMap::CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}", "yardoc")
|
94
|
-
FileUtils.remove_entry_secure cache_dir if File.exist?(cache_dir)
|
95
|
-
FileUtils.mkdir_p cache_dir
|
96
|
-
# @todo Should merge be true?
|
97
|
-
YARD::Registry.save true, cache_dir
|
98
|
-
# Clear the serialized cache if it exists
|
99
|
-
FileUtils.safe_unlink File.join(CoreDocs.cache_dir, 'gems', "#{spec.name}-#{spec.version}.ser")
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.base_name mod
|
105
|
-
mod.full_name.split('::')[0..-2].join('::')
|
106
|
-
end
|
107
|
-
|
108
|
-
# @param cmnt [RDoc::Comment]
|
109
|
-
# @return [String]
|
110
|
-
def self.commentary cmnt
|
111
|
-
return cmnt if cmnt.is_a?(String)
|
112
|
-
return cmnt.text if cmnt.is_a?(RDoc::Comment)
|
113
|
-
result = []
|
114
|
-
cmnt.parts.each do |part|
|
115
|
-
result.push RDoc::Markup::ToHtml.new({}).to_html(part.text) if part.respond_to?(:text)
|
116
|
-
end
|
117
|
-
result.join("\n\n")
|
118
|
-
end
|
119
|
-
|
120
|
-
# @param obj [RDoc::Context]
|
121
|
-
def self.locate obj
|
122
|
-
# @todo line is always nil for some reason
|
123
|
-
file, line = find_file(obj)
|
124
|
-
return nil if file.nil?
|
125
|
-
Location.new(
|
126
|
-
file,
|
127
|
-
Range.from_to(line || 1, 0, line || 1, 0)
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.find_file obj
|
132
|
-
if obj.respond_to?(:in_files) && !obj.in_files.empty?
|
133
|
-
[obj.in_files.first.to_s.sub(/^file /, ''), obj.line]
|
134
|
-
else
|
135
|
-
[obj.file, obj.line]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
class YardMap
|
3
|
-
module StdlibFills
|
4
|
-
Override = Pin::Reference::Override
|
5
|
-
|
6
|
-
LIBS = {
|
7
|
-
'benchmark' => [
|
8
|
-
Override.method_return('Benchmark.measure', 'Benchmark::Tms')
|
9
|
-
],
|
10
|
-
|
11
|
-
'pathname' => [
|
12
|
-
Override.method_return('Pathname#join', 'Pathname'),
|
13
|
-
Override.method_return('Pathname#basename', 'Pathname'),
|
14
|
-
Override.method_return('Pathname#dirname', 'Pathname'),
|
15
|
-
Override.method_return('Pathname#cleanpath', 'Pathname'),
|
16
|
-
Override.method_return('Pathname#children', 'Array<Pathname>'),
|
17
|
-
Override.method_return('Pathname#entries', 'Array<Pathname>')
|
18
|
-
],
|
19
|
-
|
20
|
-
'set' => [
|
21
|
-
Override.method_return('Enumerable#to_set', 'Set'),
|
22
|
-
Override.method_return('Set#add', 'self'),
|
23
|
-
Override.method_return('Set#add?', 'self, nil'),
|
24
|
-
Override.method_return('Set#classify', 'Hash'),
|
25
|
-
Override.from_comment('Set#each', '@yieldparam_single_parameter'),
|
26
|
-
],
|
27
|
-
|
28
|
-
'tempfile' => [
|
29
|
-
Override.from_comment('Tempfile.open', %(
|
30
|
-
@yieldparam [Tempfile]
|
31
|
-
@return [Tempfile]
|
32
|
-
))
|
33
|
-
]
|
34
|
-
}.freeze
|
35
|
-
|
36
|
-
# @param path [String]
|
37
|
-
# @return [Array<Pin::Reference::Override>]
|
38
|
-
def self.get path
|
39
|
-
LIBS[path] || []
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/yard-solargraph.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yard'
|
4
|
-
|
5
|
-
# Change YARD log IO to avoid sending unexpected messages to STDOUT
|
6
|
-
YARD::Logger.instance.io = File.new(File::NULL, 'w')
|
7
|
-
|
8
|
-
module Solargraph
|
9
|
-
# A placeholder for the @!domain directive. It doesn't need to do anything
|
10
|
-
# for yardocs. It's only used for Solargraph API maps.
|
11
|
-
class DomainDirective < YARD::Tags::Directive
|
12
|
-
def call; end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Define a @type tag for documenting variables
|
17
|
-
YARD::Tags::Library.define_tag("Type", :type, :with_types_and_name)
|
18
|
-
# Define a @yieldself tag for documenting block contexts
|
19
|
-
YARD::Tags::Library.define_tag("Yieldself", :yieldself, :with_types)
|
20
|
-
# Define a @yieldpublic tag for documenting block domains
|
21
|
-
YARD::Tags::Library.define_tag("Yieldpublic", :yieldpublic, :with_types)
|
22
|
-
# Define a @return_single_parameter tag for returning e.g. Array parameters
|
23
|
-
YARD::Tags::Library.define_tag('ReturnSingleParameter', :return_single_parameter)
|
24
|
-
# Define a @yieldparam_single_parameter tag for yielding e.g. Array parameters
|
25
|
-
YARD::Tags::Library.define_tag('YieldparamSingleParameter', :yieldparam_single_parameter)
|
26
|
-
# Define a @return_value_parameter tag for returning e.g. Hash values
|
27
|
-
YARD::Tags::Library.define_tag('ReturnValueParameter', :return_value_parameter)
|
28
|
-
# Define a @param_tuple tag for e.g. Hash#[]= parameters
|
29
|
-
YARD::Tags::Library.define_tag('ParamTuple', :param_tuple)
|
30
|
-
# Define a @!domain directive for documenting DSLs
|
31
|
-
YARD::Tags::Library.define_directive("domain", :with_types, Solargraph::DomainDirective)
|
32
|
-
# Define an @!override directive for overriding method tags
|
33
|
-
YARD::Tags::Library.define_directive("override", :with_name, Solargraph::DomainDirective)
|
data/yardoc/2.2.2.tar.gz
DELETED
Binary file
|