decode 0.24.2 → 0.24.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
- checksums.yaml.gz.sig +0 -0
- data/lib/decode/comment/attribute.rb +1 -1
- data/lib/decode/comment/parameter.rb +1 -1
- data/lib/decode/comment/tag.rb +7 -0
- data/lib/decode/rbs/method.rb +6 -3
- data/lib/decode/version.rb +1 -1
- data/sig/decode.rbs +801 -0
- data.tar.gz.sig +0 -0
- metadata +2 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef915b75f58d7174e3eca3d8bbe1f0c5fb3e108bc448d3fbbf8d7125c7cc862
|
4
|
+
data.tar.gz: f0e57718607f48606b177b9bd3e33d96dc3c99d86bc5c118ec195c3fbe183b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a856492a5a76b28ce351aac35e1c9912343e059bd90185538864447d7c0b86ef6f91efa276a2bc6401c96dbe7ee7c71c26c2188ce605907a869c502be01474
|
7
|
+
data.tar.gz: c07db98e11975aaaebe211bd45f61259f7d845feeb7e3a9d916ec04cb7b4cd2d5495b1ef5168a4bb30ed93731936171b4dd1ef22f9c0ecb50c63ff2b3637b1e1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -13,7 +13,7 @@ module Decode
|
|
13
13
|
# - `@attribute [Integer] The person's age.`
|
14
14
|
#
|
15
15
|
class Attribute < Tag
|
16
|
-
PATTERN = /\A\[(
|
16
|
+
PATTERN = /\A\[#{Tag.bracketed_content(:type)}\](\s+(?<details>.*?))?\Z/
|
17
17
|
|
18
18
|
# Build an attribute from a directive and match.
|
19
19
|
# @parameter directive [String] The original directive text.
|
@@ -12,7 +12,7 @@ module Decode
|
|
12
12
|
# - `@parameter age [Float] The users age.`
|
13
13
|
#
|
14
14
|
class Parameter < Tag
|
15
|
-
PATTERN = /\A(?<name>.*?)\s+\[(
|
15
|
+
PATTERN = /\A(?<name>.*?)\s+\[#{Tag.bracketed_content(:type)}\](\s+(?<details>.*?))?\Z/
|
16
16
|
|
17
17
|
# Build a parameter from a directive and regex match.
|
18
18
|
# @parameter directive [String] The original directive text.
|
data/lib/decode/comment/tag.rb
CHANGED
@@ -9,6 +9,13 @@ module Decode
|
|
9
9
|
module Comment
|
10
10
|
# Represents a documentation tag parsed from a comment directive.
|
11
11
|
class Tag < Node
|
12
|
+
# Build a pattern for bracketed content, supporting nested brackets.
|
13
|
+
# @parameter name [String] The name of the group.
|
14
|
+
# @returns [String] The pattern.
|
15
|
+
def self.bracketed_content(name)
|
16
|
+
"(?<#{name}>(?:[^\\[\\]]+|\\[\\g<#{name}>\\])*)"
|
17
|
+
end
|
18
|
+
|
12
19
|
# Match text against the tag pattern.
|
13
20
|
# @parameter text [String] The text to match.
|
14
21
|
def self.match(text)
|
data/lib/decode/rbs/method.rb
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
|
6
6
|
require "rbs"
|
7
7
|
require "console"
|
8
|
-
require "types"
|
9
8
|
require_relative "wrapper"
|
10
9
|
|
11
10
|
module Decode
|
@@ -202,8 +201,12 @@ module Decode
|
|
202
201
|
|
203
202
|
# Parse a type string and convert it to RBS type
|
204
203
|
def parse_type_string(type_string)
|
205
|
-
|
206
|
-
|
204
|
+
# This is for backwards compatibility with the old syntax, eventually we will emit warnings for these:
|
205
|
+
type_string = type_string.tr("()", "[]")
|
206
|
+
type_string.gsub!("| Nil", "| nil")
|
207
|
+
type_string.gsub!("Boolean", "bool")
|
208
|
+
|
209
|
+
return ::RBS::Parser.parse_type(type_string)
|
207
210
|
rescue => error
|
208
211
|
Console.warn(self, "Failed to parse type string: #{type_string}", error)
|
209
212
|
return ::RBS::Parser.parse_type("untyped")
|
data/lib/decode/version.rb
CHANGED
data/sig/decode.rbs
ADDED
@@ -0,0 +1,801 @@
|
|
1
|
+
module Decode
|
2
|
+
# Represents comment parsing and processing functionality.
|
3
|
+
module Comment
|
4
|
+
# Describes an attribute type.
|
5
|
+
#
|
6
|
+
# - `@attribute [Integer] The person's age.`
|
7
|
+
class Attribute < ::Tag
|
8
|
+
# Build an attribute from a directive and match.
|
9
|
+
public def self.build: (String directive, MatchData match) -> untyped
|
10
|
+
|
11
|
+
# Initialize a new attribute.
|
12
|
+
public def initialize: (String directive, String type) -> void
|
13
|
+
end
|
14
|
+
|
15
|
+
# Represents a node in a comment tree structure.
|
16
|
+
class Node
|
17
|
+
# Initialize the node.
|
18
|
+
public def initialize: (Array[Node] | nil children) -> void
|
19
|
+
|
20
|
+
# Whether this node has any children nodes.
|
21
|
+
# Ignores {Text} instances.
|
22
|
+
public def children?: () -> bool
|
23
|
+
|
24
|
+
# Add a child node to this node.
|
25
|
+
public def add: (Node child) -> self
|
26
|
+
|
27
|
+
# Enumerate all non-text children nodes.
|
28
|
+
public def each: () -> untyped
|
29
|
+
|
30
|
+
# Filter children nodes by class type.
|
31
|
+
public def filter: (Class klass) -> untyped
|
32
|
+
|
33
|
+
# Any lines of text associated with this node.
|
34
|
+
public def text: () -> (Array[String] | nil)
|
35
|
+
|
36
|
+
# Traverse the tags from this node using {each}. Invoke `descend.call(child)` to recursively traverse the specified child.
|
37
|
+
public def traverse: () { (Node node, Proc descend) -> void } -> untyped
|
38
|
+
end
|
39
|
+
|
40
|
+
# Describes a method option (keyword argument).
|
41
|
+
#
|
42
|
+
# - `@option :cached [Boolean] Whether to cache the value.`
|
43
|
+
class Option < ::Parameter
|
44
|
+
end
|
45
|
+
|
46
|
+
# Represents a named method parameter.
|
47
|
+
#
|
48
|
+
# - `@parameter age [Float] The users age.`
|
49
|
+
class Parameter < ::Tag
|
50
|
+
# Build a parameter from a directive and regex match.
|
51
|
+
public def self.build: (String directive, MatchData match) -> Parameter
|
52
|
+
|
53
|
+
# Initialize a new parameter.
|
54
|
+
public def initialize: (String directive, String name, String type) -> void
|
55
|
+
end
|
56
|
+
|
57
|
+
# Asserts a specific property about the method signature.
|
58
|
+
#
|
59
|
+
# - `@reentrant This method is thread-safe.`
|
60
|
+
# - `@deprecated Please use {other_method} instead.`
|
61
|
+
# - `@blocking This method may block.`
|
62
|
+
# - `@asynchronous This method may yield.`
|
63
|
+
class Pragma < ::Tag
|
64
|
+
# Parse a pragma directive from text.
|
65
|
+
public def self.parse: (String directive, String text, Array[String] lines, Array[Tag] tags, Integer level) -> untyped
|
66
|
+
|
67
|
+
# Build a pragma from a directive and text.
|
68
|
+
public def self.build: (String directive, String text) -> untyped
|
69
|
+
|
70
|
+
# Initialize a new pragma.
|
71
|
+
public def initialize: (String directive) -> void
|
72
|
+
end
|
73
|
+
|
74
|
+
# Identifies that a method might raise an exception.
|
75
|
+
#
|
76
|
+
# - `@raises [ArgumentError] If the argument cannot be coerced.`
|
77
|
+
class Raises < ::Attribute
|
78
|
+
end
|
79
|
+
|
80
|
+
# Represents an RBS type annotation following rbs-inline syntax.
|
81
|
+
#
|
82
|
+
# Examples:
|
83
|
+
# - `@rbs generic T` - Declares a generic type parameter for a class
|
84
|
+
# - `@rbs [T] () { () -> T } -> Task[T]` - Complete method type signature
|
85
|
+
class RBS < ::Tag
|
86
|
+
# Parse an RBS pragma from text.
|
87
|
+
public def self.parse: (String directive, String text, Array[String] lines, Array[Tag] tags, Integer level) -> untyped
|
88
|
+
|
89
|
+
# Build an RBS pragma from a directive and text.
|
90
|
+
public def self.build: (String directive, String text) -> untyped
|
91
|
+
|
92
|
+
# Initialize a new RBS pragma.
|
93
|
+
public def initialize: (String directive, String text) -> void
|
94
|
+
|
95
|
+
# Check if this is a generic type declaration.
|
96
|
+
public def generic?: () -> bool
|
97
|
+
|
98
|
+
# Extract the generic type parameter name.
|
99
|
+
public def generic_parameter: () -> (String | nil)
|
100
|
+
|
101
|
+
# Check if this is a method type signature.
|
102
|
+
public def method_signature?: () -> bool
|
103
|
+
|
104
|
+
# Get the method type signature text.
|
105
|
+
public def method_signature: () -> (String | nil)
|
106
|
+
end
|
107
|
+
|
108
|
+
# Represents a return value.
|
109
|
+
#
|
110
|
+
# Example: `@returns [Integer] The person's age.`
|
111
|
+
class Returns < ::Attribute
|
112
|
+
end
|
113
|
+
|
114
|
+
# Represents a documentation tag parsed from a comment directive.
|
115
|
+
class Tag < ::Node
|
116
|
+
# Build a pattern for bracketed content, supporting nested brackets.
|
117
|
+
public def self.bracketed_content: (String name) -> String
|
118
|
+
|
119
|
+
# Match text against the tag pattern.
|
120
|
+
public def self.match: (String text) -> untyped
|
121
|
+
|
122
|
+
# Parse a tag from a directive and text.
|
123
|
+
public def self.parse: (String directive, String text, Array[String] lines, Tags tags, Integer level) -> untyped
|
124
|
+
|
125
|
+
# Initialize a new tag.
|
126
|
+
public def initialize: (String directive) -> void
|
127
|
+
end
|
128
|
+
|
129
|
+
# Represents a collection of documentation tags and their parsing logic.
|
130
|
+
class Tags
|
131
|
+
# Build a tags parser with directive mappings.
|
132
|
+
public def self.build: (Proc block) -> untyped
|
133
|
+
|
134
|
+
# Initialize a new tags parser.
|
135
|
+
public def initialize: (Hash[String, Class] directives) -> void
|
136
|
+
|
137
|
+
# Check if a line has valid indentation for the given level.
|
138
|
+
public def valid_indentation?: (String line, Integer level) -> bool
|
139
|
+
|
140
|
+
# Parse documentation tags from lines.
|
141
|
+
public def parse: (Array[String] lines, Integer level, Proc block) -> untyped
|
142
|
+
|
143
|
+
# Ignore lines at the specified indentation level.
|
144
|
+
public def ignore: (Array[String] lines, Integer level) -> untyped
|
145
|
+
end
|
146
|
+
|
147
|
+
# A structured comment.
|
148
|
+
class Text
|
149
|
+
# Initialize a new text node.
|
150
|
+
public def initialize: (String line) -> void
|
151
|
+
|
152
|
+
# Traverse the text node.
|
153
|
+
public def traverse: () -> untyped
|
154
|
+
end
|
155
|
+
|
156
|
+
# Identifies that a method might throw a specific symbol.
|
157
|
+
#
|
158
|
+
# - `@throws [:skip] To skip recursion.`
|
159
|
+
class Throws < ::Attribute
|
160
|
+
end
|
161
|
+
|
162
|
+
# Describes a block parameter.
|
163
|
+
#
|
164
|
+
# - `@yields {|person| ... } If a block is given.`
|
165
|
+
#
|
166
|
+
# Should contain nested parameters.
|
167
|
+
class Yields < ::Tag
|
168
|
+
# Build a yields tag from a directive and match.
|
169
|
+
public def self.build: (String directive, MatchData match) -> untyped
|
170
|
+
|
171
|
+
# Initialize a new yields tag.
|
172
|
+
public def initialize: (String directive, String block) -> void
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
# A symbol with attached documentation.
|
177
|
+
class Definition
|
178
|
+
# Initialize the symbol.
|
179
|
+
public def initialize: (Symbol | Array[Symbol] path, Symbol parent, Language language, Array[String] comments, Source source) -> void
|
180
|
+
|
181
|
+
# Generate a debug representation of the definition.
|
182
|
+
public def inspect: () -> untyped
|
183
|
+
|
184
|
+
# The symbol name.
|
185
|
+
# e.g. `:Decode`.
|
186
|
+
public def name: () -> untyped
|
187
|
+
|
188
|
+
# The full path to the definition.
|
189
|
+
public def full_path: () -> untyped
|
190
|
+
|
191
|
+
# Whether the definition is considered part of the public interface.
|
192
|
+
# This is used to determine whether the definition should be documented for coverage purposes.
|
193
|
+
public def public?: () -> bool
|
194
|
+
|
195
|
+
# Whether the definition has documentation.
|
196
|
+
public def documented?: () -> bool
|
197
|
+
|
198
|
+
# The qualified name is an absolute name which includes any and all namespacing.
|
199
|
+
public def qualified_name: () -> String
|
200
|
+
|
201
|
+
# The name relative to the parent.
|
202
|
+
public def nested_name: () -> String
|
203
|
+
|
204
|
+
# Does the definition name match the specified prefix?
|
205
|
+
public def start_with?: () -> bool
|
206
|
+
|
207
|
+
# Convert this definition into another kind of definition.
|
208
|
+
public def convert: () -> untyped
|
209
|
+
|
210
|
+
# A short form of the definition.
|
211
|
+
# e.g. `def short_form`.
|
212
|
+
public def short_form: () -> (String | nil)
|
213
|
+
|
214
|
+
# A long form of the definition.
|
215
|
+
# e.g. `def initialize(kind, name, comments, **options)`.
|
216
|
+
public def long_form: () -> (String | nil)
|
217
|
+
|
218
|
+
# A long form which uses the qualified name if possible.
|
219
|
+
# Defaults to {long_form}.
|
220
|
+
public def qualified_form: () -> (String | nil)
|
221
|
+
|
222
|
+
# Whether the definition spans multiple lines.
|
223
|
+
public def multiline?: () -> bool
|
224
|
+
|
225
|
+
# The full text of the definition.
|
226
|
+
public def text: () -> (String | nil)
|
227
|
+
|
228
|
+
# Whether this definition can contain nested definitions.
|
229
|
+
public def container?: () -> bool
|
230
|
+
|
231
|
+
# Whether this represents a single entity to be documented (along with it's contents).
|
232
|
+
public def nested?: () -> bool
|
233
|
+
|
234
|
+
# Structured access to the definitions comments.
|
235
|
+
public def documentation: () -> (Documentation | nil)
|
236
|
+
|
237
|
+
# The location of the definition.
|
238
|
+
public def location: () -> (Location | nil)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Structured access to a set of comment lines.
|
242
|
+
class Documentation < ::Comment::Node
|
243
|
+
# Initialize the documentation with an array of comments, within a specific language.
|
244
|
+
public def initialize: (Array[String] comments, Language language) -> void
|
245
|
+
end
|
246
|
+
|
247
|
+
# Represents a list of definitions organised for quick lookup and lexical enumeration.
|
248
|
+
class Index
|
249
|
+
# Create and populate an index from the given paths.
|
250
|
+
public def self.for: (Array[String] paths, Languages languages) -> Index
|
251
|
+
|
252
|
+
# Initialize an empty index.
|
253
|
+
public def initialize: (Languages languages) -> void
|
254
|
+
|
255
|
+
# Generate a string representation of this index.
|
256
|
+
public def inspect: () -> String
|
257
|
+
|
258
|
+
# Updates the index by parsing the specified files.
|
259
|
+
# All extracted definitions are merged into the existing index.
|
260
|
+
public def update: (Array[String] paths) -> untyped
|
261
|
+
|
262
|
+
# Lookup the specified reference and return matching definitions.
|
263
|
+
public def lookup: (Language::Reference reference, Definition relative_to) -> (Definition | nil)
|
264
|
+
end
|
265
|
+
|
266
|
+
# Language specific parsers and definitions.
|
267
|
+
module Language
|
268
|
+
# Represents a generic language implementation that can be extended for specific languages.
|
269
|
+
class Generic
|
270
|
+
# Initialize a new generic language.
|
271
|
+
public def initialize: (String name, Array[String] extensions, Comment::Tags tags) -> void
|
272
|
+
|
273
|
+
# Get all names for this language.
|
274
|
+
public def names: () -> Array[String]
|
275
|
+
|
276
|
+
# Generate a language-specific reference.
|
277
|
+
public def reference_for: (String identifier) -> Reference
|
278
|
+
|
279
|
+
# Get the parser for this language.
|
280
|
+
public def parser: () -> (Parser | nil)
|
281
|
+
|
282
|
+
# Parse the input yielding definitions.
|
283
|
+
public def definitions_for: (Source source) { (Definition definition) -> void } -> Enumerator[Segment]
|
284
|
+
|
285
|
+
# Parse the input yielding segments.
|
286
|
+
# Segments are constructed from a block of top level comments followed by a block of code.
|
287
|
+
public def segments_for: (Source source) { (Segment segment) -> void } -> Enumerator[Segment]
|
288
|
+
end
|
289
|
+
|
290
|
+
# An reference which can be resolved to zero or more definitions.
|
291
|
+
class Reference
|
292
|
+
# Initialize the reference.
|
293
|
+
public def initialize: (String identifier) -> void
|
294
|
+
|
295
|
+
# Generate a string representation of the reference.
|
296
|
+
public def to_s: () -> untyped
|
297
|
+
|
298
|
+
# Generate a debug representation of the reference.
|
299
|
+
public def inspect: () -> untyped
|
300
|
+
|
301
|
+
# Whether the reference starts at the base of the lexical tree.
|
302
|
+
public def absolute?: () -> bool
|
303
|
+
|
304
|
+
# Check if this is a relative reference.
|
305
|
+
public def relative?: () -> bool
|
306
|
+
|
307
|
+
# Split an identifier into prefix and name components.
|
308
|
+
public def split: (String identifier) -> untyped
|
309
|
+
|
310
|
+
# Get the lexical path of this reference.
|
311
|
+
public def lexical_path: () -> untyped
|
312
|
+
|
313
|
+
# Calculate the priority of a definition for matching.
|
314
|
+
public def priority: (String definition, String prefix) -> untyped
|
315
|
+
|
316
|
+
# Find the best matching definition from a list.
|
317
|
+
public def best: (Array[String] definitions) -> untyped
|
318
|
+
|
319
|
+
# The lexical path of the reference.
|
320
|
+
public def path: () -> Array[String]
|
321
|
+
end
|
322
|
+
|
323
|
+
# Represents an interface for extracting information from Ruby source code.
|
324
|
+
module Ruby
|
325
|
+
# Create a new Ruby language instance.
|
326
|
+
public def self.new: () -> Ruby::Generic
|
327
|
+
|
328
|
+
# Represents an alias statement, e.g., `alias new_name old_name` or `alias_method :new_name, :old_name`
|
329
|
+
class Alias < ::Definition
|
330
|
+
# Initialize a new alias definition.
|
331
|
+
public def initialize: (String new_name, String old_name, Hash options) -> void
|
332
|
+
|
333
|
+
# Generate a short form representation of the alias.
|
334
|
+
public def short_form: () -> untyped
|
335
|
+
|
336
|
+
# Generate a long form representation of the alias.
|
337
|
+
public def long_form: () -> untyped
|
338
|
+
|
339
|
+
# Generate a string representation of the alias.
|
340
|
+
public def to_s: () -> untyped
|
341
|
+
end
|
342
|
+
|
343
|
+
# A Ruby-specific attribute.
|
344
|
+
class Attribute < ::Definition
|
345
|
+
# The short form of the attribute.
|
346
|
+
# e.g. `attr :value`.
|
347
|
+
public def short_form: () -> untyped
|
348
|
+
|
349
|
+
# Generate a long form representation of the attribute.
|
350
|
+
public def long_form: () -> untyped
|
351
|
+
end
|
352
|
+
|
353
|
+
# A Ruby-specific block which might carry other definitions.
|
354
|
+
class Block < ::Definition
|
355
|
+
# A block can sometimes be a container for other definitions.
|
356
|
+
public def container?: () -> bool
|
357
|
+
|
358
|
+
# Generate a nested name for the block.
|
359
|
+
public def nested_name: () -> untyped
|
360
|
+
|
361
|
+
# The short form of the block.
|
362
|
+
# e.g. `foo`.
|
363
|
+
public def short_form: () -> untyped
|
364
|
+
|
365
|
+
# The long form of the block.
|
366
|
+
# e.g. `foo(:bar)`.
|
367
|
+
public def long_form: () -> untyped
|
368
|
+
|
369
|
+
# The fully qualified name of the block.
|
370
|
+
# e.g. `::Barnyard::foo`.
|
371
|
+
public def qualified_form: () -> untyped
|
372
|
+
|
373
|
+
# Convert the block to a different kind of definition.
|
374
|
+
public def convert: (Symbol kind) -> untyped
|
375
|
+
end
|
376
|
+
|
377
|
+
# A Ruby-specific block which might carry other definitions.
|
378
|
+
class Call < ::Definition
|
379
|
+
# A block can sometimes be a container for other definitions.
|
380
|
+
public def container?: () -> bool
|
381
|
+
|
382
|
+
# The short form of the class.
|
383
|
+
# e.g. `foo`.
|
384
|
+
public def short_form: () -> untyped
|
385
|
+
|
386
|
+
# The long form of the class.
|
387
|
+
# e.g. `foo(:bar)`.
|
388
|
+
public def long_form: () -> untyped
|
389
|
+
|
390
|
+
# The fully qualified name of the block.
|
391
|
+
# e.g. `class ::Barnyard::Dog`.
|
392
|
+
public def qualified_form: () -> untyped
|
393
|
+
end
|
394
|
+
|
395
|
+
# A Ruby-specific class.
|
396
|
+
class Class < ::Definition
|
397
|
+
# Initialize a new class definition.
|
398
|
+
public def initialize: (Array arguments, String super_class, Hash options) -> void
|
399
|
+
|
400
|
+
# A class is a container for other definitions.
|
401
|
+
public def container?: () -> bool
|
402
|
+
|
403
|
+
# The short form of the class.
|
404
|
+
# e.g. `class Animal`.
|
405
|
+
public def short_form: () -> untyped
|
406
|
+
|
407
|
+
# The long form of the class.
|
408
|
+
# e.g. `class Dog < Animal`.
|
409
|
+
public def long_form: () -> untyped
|
410
|
+
|
411
|
+
# The fully qualified name of the class.
|
412
|
+
# e.g. `class ::Barnyard::Dog`.
|
413
|
+
public def qualified_form: () -> untyped
|
414
|
+
end
|
415
|
+
|
416
|
+
# A Ruby-specific singleton class.
|
417
|
+
class Singleton < ::Definition
|
418
|
+
# Generate a nested name for the singleton class.
|
419
|
+
public def nested_name: () -> untyped
|
420
|
+
|
421
|
+
# A singleton class is a container for other definitions.
|
422
|
+
public def container?: () -> bool
|
423
|
+
|
424
|
+
# Typically, a singleton class does not contain other definitions.
|
425
|
+
public def nested?: () -> bool
|
426
|
+
|
427
|
+
# The short form of the class.
|
428
|
+
# e.g. `class << self`.
|
429
|
+
public def short_form: () -> untyped
|
430
|
+
end
|
431
|
+
|
432
|
+
# A Ruby-specific block of code.
|
433
|
+
class Code
|
434
|
+
# Initialize a new code block.
|
435
|
+
public def initialize: (String text, Index index, Definition relative_to, Language language) -> void
|
436
|
+
|
437
|
+
# Extract definitions from the code.
|
438
|
+
public def extract: (Array into) -> untyped
|
439
|
+
end
|
440
|
+
|
441
|
+
# A Ruby-specific constant.
|
442
|
+
class Constant < ::Definition
|
443
|
+
# The short form of the constant.
|
444
|
+
# e.g. `NAME`.
|
445
|
+
public def short_form: () -> untyped
|
446
|
+
|
447
|
+
# Generate a nested name for the constant.
|
448
|
+
public def nested_name: () -> untyped
|
449
|
+
|
450
|
+
# The long form of the constant.
|
451
|
+
# e.g. `NAME = "Alice"`.
|
452
|
+
public def long_form: () -> untyped
|
453
|
+
end
|
454
|
+
|
455
|
+
# Represents a Ruby-specific definition extracted from source code.
|
456
|
+
class Definition < ::Decode::Definition
|
457
|
+
# Initialize the definition from the syntax tree node.
|
458
|
+
public def initialize: (Array arguments, Symbol visibility, Parser::AST::Node node, Hash options) -> void
|
459
|
+
|
460
|
+
# Check if this definition is public.
|
461
|
+
public def public?: () -> bool
|
462
|
+
|
463
|
+
# Check if this definition spans multiple lines.
|
464
|
+
public def multiline?: () -> bool
|
465
|
+
|
466
|
+
# The source code associated with the definition.
|
467
|
+
public def text: () -> String
|
468
|
+
|
469
|
+
# Get the location of this definition.
|
470
|
+
public def location: () -> (Location | nil)
|
471
|
+
end
|
472
|
+
|
473
|
+
# A Ruby-specific function.
|
474
|
+
class Function < ::Method
|
475
|
+
# Generate a nested name for the function.
|
476
|
+
public def nested_name: () -> untyped
|
477
|
+
|
478
|
+
# The node which contains the function arguments.
|
479
|
+
public def arguments_node: () -> untyped
|
480
|
+
end
|
481
|
+
|
482
|
+
# Represents the Ruby language implementation for parsing and analysis.
|
483
|
+
class Generic < ::Language::Generic
|
484
|
+
# Get the parser for Ruby source code.
|
485
|
+
public def parser: () -> Parser
|
486
|
+
|
487
|
+
# Generate a language-specific reference for Ruby.
|
488
|
+
public def reference_for: (String identifier) -> Reference
|
489
|
+
|
490
|
+
# Generate a code representation with syntax highlighting and link resolution.
|
491
|
+
public def code_for: (String text, Index index, Definition relative_to) -> Code
|
492
|
+
end
|
493
|
+
|
494
|
+
# A Ruby-specific method.
|
495
|
+
class Method < ::Definition
|
496
|
+
# Initialize a new method definition.
|
497
|
+
public def initialize: (Array arguments, String receiver, Hash options) -> void
|
498
|
+
|
499
|
+
# Generate a nested name for the method.
|
500
|
+
public def nested_name: () -> untyped
|
501
|
+
|
502
|
+
# The short form of the method.
|
503
|
+
# e.g. `def puts` or `def self.puts`.
|
504
|
+
public def short_form: () -> untyped
|
505
|
+
|
506
|
+
# The node which contains the function arguments.
|
507
|
+
public def arguments_node: () -> untyped
|
508
|
+
|
509
|
+
# The long form of the method.
|
510
|
+
# e.g. `def puts(*lines, separator: "\n")` or `def self.puts(*lines, separator: "\n")`.
|
511
|
+
public def long_form: () -> untyped
|
512
|
+
|
513
|
+
# The fully qualified name of the block.
|
514
|
+
# e.g. `::Barnyard#foo`.
|
515
|
+
public def qualified_form: () -> untyped
|
516
|
+
|
517
|
+
# Override the qualified_name method to handle method name joining correctly
|
518
|
+
public def qualified_name: () -> untyped
|
519
|
+
|
520
|
+
# Convert the method to a different kind of definition.
|
521
|
+
public def convert: (Symbol kind) -> untyped
|
522
|
+
end
|
523
|
+
|
524
|
+
# A Ruby-specific module.
|
525
|
+
class Module < ::Definition
|
526
|
+
# A module is a container for other definitions.
|
527
|
+
public def container?: () -> bool
|
528
|
+
|
529
|
+
# The short form of the module.
|
530
|
+
# e.g. `module Barnyard`.
|
531
|
+
public def short_form: () -> untyped
|
532
|
+
|
533
|
+
# Generate a long form representation of the module.
|
534
|
+
public def long_form: () -> untyped
|
535
|
+
|
536
|
+
# The fully qualified name of the module.
|
537
|
+
# e.g. `module ::Barnyard::Dog`.
|
538
|
+
public def qualified_form: () -> untyped
|
539
|
+
end
|
540
|
+
|
541
|
+
# The Ruby source code parser.
|
542
|
+
class Parser
|
543
|
+
# Initialize a new Ruby parser.
|
544
|
+
public def initialize: (Language language) -> void
|
545
|
+
|
546
|
+
# Extract definitions from the given input file.
|
547
|
+
public def definitions_for: () -> untyped
|
548
|
+
|
549
|
+
# Walk over the syntax tree and extract relevant definitions with their associated comments.
|
550
|
+
public def walk_definitions: () -> untyped
|
551
|
+
|
552
|
+
# Extract segments from the given input file.
|
553
|
+
public def segments_for: () -> untyped
|
554
|
+
end
|
555
|
+
|
556
|
+
# An Ruby-specific reference which can be resolved to zero or more definitions.
|
557
|
+
class Reference < ::Language::Reference
|
558
|
+
# Create a reference from a constant node.
|
559
|
+
public def self.from_const: (Prism::Node node, Language language) -> untyped
|
560
|
+
|
561
|
+
# Append a constant node to the path.
|
562
|
+
public def self.append_const: (Prism::Node node, Array path) -> self
|
563
|
+
|
564
|
+
# Split a Ruby identifier into prefix and name components.
|
565
|
+
public def split: (String text) -> untyped
|
566
|
+
end
|
567
|
+
|
568
|
+
# A Ruby specific code segment.
|
569
|
+
class Segment < ::Decode::Segment
|
570
|
+
# Initialize a new Ruby segment.
|
571
|
+
public def initialize: (Array[String] comments, Language language, Prism::Node node, Hash options) -> void
|
572
|
+
|
573
|
+
# Expand the segment to include another node.
|
574
|
+
public def expand: (Prism::Node node) -> untyped
|
575
|
+
|
576
|
+
# The source code trailing the comments.
|
577
|
+
public def code: () -> (String | nil)
|
578
|
+
end
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
# Represents a context for looking up languages based on file extension or name.
|
583
|
+
class Languages
|
584
|
+
# Create a new languages context with all supported languages.
|
585
|
+
public def self.all: () -> Languages
|
586
|
+
|
587
|
+
# Initialize a new languages context.
|
588
|
+
public def initialize: () -> void
|
589
|
+
|
590
|
+
# Freeze the languages context to prevent further modifications.
|
591
|
+
public def freeze: () -> untyped
|
592
|
+
|
593
|
+
# Add a language to this context.
|
594
|
+
public def add: (Language::Generic language) -> self
|
595
|
+
|
596
|
+
# Fetch a language by name, creating a generic language if needed.
|
597
|
+
public def fetch: (String name) -> Language::Generic
|
598
|
+
|
599
|
+
# Create a source object for the given file path.
|
600
|
+
public def source_for: (String path) -> (Source | nil)
|
601
|
+
|
602
|
+
# Parse a language agnostic reference.
|
603
|
+
public def parse_reference: (String text, Language::Generic default_language) -> (Language::Reference | nil)
|
604
|
+
|
605
|
+
# Create a reference for the given language and identifier.
|
606
|
+
public def reference_for: (String name, String identifier) -> Language::Reference
|
607
|
+
end
|
608
|
+
|
609
|
+
# Represents a location in a source file.
|
610
|
+
class Location
|
611
|
+
# Generate a string representation of the location.
|
612
|
+
public def to_s: () -> untyped
|
613
|
+
end
|
614
|
+
|
615
|
+
# RBS generation functionality for Ruby type signatures.
|
616
|
+
module RBS
|
617
|
+
# Represents a Ruby class definition wrapper for RBS generation.
|
618
|
+
class Class < ::Wrapper
|
619
|
+
# Initialize a new class wrapper.
|
620
|
+
public def initialize: (Decode::Definition definition) -> void
|
621
|
+
|
622
|
+
# Extract generic type parameters from the class definition.
|
623
|
+
public def generics: () -> Array
|
624
|
+
|
625
|
+
# Convert the class definition to RBS AST
|
626
|
+
public def to_rbs_ast: () -> untyped
|
627
|
+
end
|
628
|
+
|
629
|
+
# Represents a generator for RBS type declarations.
|
630
|
+
class Generator
|
631
|
+
# Initialize a new RBS generator.
|
632
|
+
# Sets up the RBS environment for type resolution.
|
633
|
+
public def initialize: () -> void
|
634
|
+
|
635
|
+
# Generate RBS declarations for the given index.
|
636
|
+
public def generate: (Decode::Index index, IO output) -> untyped
|
637
|
+
end
|
638
|
+
|
639
|
+
# Represents a Ruby method definition wrapper for RBS generation.
|
640
|
+
class Method < ::Wrapper
|
641
|
+
# Initialize a new method wrapper.
|
642
|
+
public def initialize: (Decode::Definition definition) -> void
|
643
|
+
|
644
|
+
# Extract method signatures from the method definition.
|
645
|
+
public def signatures: () -> Array
|
646
|
+
|
647
|
+
# Convert the method definition to RBS AST
|
648
|
+
public def to_rbs_ast: () -> untyped
|
649
|
+
end
|
650
|
+
|
651
|
+
# Represents a Ruby module definition wrapper for RBS generation.
|
652
|
+
class Module < ::Wrapper
|
653
|
+
# Initialize a new module wrapper.
|
654
|
+
public def initialize: (Decode::Definition definition) -> void
|
655
|
+
|
656
|
+
# Convert the module definition to RBS AST
|
657
|
+
public def to_rbs_ast: () -> untyped
|
658
|
+
end
|
659
|
+
|
660
|
+
# Base wrapper class for RBS generation from definitions.
|
661
|
+
class Wrapper
|
662
|
+
# Initialize the wrapper instance variables.
|
663
|
+
public def initialize: (Definition definition) -> void
|
664
|
+
|
665
|
+
# Extract RBS tags from the definition's documentation.
|
666
|
+
public def tags: () -> Array
|
667
|
+
end
|
668
|
+
end
|
669
|
+
|
670
|
+
# An abstract namespace for nesting definitions.
|
671
|
+
class Scope < ::Definition
|
672
|
+
public def short_form: () -> String
|
673
|
+
|
674
|
+
# Scopes are always containers.
|
675
|
+
public def container?: () -> bool
|
676
|
+
end
|
677
|
+
|
678
|
+
# A chunk of code with an optional preceeding comment block.
|
679
|
+
#
|
680
|
+
# ~~~ ruby
|
681
|
+
# # Get the first segment from a source file:
|
682
|
+
# segment = source.segments.first
|
683
|
+
# ~~~
|
684
|
+
class Segment
|
685
|
+
# Initialize a new segment.
|
686
|
+
public def initialize: (Array[String] comments, Language::Generic language) -> void
|
687
|
+
|
688
|
+
# An interface for accsssing the documentation of the definition.
|
689
|
+
public def documentation: () -> (Documentation | nil)
|
690
|
+
|
691
|
+
# The source code trailing the comments.
|
692
|
+
public def code: () -> (String | nil)
|
693
|
+
end
|
694
|
+
|
695
|
+
# Represents a source file in a specific language.
|
696
|
+
class Source
|
697
|
+
# Initialize a new source file.
|
698
|
+
public def initialize: (String path, Language::Generic language) -> void
|
699
|
+
|
700
|
+
# The relative path of the source, if it is known.
|
701
|
+
public def relative_path: () -> String
|
702
|
+
|
703
|
+
# Read the source file into an internal buffer/cache.
|
704
|
+
public def read: () -> String
|
705
|
+
|
706
|
+
# Open the source file and read all definitions.
|
707
|
+
public def definitions: () { (Definition definition) -> void } -> Enumerator[Definition]
|
708
|
+
|
709
|
+
# Open the source file and read all segments.
|
710
|
+
public def segments: () { (Segment segment) -> void } -> Enumerator[Segment]
|
711
|
+
|
712
|
+
# Generate code representation with optional index for link resolution.
|
713
|
+
public def code: (Index index, Definition relative_to) -> String
|
714
|
+
end
|
715
|
+
|
716
|
+
# Provides syntax rewriting and linking functionality.
|
717
|
+
module Syntax
|
718
|
+
# Represents a link to a definition in the documentation.
|
719
|
+
class Link < ::Match
|
720
|
+
# Initialize a new link.
|
721
|
+
public def initialize: (Range range, Definition definition) -> void
|
722
|
+
|
723
|
+
# Apply the link to the output.
|
724
|
+
public def apply: (String output, Rewriter rewriter) -> untyped
|
725
|
+
end
|
726
|
+
|
727
|
+
# Represents a match in the source text for syntax rewriting.
|
728
|
+
class Match
|
729
|
+
# Initialize a new match.
|
730
|
+
public def initialize: (Range range) -> void
|
731
|
+
|
732
|
+
# Apply the match to extract text from source.
|
733
|
+
public def apply: (String source) -> untyped
|
734
|
+
|
735
|
+
# Apply the match to the output.
|
736
|
+
public def apply: (String output, Rewriter rewriter) -> untyped
|
737
|
+
|
738
|
+
# Compare matches by their starting position.
|
739
|
+
public def <=>: (Match other) -> untyped
|
740
|
+
|
741
|
+
# Get the starting offset of this match.
|
742
|
+
public def offset: () -> untyped
|
743
|
+
|
744
|
+
# Get the size of this match.
|
745
|
+
public def size: () -> untyped
|
746
|
+
end
|
747
|
+
|
748
|
+
# Provides text rewriting functionality with match-based substitutions.
|
749
|
+
class Rewriter
|
750
|
+
# Initialize a new rewriter.
|
751
|
+
public def initialize: (String text) -> void
|
752
|
+
|
753
|
+
# Add a match to the rewriter.
|
754
|
+
public def <<: (Match match) -> self
|
755
|
+
|
756
|
+
# Returns a chunk of raw text with no formatting.
|
757
|
+
public def text_for: () -> untyped
|
758
|
+
|
759
|
+
# Apply all matches to generate the rewritten output.
|
760
|
+
public def apply: (Array output) -> untyped
|
761
|
+
|
762
|
+
# Generate a link to a definition.
|
763
|
+
public def link_to: (Definition definition, String text) -> untyped
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
# Represents a prefix-trie data structure for fast lexical lookups.
|
768
|
+
class Trie
|
769
|
+
# Initialize an empty trie.
|
770
|
+
public def initialize: () -> void
|
771
|
+
|
772
|
+
# Insert the specified value at the given path into the trie.
|
773
|
+
public def insert: (Array[String] path, Object value) -> untyped
|
774
|
+
|
775
|
+
# Lookup the values at the specified path.
|
776
|
+
public def lookup: (Array[String] path) -> (Node | nil)
|
777
|
+
|
778
|
+
# Enumerate all lexical scopes under the specified path.
|
779
|
+
public def each: (Array[String] path) { (Array[String] path, Array[Object] | nil values) -> void } -> untyped
|
780
|
+
|
781
|
+
# Traverse the trie starting from the specified path.
|
782
|
+
# See {Node#traverse} for details.
|
783
|
+
public def traverse: (Array[String] path) { () -> void } -> untyped
|
784
|
+
|
785
|
+
# Represents a single node in the trie.
|
786
|
+
class Node
|
787
|
+
# Initialize a new trie node.
|
788
|
+
public def initialize: () -> void
|
789
|
+
|
790
|
+
# Generate a string representation of this node.
|
791
|
+
public def inspect: () -> String
|
792
|
+
|
793
|
+
# Look up a lexical path starting at this node.
|
794
|
+
public def lookup: (Array[String] path, Integer index) -> (Node | nil)
|
795
|
+
|
796
|
+
# Traverse the trie from this node.
|
797
|
+
# Invoke `descend.call` to traverse the children of the current node.
|
798
|
+
public def traverse: (Array[String] path) { (Array[String] path, Node node, Proc descend) -> void } -> untyped
|
799
|
+
end
|
800
|
+
end
|
801
|
+
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.24.
|
4
|
+
version: 0.24.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: types
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
executables: []
|
84
70
|
extensions: []
|
85
71
|
extra_rdoc_files: []
|
@@ -145,6 +131,7 @@ files:
|
|
145
131
|
- license.md
|
146
132
|
- readme.md
|
147
133
|
- releases.md
|
134
|
+
- sig/decode.rbs
|
148
135
|
homepage: https://github.com/socketry/decode
|
149
136
|
licenses:
|
150
137
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|