rbs 3.2.2 → 3.3.0.pre.1
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/workflows/comments.yml +1 -1
- data/.github/workflows/ruby.yml +7 -2
- data/CHANGELOG.md +85 -0
- data/Gemfile.lock +14 -14
- data/README.md +11 -2
- data/Rakefile +10 -7
- data/Steepfile +7 -7
- data/core/basic_object.rbs +7 -7
- data/core/binding.rbs +3 -3
- data/core/builtin.rbs +171 -5
- data/core/constants.rbs +17 -17
- data/core/dir.rbs +3 -3
- data/core/encoding.rbs +434 -628
- data/core/enumerator.rbs +37 -0
- data/core/exception.rbs +11 -11
- data/core/false_class.rbs +5 -11
- data/core/fiber.rbs +3 -3
- data/core/file_test.rbs +28 -26
- data/core/kernel.rbs +900 -21
- data/core/marshal.rbs +24 -14
- data/core/match_data.rbs +8 -8
- data/core/math.rbs +57 -53
- data/core/method.rbs +3 -1
- data/core/module.rbs +38 -36
- data/core/nil_class.rbs +7 -13
- data/core/object.rbs +3 -966
- data/core/process.rbs +3 -3
- data/core/ractor.rbs +2 -2
- data/core/rb_config.rbs +64 -43
- data/core/regexp.rbs +3 -3
- data/core/signal.rbs +10 -4
- data/core/struct.rbs +1 -1
- data/core/thread.rbs +7 -7
- data/core/thread_group.rbs +9 -9
- data/core/true_class.rbs +5 -11
- data/core/unbound_method.rbs +56 -7
- data/core/warning.rbs +33 -0
- data/docs/collection.md +56 -6
- data/docs/data_and_struct.md +57 -0
- data/docs/stdlib.md +61 -2
- data/docs/syntax.md +123 -2
- data/ext/rbs_extension/lexer.c +624 -569
- data/ext/rbs_extension/lexer.h +1 -0
- data/ext/rbs_extension/lexer.re +1 -0
- data/ext/rbs_extension/lexstate.c +1 -0
- data/ext/rbs_extension/parser.c +6 -0
- data/goodcheck.yml +2 -2
- data/lib/rbs/annotate/formatter.rb +13 -3
- data/lib/rbs/annotate/rdoc_source.rb +10 -1
- data/lib/rbs/cli/colored_io.rb +48 -0
- data/lib/rbs/cli/diff.rb +80 -0
- data/lib/rbs/cli.rb +151 -16
- data/lib/rbs/collection/config/lockfile.rb +0 -25
- data/lib/rbs/collection/config/lockfile_generator.rb +0 -6
- data/lib/rbs/collection/installer.rb +1 -1
- data/lib/rbs/collection/sources/git.rb +6 -4
- data/lib/rbs/collection/sources/local.rb +7 -5
- data/lib/rbs/diff.rb +104 -0
- data/lib/rbs/environment.rb +1 -1
- data/lib/rbs/method_type.rb +23 -0
- data/lib/rbs/prototype/rb.rb +2 -9
- data/lib/rbs/prototype/runtime/helpers.rb +59 -0
- data/lib/rbs/prototype/runtime/value_object_generator.rb +236 -0
- data/lib/rbs/prototype/runtime.rb +234 -150
- data/lib/rbs/sorter.rb +144 -117
- data/lib/rbs/test/guaranteed.rb +31 -0
- data/lib/rbs/test/type_check.rb +4 -4
- data/lib/rbs/test.rb +3 -0
- data/lib/rbs/types.rb +184 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -4
- data/lib/rbs.rb +1 -0
- data/rbs.gemspec +1 -0
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/cli/colored_io.rbs +15 -0
- data/sig/cli/diff.rbs +21 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/config/lockfile.rbs +0 -6
- data/sig/diff.rbs +23 -0
- data/sig/errors.rbs +1 -5
- data/sig/method_types.rbs +6 -0
- data/sig/prototype/runtime.rbs +108 -0
- data/sig/rdoc/rbs.rbs +4 -0
- data/sig/shims/bundler.rbs +5 -0
- data/sig/sorter.rbs +23 -5
- data/sig/types.rbs +29 -0
- data/stdlib/benchmark/0/benchmark.rbs +1 -1
- data/stdlib/cgi/0/core.rbs +2 -2
- data/stdlib/did_you_mean/0/did_you_mean.rbs +2 -2
- data/stdlib/digest/0/digest.rbs +1 -1
- data/stdlib/fileutils/0/fileutils.rbs +1 -1
- data/stdlib/forwardable/0/forwardable.rbs +4 -4
- data/stdlib/io-console/0/io-console.rbs +1 -1
- data/stdlib/json/0/json.rbs +37 -0
- data/stdlib/logger/0/logger.rbs +2 -2
- data/stdlib/net-http/0/manifest.yaml +1 -1
- data/stdlib/net-http/0/net-http.rbs +16 -63
- data/stdlib/net-protocol/0/manifest.yaml +2 -0
- data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
- data/stdlib/openssl/0/openssl.rbs +1 -1
- data/stdlib/pp/0/manifest.yaml +2 -0
- data/stdlib/pp/0/pp.rbs +301 -0
- data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
- data/stdlib/psych/0/manifest.yaml +3 -0
- data/stdlib/psych/0/psych.rbs +391 -0
- data/stdlib/{yaml → psych}/0/store.rbs +2 -2
- data/stdlib/rdoc/0/code_object.rbs +55 -0
- data/stdlib/rdoc/0/comment.rbs +60 -0
- data/stdlib/rdoc/0/context.rbs +153 -0
- data/stdlib/rdoc/0/markup.rbs +119 -0
- data/stdlib/rdoc/0/parser.rbs +56 -0
- data/stdlib/rdoc/0/rdoc.rbs +0 -372
- data/stdlib/rdoc/0/ri.rbs +17 -0
- data/stdlib/rdoc/0/store.rbs +48 -0
- data/stdlib/rdoc/0/top_level.rbs +97 -0
- data/stdlib/socket/0/basic_socket.rbs +1 -1
- data/stdlib/socket/0/socket.rbs +1 -1
- data/stdlib/uri/0/common.rbs +1 -1
- data/stdlib/yaml/0/manifest.yaml +1 -2
- data/stdlib/yaml/0/yaml.rbs +1 -199
- metadata +46 -9
- data/sig/shims/pp.rbs +0 -3
- data/sig/shims.rbs +0 -47
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# <!-- rdoc-file=ext/psych/lib/psych.rb -->
|
|
2
|
+
# # Overview
|
|
3
|
+
#
|
|
4
|
+
# Psych is a YAML parser and emitter. Psych leverages libyaml [Home page:
|
|
5
|
+
# https://pyyaml.org/wiki/LibYAML] or [git repo:
|
|
6
|
+
# https://github.com/yaml/libyaml] for its YAML parsing and emitting
|
|
7
|
+
# capabilities. In addition to wrapping libyaml, Psych also knows how to
|
|
8
|
+
# serialize and de-serialize most Ruby objects to and from the YAML format.
|
|
9
|
+
#
|
|
10
|
+
# # I NEED TO PARSE OR EMIT YAML RIGHT NOW!
|
|
11
|
+
#
|
|
12
|
+
# # Parse some YAML
|
|
13
|
+
# Psych.load("--- foo") # => "foo"
|
|
14
|
+
#
|
|
15
|
+
# # Emit some YAML
|
|
16
|
+
# Psych.dump("foo") # => "--- foo\n...\n"
|
|
17
|
+
# { :a => 'b'}.to_yaml # => "---\n:a: b\n"
|
|
18
|
+
#
|
|
19
|
+
# Got more time on your hands? Keep on reading!
|
|
20
|
+
#
|
|
21
|
+
# ## YAML Parsing
|
|
22
|
+
#
|
|
23
|
+
# Psych provides a range of interfaces for parsing a YAML document ranging from
|
|
24
|
+
# low level to high level, depending on your parsing needs. At the lowest
|
|
25
|
+
# level, is an event based parser. Mid level is access to the raw YAML AST, and
|
|
26
|
+
# at the highest level is the ability to unmarshal YAML to Ruby objects.
|
|
27
|
+
#
|
|
28
|
+
# ## YAML Emitting
|
|
29
|
+
#
|
|
30
|
+
# Psych provides a range of interfaces ranging from low to high level for
|
|
31
|
+
# producing YAML documents. Very similar to the YAML parsing interfaces, Psych
|
|
32
|
+
# provides at the lowest level, an event based system, mid-level is building a
|
|
33
|
+
# YAML AST, and the highest level is converting a Ruby object straight to a YAML
|
|
34
|
+
# document.
|
|
35
|
+
#
|
|
36
|
+
# ## High-level API
|
|
37
|
+
#
|
|
38
|
+
# ### Parsing
|
|
39
|
+
#
|
|
40
|
+
# The high level YAML parser provided by Psych simply takes YAML as input and
|
|
41
|
+
# returns a Ruby data structure. For information on using the high level parser
|
|
42
|
+
# see Psych.load
|
|
43
|
+
#
|
|
44
|
+
# #### Reading from a string
|
|
45
|
+
#
|
|
46
|
+
# Psych.safe_load("--- a") # => 'a'
|
|
47
|
+
# Psych.safe_load("---\n - a\n - b") # => ['a', 'b']
|
|
48
|
+
# # From a trusted string:
|
|
49
|
+
# Psych.load("--- !ruby/range\nbegin: 0\nend: 42\nexcl: false\n") # => 0..42
|
|
50
|
+
#
|
|
51
|
+
# #### Reading from a file
|
|
52
|
+
#
|
|
53
|
+
# Psych.safe_load_file("data.yml", permitted_classes: [Date])
|
|
54
|
+
# Psych.load_file("trusted_database.yml")
|
|
55
|
+
#
|
|
56
|
+
# #### Exception handling
|
|
57
|
+
#
|
|
58
|
+
# begin
|
|
59
|
+
# # The second argument changes only the exception contents
|
|
60
|
+
# Psych.parse("--- `", "file.txt")
|
|
61
|
+
# rescue Psych::SyntaxError => ex
|
|
62
|
+
# ex.file # => 'file.txt'
|
|
63
|
+
# ex.message # => "(file.txt): found character that cannot start any token"
|
|
64
|
+
# end
|
|
65
|
+
#
|
|
66
|
+
# ### Emitting
|
|
67
|
+
#
|
|
68
|
+
# The high level emitter has the easiest interface. Psych simply takes a Ruby
|
|
69
|
+
# data structure and converts it to a YAML document. See Psych.dump for more
|
|
70
|
+
# information on dumping a Ruby data structure.
|
|
71
|
+
#
|
|
72
|
+
# #### Writing to a string
|
|
73
|
+
#
|
|
74
|
+
# # Dump an array, get back a YAML string
|
|
75
|
+
# Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"
|
|
76
|
+
#
|
|
77
|
+
# # Dump an array to an IO object
|
|
78
|
+
# Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
|
|
79
|
+
#
|
|
80
|
+
# # Dump an array with indentation set
|
|
81
|
+
# Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"
|
|
82
|
+
#
|
|
83
|
+
# # Dump an array to an IO with indentation set
|
|
84
|
+
# Psych.dump(['a', ['b']], StringIO.new, :indentation => 3)
|
|
85
|
+
#
|
|
86
|
+
# #### Writing to a file
|
|
87
|
+
#
|
|
88
|
+
# Currently there is no direct API for dumping Ruby structure to file:
|
|
89
|
+
#
|
|
90
|
+
# File.open('database.yml', 'w') do |file|
|
|
91
|
+
# file.write(Psych.dump(['a', 'b']))
|
|
92
|
+
# end
|
|
93
|
+
#
|
|
94
|
+
# ## Mid-level API
|
|
95
|
+
#
|
|
96
|
+
# ### Parsing
|
|
97
|
+
#
|
|
98
|
+
# Psych provides access to an AST produced from parsing a YAML document. This
|
|
99
|
+
# tree is built using the Psych::Parser and Psych::TreeBuilder. The AST can be
|
|
100
|
+
# examined and manipulated freely. Please see Psych::parse_stream,
|
|
101
|
+
# Psych::Nodes, and Psych::Nodes::Node for more information on dealing with YAML
|
|
102
|
+
# syntax trees.
|
|
103
|
+
#
|
|
104
|
+
# #### Reading from a string
|
|
105
|
+
#
|
|
106
|
+
# # Returns Psych::Nodes::Stream
|
|
107
|
+
# Psych.parse_stream("---\n - a\n - b")
|
|
108
|
+
#
|
|
109
|
+
# # Returns Psych::Nodes::Document
|
|
110
|
+
# Psych.parse("---\n - a\n - b")
|
|
111
|
+
#
|
|
112
|
+
# #### Reading from a file
|
|
113
|
+
#
|
|
114
|
+
# # Returns Psych::Nodes::Stream
|
|
115
|
+
# Psych.parse_stream(File.read('database.yml'))
|
|
116
|
+
#
|
|
117
|
+
# # Returns Psych::Nodes::Document
|
|
118
|
+
# Psych.parse_file('database.yml')
|
|
119
|
+
#
|
|
120
|
+
# #### Exception handling
|
|
121
|
+
#
|
|
122
|
+
# begin
|
|
123
|
+
# # The second argument changes only the exception contents
|
|
124
|
+
# Psych.parse("--- `", "file.txt")
|
|
125
|
+
# rescue Psych::SyntaxError => ex
|
|
126
|
+
# ex.file # => 'file.txt'
|
|
127
|
+
# ex.message # => "(file.txt): found character that cannot start any token"
|
|
128
|
+
# end
|
|
129
|
+
#
|
|
130
|
+
# ### Emitting
|
|
131
|
+
#
|
|
132
|
+
# At the mid level is building an AST. This AST is exactly the same as the AST
|
|
133
|
+
# used when parsing a YAML document. Users can build an AST by hand and the AST
|
|
134
|
+
# knows how to emit itself as a YAML document. See Psych::Nodes,
|
|
135
|
+
# Psych::Nodes::Node, and Psych::TreeBuilder for more information on building a
|
|
136
|
+
# YAML AST.
|
|
137
|
+
#
|
|
138
|
+
# #### Writing to a string
|
|
139
|
+
#
|
|
140
|
+
# # We need Psych::Nodes::Stream (not Psych::Nodes::Document)
|
|
141
|
+
# stream = Psych.parse_stream("---\n - a\n - b")
|
|
142
|
+
#
|
|
143
|
+
# stream.to_yaml # => "---\n- a\n- b\n"
|
|
144
|
+
#
|
|
145
|
+
# #### Writing to a file
|
|
146
|
+
#
|
|
147
|
+
# # We need Psych::Nodes::Stream (not Psych::Nodes::Document)
|
|
148
|
+
# stream = Psych.parse_stream(File.read('database.yml'))
|
|
149
|
+
#
|
|
150
|
+
# File.open('database.yml', 'w') do |file|
|
|
151
|
+
# file.write(stream.to_yaml)
|
|
152
|
+
# end
|
|
153
|
+
#
|
|
154
|
+
# ## Low-level API
|
|
155
|
+
#
|
|
156
|
+
# ### Parsing
|
|
157
|
+
#
|
|
158
|
+
# The lowest level parser should be used when the YAML input is already known,
|
|
159
|
+
# and the developer does not want to pay the price of building an AST or
|
|
160
|
+
# automatic detection and conversion to Ruby objects. See Psych::Parser for
|
|
161
|
+
# more information on using the event based parser.
|
|
162
|
+
#
|
|
163
|
+
# #### Reading to Psych::Nodes::Stream structure
|
|
164
|
+
#
|
|
165
|
+
# parser = Psych::Parser.new(TreeBuilder.new) # => #<Psych::Parser>
|
|
166
|
+
# parser = Psych.parser # it's an alias for the above
|
|
167
|
+
#
|
|
168
|
+
# parser.parse("---\n - a\n - b") # => #<Psych::Parser>
|
|
169
|
+
# parser.handler # => #<Psych::TreeBuilder>
|
|
170
|
+
# parser.handler.root # => #<Psych::Nodes::Stream>
|
|
171
|
+
#
|
|
172
|
+
# #### Receiving an events stream
|
|
173
|
+
#
|
|
174
|
+
# recorder = Psych::Handlers::Recorder.new
|
|
175
|
+
# parser = Psych::Parser.new(recorder)
|
|
176
|
+
#
|
|
177
|
+
# parser.parse("---\n - a\n - b")
|
|
178
|
+
# recorder.events # => [list of [event, args] lists]
|
|
179
|
+
# # event is one of: Psych::Handler::EVENTS
|
|
180
|
+
# # args are the arguments passed to the event
|
|
181
|
+
#
|
|
182
|
+
# ### Emitting
|
|
183
|
+
#
|
|
184
|
+
# The lowest level emitter is an event based system. Events are sent to a
|
|
185
|
+
# Psych::Emitter object. That object knows how to convert the events to a YAML
|
|
186
|
+
# document. This interface should be used when document format is known in
|
|
187
|
+
# advance or speed is a concern. See Psych::Emitter for more information.
|
|
188
|
+
#
|
|
189
|
+
# #### Writing to a Ruby structure
|
|
190
|
+
#
|
|
191
|
+
# Psych.parser.parse("--- a") # => #<Psych::Parser>
|
|
192
|
+
#
|
|
193
|
+
# parser.handler.first # => #<Psych::Nodes::Stream>
|
|
194
|
+
# parser.handler.first.to_ruby # => ["a"]
|
|
195
|
+
#
|
|
196
|
+
# parser.handler.root.first # => #<Psych::Nodes::Document>
|
|
197
|
+
# parser.handler.root.first.to_ruby # => "a"
|
|
198
|
+
#
|
|
199
|
+
# # You can instantiate an Emitter manually
|
|
200
|
+
# Psych::Visitors::ToRuby.new.accept(parser.handler.root.first)
|
|
201
|
+
# # => "a"
|
|
202
|
+
#
|
|
203
|
+
module Psych
|
|
204
|
+
# <!--
|
|
205
|
+
# rdoc-file=ext/psych/lib/psych.rb
|
|
206
|
+
# - Psych.dump(o) -> string of yaml
|
|
207
|
+
# - Psych.dump(o, options) -> string of yaml
|
|
208
|
+
# - Psych.dump(o, io) -> io object passed in
|
|
209
|
+
# - Psych.dump(o, io, options) -> io object passed in
|
|
210
|
+
# -->
|
|
211
|
+
# Dump Ruby object `o` to a YAML string. Optional `options` may be passed in to
|
|
212
|
+
# control the output format. If an IO object is passed in, the YAML will be
|
|
213
|
+
# dumped to that IO object.
|
|
214
|
+
#
|
|
215
|
+
# Currently supported options are:
|
|
216
|
+
#
|
|
217
|
+
# `:indentation`
|
|
218
|
+
# : Number of space characters used to indent. Acceptable value should be in
|
|
219
|
+
# `0..9` range, otherwise option is ignored.
|
|
220
|
+
#
|
|
221
|
+
# Default: `2`.
|
|
222
|
+
# `:line_width`
|
|
223
|
+
# : Max character to wrap line at.
|
|
224
|
+
#
|
|
225
|
+
# Default: `0` (meaning "wrap at 81").
|
|
226
|
+
# `:canonical`
|
|
227
|
+
# : Write "canonical" YAML form (very verbose, yet strictly formal).
|
|
228
|
+
#
|
|
229
|
+
# Default: `false`.
|
|
230
|
+
# `:header`
|
|
231
|
+
# : Write `%YAML [version]` at the beginning of document.
|
|
232
|
+
#
|
|
233
|
+
# Default: `false`.
|
|
234
|
+
#
|
|
235
|
+
#
|
|
236
|
+
# Example:
|
|
237
|
+
#
|
|
238
|
+
# # Dump an array, get back a YAML string
|
|
239
|
+
# Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"
|
|
240
|
+
#
|
|
241
|
+
# # Dump an array to an IO object
|
|
242
|
+
# Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
|
|
243
|
+
#
|
|
244
|
+
# # Dump an array with indentation set
|
|
245
|
+
# Psych.dump(['a', ['b']], indentation: 3) # => "---\n- a\n- - b\n"
|
|
246
|
+
#
|
|
247
|
+
# # Dump an array to an IO with indentation set
|
|
248
|
+
# Psych.dump(['a', ['b']], StringIO.new, indentation: 3)
|
|
249
|
+
#
|
|
250
|
+
%a{annotate:rdoc:copy:Psych.dump}
|
|
251
|
+
def self.dump: (untyped o, ?indentation: Integer, ?line_width: Integer, ?canonical: bool, ?header: bool) -> String
|
|
252
|
+
| [IO] (untyped o, IO, ?indentation: Integer, ?line_width: Integer, ?canonical: bool, ?header: bool) -> IO
|
|
253
|
+
|
|
254
|
+
# <!--
|
|
255
|
+
# rdoc-file=ext/psych/lib/psych.rb
|
|
256
|
+
# - load(yaml, permitted_classes: [Symbol], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false)
|
|
257
|
+
# -->
|
|
258
|
+
# Load `yaml` in to a Ruby data structure. If multiple documents are provided,
|
|
259
|
+
# the object contained in the first document will be returned. `filename` will
|
|
260
|
+
# be used in the exception message if any exception is raised while parsing. If
|
|
261
|
+
# `yaml` is empty, it returns the specified `fallback` return value, which
|
|
262
|
+
# defaults to `false`.
|
|
263
|
+
#
|
|
264
|
+
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
|
|
265
|
+
#
|
|
266
|
+
# Example:
|
|
267
|
+
#
|
|
268
|
+
# Psych.load("--- a") # => 'a'
|
|
269
|
+
# Psych.load("---\n - a\n - b") # => ['a', 'b']
|
|
270
|
+
#
|
|
271
|
+
# begin
|
|
272
|
+
# Psych.load("--- `", filename: "file.txt")
|
|
273
|
+
# rescue Psych::SyntaxError => ex
|
|
274
|
+
# ex.file # => 'file.txt'
|
|
275
|
+
# ex.message # => "(file.txt): found character that cannot start any token"
|
|
276
|
+
# end
|
|
277
|
+
#
|
|
278
|
+
# When the optional `symbolize_names` keyword argument is set to a true value,
|
|
279
|
+
# returns symbols for keys in Hash objects (default: strings).
|
|
280
|
+
#
|
|
281
|
+
# Psych.load("---\n foo: bar") # => {"foo"=>"bar"}
|
|
282
|
+
# Psych.load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
|
283
|
+
#
|
|
284
|
+
# Raises a TypeError when `yaml` parameter is NilClass. This method is similar
|
|
285
|
+
# to `safe_load` except that `Symbol` objects are allowed by default.
|
|
286
|
+
#
|
|
287
|
+
%a{annotate:rdoc:copy:Psych.load}
|
|
288
|
+
def self.load: (String yaml, ?filename: String | _ToStr | _ToS?, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool) -> untyped
|
|
289
|
+
|
|
290
|
+
# <!--
|
|
291
|
+
# rdoc-file=ext/psych/lib/psych.rb
|
|
292
|
+
# - load_file(filename, **kwargs)
|
|
293
|
+
# -->
|
|
294
|
+
# Loads the document contained in `filename`. Returns the yaml contained in
|
|
295
|
+
# `filename` as a Ruby object, or if the file is empty, it returns the specified
|
|
296
|
+
# `fallback` return value, which defaults to `false`. See load for options.
|
|
297
|
+
#
|
|
298
|
+
%a{annotate:rdoc:copy:Psych.load_file}
|
|
299
|
+
def self.load_file: (string | _ToPath, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool) -> untyped
|
|
300
|
+
|
|
301
|
+
# <!--
|
|
302
|
+
# rdoc-file=ext/psych/lib/psych.rb
|
|
303
|
+
# - safe_load(yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil, fallback: nil, symbolize_names: false, freeze: false, strict_integer: false)
|
|
304
|
+
# -->
|
|
305
|
+
# Safely load the yaml string in `yaml`. By default, only the following classes
|
|
306
|
+
# are allowed to be deserialized:
|
|
307
|
+
#
|
|
308
|
+
# * TrueClass
|
|
309
|
+
# * FalseClass
|
|
310
|
+
# * NilClass
|
|
311
|
+
# * Integer
|
|
312
|
+
# * Float
|
|
313
|
+
# * String
|
|
314
|
+
# * Array
|
|
315
|
+
# * Hash
|
|
316
|
+
#
|
|
317
|
+
#
|
|
318
|
+
# Recursive data structures are not allowed by default. Arbitrary classes can
|
|
319
|
+
# be allowed by adding those classes to the `permitted_classes` keyword
|
|
320
|
+
# argument. They are additive. For example, to allow Date deserialization:
|
|
321
|
+
#
|
|
322
|
+
# Psych.safe_load(yaml, permitted_classes: [Date])
|
|
323
|
+
#
|
|
324
|
+
# Now the Date class can be loaded in addition to the classes listed above.
|
|
325
|
+
#
|
|
326
|
+
# Aliases can be explicitly allowed by changing the `aliases` keyword argument.
|
|
327
|
+
# For example:
|
|
328
|
+
#
|
|
329
|
+
# x = []
|
|
330
|
+
# x << x
|
|
331
|
+
# yaml = Psych.dump x
|
|
332
|
+
# Psych.safe_load yaml # => raises an exception
|
|
333
|
+
# Psych.safe_load yaml, aliases: true # => loads the aliases
|
|
334
|
+
#
|
|
335
|
+
# A Psych::DisallowedClass exception will be raised if the yaml contains a class
|
|
336
|
+
# that isn't in the `permitted_classes` list.
|
|
337
|
+
#
|
|
338
|
+
# A Psych::AliasesNotEnabled exception will be raised if the yaml contains
|
|
339
|
+
# aliases but the `aliases` keyword argument is set to false.
|
|
340
|
+
#
|
|
341
|
+
# `filename` will be used in the exception message if any exception is raised
|
|
342
|
+
# while parsing.
|
|
343
|
+
#
|
|
344
|
+
# When the optional `symbolize_names` keyword argument is set to a true value,
|
|
345
|
+
# returns symbols for keys in Hash objects (default: strings).
|
|
346
|
+
#
|
|
347
|
+
# Psych.safe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
|
348
|
+
# Psych.safe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
|
349
|
+
#
|
|
350
|
+
%a{annotate:rdoc:copy:Psych.safe_load}
|
|
351
|
+
def self.safe_load: (String yaml, ?permitted_classes: Array[Class], ?permitted_symbols: Array[Symbol], ?aliases: bool, ?filename: String | _ToStr | _ToS?, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool) -> untyped
|
|
352
|
+
|
|
353
|
+
# <!--
|
|
354
|
+
# rdoc-file=ext/psych/lib/psych.rb
|
|
355
|
+
# - unsafe_load(yaml, filename: nil, fallback: false, symbolize_names: false, freeze: false, strict_integer: false)
|
|
356
|
+
# -->
|
|
357
|
+
# Load `yaml` in to a Ruby data structure. If multiple documents are provided,
|
|
358
|
+
# the object contained in the first document will be returned. `filename` will
|
|
359
|
+
# be used in the exception message if any exception is raised while parsing. If
|
|
360
|
+
# `yaml` is empty, it returns the specified `fallback` return value, which
|
|
361
|
+
# defaults to `false`.
|
|
362
|
+
#
|
|
363
|
+
# Raises a Psych::SyntaxError when a YAML syntax error is detected.
|
|
364
|
+
#
|
|
365
|
+
# Example:
|
|
366
|
+
#
|
|
367
|
+
# Psych.unsafe_load("--- a") # => 'a'
|
|
368
|
+
# Psych.unsafe_load("---\n - a\n - b") # => ['a', 'b']
|
|
369
|
+
#
|
|
370
|
+
# begin
|
|
371
|
+
# Psych.unsafe_load("--- `", filename: "file.txt")
|
|
372
|
+
# rescue Psych::SyntaxError => ex
|
|
373
|
+
# ex.file # => 'file.txt'
|
|
374
|
+
# ex.message # => "(file.txt): found character that cannot start any token"
|
|
375
|
+
# end
|
|
376
|
+
#
|
|
377
|
+
# When the optional `symbolize_names` keyword argument is set to a true value,
|
|
378
|
+
# returns symbols for keys in Hash objects (default: strings).
|
|
379
|
+
#
|
|
380
|
+
# Psych.unsafe_load("---\n foo: bar") # => {"foo"=>"bar"}
|
|
381
|
+
# Psych.unsafe_load("---\n foo: bar", symbolize_names: true) # => {:foo=>"bar"}
|
|
382
|
+
#
|
|
383
|
+
# Raises a TypeError when `yaml` parameter is NilClass
|
|
384
|
+
#
|
|
385
|
+
# NOTE: This method *should not* be used to parse untrusted documents, such as
|
|
386
|
+
# YAML documents that are supplied via user input. Instead, please use the load
|
|
387
|
+
# method or the safe_load method.
|
|
388
|
+
#
|
|
389
|
+
%a{annotate:rdoc:copy:Psych.unsafe_load}
|
|
390
|
+
def self.unsafe_load: (String yaml, ?filename: String | _ToStr | _ToS?, ?fallback: untyped, ?symbolize_names: bool, ?freeze: bool, ?strict_integer: bool) -> untyped
|
|
391
|
+
end
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
# greeting:
|
|
31
31
|
# hello: world
|
|
32
32
|
#
|
|
33
|
-
class
|
|
33
|
+
class Psych::Store < ::PStore
|
|
34
34
|
# <!--
|
|
35
35
|
# rdoc-file=lib/yaml/store.rb
|
|
36
36
|
# - initialize( file_name, yaml_opts = {} )
|
|
@@ -45,7 +45,7 @@ class YAML::Store < ::PStore
|
|
|
45
45
|
# Options passed in through `yaml_opts` will be used when converting the store
|
|
46
46
|
# to YAML via Hash#to_yaml().
|
|
47
47
|
#
|
|
48
|
-
def initialize: (*untyped o) ->
|
|
48
|
+
def initialize: (*untyped o) -> Psych::Store
|
|
49
49
|
|
|
50
50
|
def dump: (untyped table) -> String
|
|
51
51
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
%a{annotate:rdoc:skip}
|
|
2
|
+
module RDoc
|
|
3
|
+
# <!-- rdoc-file=lib/rdoc/code_object.rb -->
|
|
4
|
+
# Base class for the RDoc code tree.
|
|
5
|
+
#
|
|
6
|
+
# We contain the common stuff for contexts (which are containers) and other
|
|
7
|
+
# elements (methods, attributes and so on)
|
|
8
|
+
#
|
|
9
|
+
# Here's the tree of the CodeObject subclasses:
|
|
10
|
+
#
|
|
11
|
+
# * RDoc::Context
|
|
12
|
+
# * RDoc::TopLevel
|
|
13
|
+
# * RDoc::ClassModule
|
|
14
|
+
# * RDoc::AnonClass (never used so far)
|
|
15
|
+
# * RDoc::NormalClass
|
|
16
|
+
# * RDoc::NormalModule
|
|
17
|
+
# * RDoc::SingleClass
|
|
18
|
+
#
|
|
19
|
+
#
|
|
20
|
+
# * RDoc::MethodAttr
|
|
21
|
+
# * RDoc::Attr
|
|
22
|
+
# * RDoc::AnyMethod
|
|
23
|
+
# * RDoc::GhostMethod
|
|
24
|
+
# * RDoc::MetaMethod
|
|
25
|
+
#
|
|
26
|
+
#
|
|
27
|
+
# * RDoc::Alias
|
|
28
|
+
# * RDoc::Constant
|
|
29
|
+
# * RDoc::Mixin
|
|
30
|
+
# * RDoc::Require
|
|
31
|
+
# * RDoc::Include
|
|
32
|
+
#
|
|
33
|
+
class CodeObject
|
|
34
|
+
# <!-- rdoc-file=lib/rdoc/code_object.rb -->
|
|
35
|
+
# Our comment
|
|
36
|
+
#
|
|
37
|
+
attr_reader comment: Markup::Document | Comment | String
|
|
38
|
+
|
|
39
|
+
# <!--
|
|
40
|
+
# rdoc-file=lib/rdoc/code_object.rb
|
|
41
|
+
# - new()
|
|
42
|
+
# -->
|
|
43
|
+
# Creates a new CodeObject that will document itself and its children
|
|
44
|
+
#
|
|
45
|
+
def initialize: () -> void
|
|
46
|
+
|
|
47
|
+
# <!--
|
|
48
|
+
# rdoc-file=lib/rdoc/code_object.rb
|
|
49
|
+
# - comment=(comment)
|
|
50
|
+
# -->
|
|
51
|
+
# Replaces our comment with `comment`, unless it is empty.
|
|
52
|
+
#
|
|
53
|
+
def comment=: (Markup::Document | Comment | String | nil) -> (Markup::Document | Comment | String)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
%a{annotate:rdoc:skip}
|
|
2
|
+
module RDoc
|
|
3
|
+
# <!-- rdoc-file=lib/rdoc/comment.rb -->
|
|
4
|
+
# A comment holds the text comment for a RDoc::CodeObject and provides a unified
|
|
5
|
+
# way of cleaning it up and parsing it into an RDoc::Markup::Document.
|
|
6
|
+
#
|
|
7
|
+
# Each comment may have a different markup format set by #format=. By default
|
|
8
|
+
# 'rdoc' is used. The :markup: directive tells RDoc which format to use.
|
|
9
|
+
#
|
|
10
|
+
# See RDoc::Markup@Other+directives for instructions on adding an alternate
|
|
11
|
+
# format.
|
|
12
|
+
#
|
|
13
|
+
class Comment
|
|
14
|
+
# <!-- rdoc-file=lib/rdoc/comment.rb -->
|
|
15
|
+
# The format of this comment. Defaults to RDoc::Markup
|
|
16
|
+
#
|
|
17
|
+
attr_reader format: String
|
|
18
|
+
|
|
19
|
+
# <!-- rdoc-file=lib/rdoc/comment.rb -->
|
|
20
|
+
# The RDoc::TopLevel this comment was found in
|
|
21
|
+
#
|
|
22
|
+
attr_accessor location: String
|
|
23
|
+
|
|
24
|
+
# <!--
|
|
25
|
+
# rdoc-file=lib/rdoc/comment.rb
|
|
26
|
+
# - new(text = nil, location = nil, language = nil)
|
|
27
|
+
# -->
|
|
28
|
+
# Creates a new comment with `text` that is found in the RDoc::TopLevel
|
|
29
|
+
# `location`.
|
|
30
|
+
#
|
|
31
|
+
def initialize: (?String? text, ?RDoc::Context? location, ?String? language) -> void
|
|
32
|
+
|
|
33
|
+
# <!--
|
|
34
|
+
# rdoc-file=lib/rdoc/comment.rb
|
|
35
|
+
# - format=(format)
|
|
36
|
+
# -->
|
|
37
|
+
# Sets the format of this comment and resets any parsed document
|
|
38
|
+
#
|
|
39
|
+
def format=: (String format) -> void
|
|
40
|
+
|
|
41
|
+
def normalized?: () -> bool
|
|
42
|
+
|
|
43
|
+
# <!--
|
|
44
|
+
# rdoc-file=lib/rdoc/comment.rb
|
|
45
|
+
# - normalize()
|
|
46
|
+
# -->
|
|
47
|
+
# Normalizes the text. See RDoc::Text#normalize_comment for details
|
|
48
|
+
#
|
|
49
|
+
def normalize: () -> self
|
|
50
|
+
|
|
51
|
+
# <!--
|
|
52
|
+
# rdoc-file=lib/rdoc/comment.rb
|
|
53
|
+
# - parse()
|
|
54
|
+
# -->
|
|
55
|
+
# Parses the comment into an RDoc::Markup::Document. The parsed document is
|
|
56
|
+
# cached until the text is changed.
|
|
57
|
+
#
|
|
58
|
+
def parse: () -> Markup::Document
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
%a{annotate:rdoc:skip}
|
|
2
|
+
module RDoc
|
|
3
|
+
# <!-- rdoc-file=lib/rdoc/context.rb -->
|
|
4
|
+
# A Context is something that can hold modules, classes, methods, attributes,
|
|
5
|
+
# aliases, requires, and includes. Classes, modules, and files are all Contexts.
|
|
6
|
+
#
|
|
7
|
+
class Context < CodeObject
|
|
8
|
+
include Comparable
|
|
9
|
+
|
|
10
|
+
# <!-- rdoc-file=lib/rdoc/context.rb -->
|
|
11
|
+
# Types of methods
|
|
12
|
+
#
|
|
13
|
+
TYPES: ::Array["class" | "instance"]
|
|
14
|
+
|
|
15
|
+
TOMDOC_TITLES: ::Array[nil | "Public" | "Internal" | "Deprecated"]
|
|
16
|
+
|
|
17
|
+
type class_types = singleton(RDoc::NormalClass) | singleton(RDoc::SingleClass)
|
|
18
|
+
|
|
19
|
+
# <!--
|
|
20
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
21
|
+
# - new()
|
|
22
|
+
# -->
|
|
23
|
+
# Creates an unnamed empty context with public current visibility
|
|
24
|
+
#
|
|
25
|
+
def initialize: () -> void
|
|
26
|
+
|
|
27
|
+
# <!--
|
|
28
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
29
|
+
# - add_alias(an_alias)
|
|
30
|
+
# -->
|
|
31
|
+
# Adds `an_alias` that is automatically resolved
|
|
32
|
+
#
|
|
33
|
+
def add_alias: (RDoc::Alias an_alias) -> RDoc::Alias
|
|
34
|
+
|
|
35
|
+
# <!--
|
|
36
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
37
|
+
# - add_attribute(attribute)
|
|
38
|
+
# -->
|
|
39
|
+
# Adds `attribute` if not already there. If it is (as method(s) or attribute),
|
|
40
|
+
# updates the comment if it was empty.
|
|
41
|
+
#
|
|
42
|
+
# The attribute is registered only if it defines a new method. For instance,
|
|
43
|
+
# `attr_reader :foo` will not be registered if method `foo` exists, but
|
|
44
|
+
# `attr_accessor :foo` will be registered if method `foo` exists, but `foo=`
|
|
45
|
+
# does not.
|
|
46
|
+
#
|
|
47
|
+
def add_attribute: (RDoc::Attr attribute) -> RDoc::Attr
|
|
48
|
+
|
|
49
|
+
# <!--
|
|
50
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
51
|
+
# - add_class(class_type, given_name, superclass = '::Object')
|
|
52
|
+
# -->
|
|
53
|
+
# Adds a class named `given_name` with `superclass`.
|
|
54
|
+
#
|
|
55
|
+
# Both `given_name` and `superclass` may contain '::', and are interpreted
|
|
56
|
+
# relative to the `self` context. This allows handling correctly examples like
|
|
57
|
+
# these:
|
|
58
|
+
# class RDoc::Gauntlet < Gauntlet
|
|
59
|
+
# module Mod
|
|
60
|
+
# class Object # implies < ::Object
|
|
61
|
+
# class SubObject < Object # this is _not_ ::Object
|
|
62
|
+
#
|
|
63
|
+
# Given `class Container::Item` RDoc assumes `Container` is a module unless it
|
|
64
|
+
# later sees `class Container`. `add_class` automatically upgrades `given_name`
|
|
65
|
+
# to a class in this case.
|
|
66
|
+
#
|
|
67
|
+
def add_class: (class_types class_type, ::String given_name, ?::String superclass) -> (RDoc::NormalClass | RDoc::SingleClass)
|
|
68
|
+
|
|
69
|
+
# <!--
|
|
70
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
71
|
+
# - add_constant(constant)
|
|
72
|
+
# -->
|
|
73
|
+
# Adds `constant` if not already there. If it is, updates the comment, value
|
|
74
|
+
# and/or is_alias_for of the known constant if they were empty/nil.
|
|
75
|
+
#
|
|
76
|
+
def add_constant: (RDoc::Constant constant) -> RDoc::Constant
|
|
77
|
+
|
|
78
|
+
# <!--
|
|
79
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
80
|
+
# - add_include(include)
|
|
81
|
+
# -->
|
|
82
|
+
# Adds included module `include` which should be an RDoc::Include
|
|
83
|
+
#
|
|
84
|
+
def add_include: (RDoc::Include `include`) -> RDoc::Include
|
|
85
|
+
|
|
86
|
+
# <!--
|
|
87
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
88
|
+
# - add_extend(ext)
|
|
89
|
+
# -->
|
|
90
|
+
# Adds extension module `ext` which should be an RDoc::Extend
|
|
91
|
+
#
|
|
92
|
+
def add_extend: (RDoc::Extend ext) -> RDoc::Extend
|
|
93
|
+
|
|
94
|
+
# <!--
|
|
95
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
96
|
+
# - add_method(method)
|
|
97
|
+
# -->
|
|
98
|
+
# Adds `method` if not already there. If it is (as method or attribute), updates
|
|
99
|
+
# the comment if it was empty.
|
|
100
|
+
#
|
|
101
|
+
def add_method: (RDoc::AnyMethod method) -> RDoc::AnyMethod
|
|
102
|
+
|
|
103
|
+
# <!--
|
|
104
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
105
|
+
# - add_module(class_type, name)
|
|
106
|
+
# -->
|
|
107
|
+
# Adds a module named `name`. If RDoc already knows `name` is a class then that
|
|
108
|
+
# class is returned instead. See also #add_class.
|
|
109
|
+
#
|
|
110
|
+
def add_module: (singleton(RDoc::NormalModule) class_type, String name) -> RDoc::NormalModule
|
|
111
|
+
|
|
112
|
+
# <!-- rdoc-file=lib/rdoc/context.rb -->
|
|
113
|
+
# All attr* methods
|
|
114
|
+
#
|
|
115
|
+
def attributes: () -> Array[Attr]
|
|
116
|
+
|
|
117
|
+
# <!-- rdoc-file=lib/rdoc/context.rb -->
|
|
118
|
+
# Constants defined
|
|
119
|
+
#
|
|
120
|
+
def constants: () -> Array[Constant]
|
|
121
|
+
|
|
122
|
+
# <!--
|
|
123
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
124
|
+
# - find_module_named(name)
|
|
125
|
+
# -->
|
|
126
|
+
# Find a module with `name` using ruby's scoping rules
|
|
127
|
+
#
|
|
128
|
+
def find_module_named: (untyped name) -> (untyped | self)
|
|
129
|
+
|
|
130
|
+
# <!--
|
|
131
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
132
|
+
# - full_name()
|
|
133
|
+
# -->
|
|
134
|
+
# The full name for this context. This method is overridden by subclasses.
|
|
135
|
+
#
|
|
136
|
+
def full_name: () -> "(unknown)"
|
|
137
|
+
|
|
138
|
+
# <!-- rdoc-file=lib/rdoc/context.rb -->
|
|
139
|
+
# Methods defined in this context
|
|
140
|
+
#
|
|
141
|
+
def method_list: () -> Array[AnyMethod]
|
|
142
|
+
|
|
143
|
+
def to_s: () -> ::String
|
|
144
|
+
|
|
145
|
+
# <!--
|
|
146
|
+
# rdoc-file=lib/rdoc/context.rb
|
|
147
|
+
# - top_level()
|
|
148
|
+
# -->
|
|
149
|
+
# Return the TopLevel that owns us
|
|
150
|
+
#
|
|
151
|
+
def top_level: () -> RDoc::TopLevel
|
|
152
|
+
end
|
|
153
|
+
end
|