rbs 2.0.0 → 2.2.2
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 +34 -0
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +82 -0
- data/README.md +6 -1
- data/Rakefile +56 -21
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +1214 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1060 -142
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2319 -318
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/docs/syntax.md +54 -11
- data/ext/rbs_extension/extconf.rb +1 -0
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexstate.c +6 -0
- data/ext/rbs_extension/parser.c +85 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/goodcheck.yml +0 -11
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/ast/members.rb +21 -13
- data/lib/rbs/buffer.rb +17 -11
- data/lib/rbs/cli.rb +48 -1
- data/lib/rbs/definition_builder/method_builder.rb +28 -16
- data/lib/rbs/definition_builder.rb +6 -2
- data/lib/rbs/environment.rb +8 -4
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/type_alias_regularity.rb +6 -4
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +1 -1
- data/lib/rbs/validator.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +54 -4
- data/lib/rbs.rb +0 -2
- data/schema/typeParam.json +3 -3
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/buffer.rbs +6 -2
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/members.rbs +24 -18
- data/sig/method_builder.rbs +5 -4
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/sig/validator.rbs +3 -1
- data/sig/writer.rbs +79 -2
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +649 -21
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1147 -145
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/manifest.yaml +1 -0
- data/stdlib/net-http/0/net-http.rbs +1513 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +423 -109
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +558 -329
- data/stdlib/uri/0/http.rbs +60 -114
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +18 -6
- data/lib/rbs/location.rb +0 -221
- data/sig/char_scanner.rbs +0 -9
data/core/trace_point.rbs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=trace_point.rb -->
|
|
1
2
|
# Document-class: TracePoint
|
|
2
3
|
#
|
|
3
4
|
# A class that provides the functionality of Kernel#set_trace_func in a nice
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
# To filter what is traced, you can pass any of the following as `events`:
|
|
31
32
|
#
|
|
32
33
|
# `:line`
|
|
33
|
-
# : execute
|
|
34
|
+
# : execute an expression or statement on a new line
|
|
34
35
|
# `:class`
|
|
35
36
|
# : start a class or module definition
|
|
36
37
|
# `:end`
|
|
@@ -49,6 +50,10 @@
|
|
|
49
50
|
# : event hook at block entry
|
|
50
51
|
# `:b_return`
|
|
51
52
|
# : event hook at block ending
|
|
53
|
+
# `:a_call`
|
|
54
|
+
# : event hook at all calls (`call`, `b_call`, and `c_call`)
|
|
55
|
+
# `:a_return`
|
|
56
|
+
# : event hook at all returns (`return`, `b_return`, and `c_return`)
|
|
52
57
|
# `:thread_begin`
|
|
53
58
|
# : event hook at thread beginning
|
|
54
59
|
# `:thread_end`
|
|
@@ -58,8 +63,11 @@
|
|
|
58
63
|
# `:script_compiled`
|
|
59
64
|
# : new Ruby code compiled (with `eval`, `load` or `require`)
|
|
60
65
|
#
|
|
61
|
-
#
|
|
62
66
|
class TracePoint < Object
|
|
67
|
+
# <!--
|
|
68
|
+
# rdoc-file=trace_point.rb
|
|
69
|
+
# - TracePoint.new(*events) { |obj| block } -> obj
|
|
70
|
+
# -->
|
|
63
71
|
# Returns a new TracePoint object, not enabled by default.
|
|
64
72
|
#
|
|
65
73
|
# Next, in order to activate the trace, you must use TracePoint#enable
|
|
@@ -104,6 +112,24 @@ class TracePoint < Object
|
|
|
104
112
|
#
|
|
105
113
|
def initialize: (*Symbol events) { (TracePoint tp) -> void } -> void
|
|
106
114
|
|
|
115
|
+
# <!--
|
|
116
|
+
# rdoc-file=trace_point.rb
|
|
117
|
+
# - TracePoint.allow_reentry
|
|
118
|
+
# -->
|
|
119
|
+
# In general, while a TracePoint callback is running, other registered callbacks
|
|
120
|
+
# are not called to avoid confusion by reentrance. This method allows the
|
|
121
|
+
# reentrance in a given block. This method should be used carefully, otherwise
|
|
122
|
+
# the callback can be easily called infinitely.
|
|
123
|
+
#
|
|
124
|
+
# If this method is called when the reentrance is already allowed, it raises a
|
|
125
|
+
# RuntimeError.
|
|
126
|
+
#
|
|
127
|
+
def self.allow_reentry: () { () -> void } -> void
|
|
128
|
+
|
|
129
|
+
# <!--
|
|
130
|
+
# rdoc-file=trace_point.rb
|
|
131
|
+
# - TracePoint.stat -> obj
|
|
132
|
+
# -->
|
|
107
133
|
# Returns internal information of TracePoint.
|
|
108
134
|
#
|
|
109
135
|
# The contents of the returned value are implementation specific. It may be
|
|
@@ -113,26 +139,44 @@ class TracePoint < Object
|
|
|
113
139
|
#
|
|
114
140
|
def self.stat: () -> untyped
|
|
115
141
|
|
|
116
|
-
#
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
142
|
+
# <!--
|
|
143
|
+
# rdoc-file=trace_point.rb
|
|
144
|
+
# - TracePoint.trace(*events) { |obj| block } -> obj
|
|
145
|
+
# -->
|
|
146
|
+
# A convenience method for TracePoint.new, that activates the trace
|
|
147
|
+
# automatically.
|
|
120
148
|
#
|
|
121
|
-
#
|
|
122
|
-
#
|
|
149
|
+
# trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
|
|
150
|
+
# #=> #<TracePoint:enabled>
|
|
123
151
|
#
|
|
124
|
-
#
|
|
152
|
+
# trace.enabled? #=> true
|
|
125
153
|
#
|
|
126
154
|
def self.trace: (*Symbol events) { (TracePoint tp) -> void } -> TracePoint
|
|
127
155
|
|
|
128
|
-
#
|
|
156
|
+
# <!--
|
|
157
|
+
# rdoc-file=trace_point.rb
|
|
158
|
+
# - binding()
|
|
159
|
+
# -->
|
|
160
|
+
# Return the generated binding object from event.
|
|
161
|
+
#
|
|
162
|
+
# Note that for `c_call` and `c_return` events, the binding returned is the
|
|
163
|
+
# binding of the nearest Ruby method calling the C method, since C methods
|
|
164
|
+
# themselves do not have bindings.
|
|
129
165
|
#
|
|
130
166
|
def binding: () -> Binding
|
|
131
167
|
|
|
168
|
+
# <!--
|
|
169
|
+
# rdoc-file=trace_point.rb
|
|
170
|
+
# - callee_id()
|
|
171
|
+
# -->
|
|
132
172
|
# Return the called name of the method being called
|
|
133
173
|
#
|
|
134
174
|
def callee_id: () -> Symbol
|
|
135
175
|
|
|
176
|
+
# <!--
|
|
177
|
+
# rdoc-file=trace_point.rb
|
|
178
|
+
# - defined_class()
|
|
179
|
+
# -->
|
|
136
180
|
# Return class or module of the method being called.
|
|
137
181
|
#
|
|
138
182
|
# class C; def foo; end; end
|
|
@@ -168,6 +212,11 @@ class TracePoint < Object
|
|
|
168
212
|
#
|
|
169
213
|
def defined_class: () -> Module
|
|
170
214
|
|
|
215
|
+
# <!--
|
|
216
|
+
# rdoc-file=trace_point.rb
|
|
217
|
+
# - trace.disable -> true or false
|
|
218
|
+
# - trace.disable { block } -> obj
|
|
219
|
+
# -->
|
|
171
220
|
# Deactivates the trace
|
|
172
221
|
#
|
|
173
222
|
# Return true if trace was enabled. Return false if trace was disabled.
|
|
@@ -199,6 +248,11 @@ class TracePoint < Object
|
|
|
199
248
|
def disable: () -> bool
|
|
200
249
|
| () { () -> void } -> void
|
|
201
250
|
|
|
251
|
+
# <!--
|
|
252
|
+
# rdoc-file=trace_point.rb
|
|
253
|
+
# - trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false
|
|
254
|
+
# - trace.enable(target: nil, target_line: nil, target_thread: nil) { block } -> obj
|
|
255
|
+
# -->
|
|
202
256
|
# Activates the trace.
|
|
203
257
|
#
|
|
204
258
|
# Returns `true` if trace was enabled. Returns `false` if trace was disabled.
|
|
@@ -241,7 +295,7 @@ class TracePoint < Object
|
|
|
241
295
|
# t.enable(target: method(:m1))
|
|
242
296
|
#
|
|
243
297
|
# m1
|
|
244
|
-
# # prints #<TracePoint:line
|
|
298
|
+
# # prints #<TracePoint:line test.rb:4 in `m1'>
|
|
245
299
|
# m2
|
|
246
300
|
# # prints nothing
|
|
247
301
|
#
|
|
@@ -253,37 +307,71 @@ class TracePoint < Object
|
|
|
253
307
|
def enable: () -> bool
|
|
254
308
|
| () { () -> void } -> void
|
|
255
309
|
|
|
310
|
+
# <!--
|
|
311
|
+
# rdoc-file=trace_point.rb
|
|
312
|
+
# - trace.enabled? -> true or false
|
|
313
|
+
# -->
|
|
256
314
|
# The current status of the trace
|
|
257
315
|
#
|
|
258
316
|
def enabled?: () -> bool
|
|
259
317
|
|
|
318
|
+
# <!--
|
|
319
|
+
# rdoc-file=trace_point.rb
|
|
320
|
+
# - trace.inspect -> string
|
|
321
|
+
# -->
|
|
260
322
|
# Return a string containing a human-readable TracePoint status.
|
|
261
323
|
#
|
|
262
324
|
def inspect: () -> String
|
|
263
325
|
|
|
326
|
+
# <!--
|
|
327
|
+
# rdoc-file=trace_point.rb
|
|
328
|
+
# - lineno()
|
|
329
|
+
# -->
|
|
264
330
|
# Line number of the event
|
|
265
331
|
#
|
|
266
332
|
def lineno: () -> Integer
|
|
267
333
|
|
|
334
|
+
# <!--
|
|
335
|
+
# rdoc-file=trace_point.rb
|
|
336
|
+
# - method_id()
|
|
337
|
+
# -->
|
|
268
338
|
# Return the name at the definition of the method being called
|
|
269
339
|
#
|
|
270
340
|
def method_id: () -> Symbol
|
|
271
341
|
|
|
342
|
+
# <!--
|
|
343
|
+
# rdoc-file=trace_point.rb
|
|
344
|
+
# - path()
|
|
345
|
+
# -->
|
|
272
346
|
# Path of the file being run
|
|
273
347
|
#
|
|
274
348
|
def path: () -> String
|
|
275
349
|
|
|
350
|
+
# <!--
|
|
351
|
+
# rdoc-file=trace_point.rb
|
|
352
|
+
# - raised_exception()
|
|
353
|
+
# -->
|
|
276
354
|
# Value from exception raised on the `:raise` event
|
|
277
355
|
#
|
|
278
356
|
def raised_exception: () -> untyped
|
|
279
357
|
|
|
358
|
+
# <!--
|
|
359
|
+
# rdoc-file=trace_point.rb
|
|
360
|
+
# - return_value()
|
|
361
|
+
# -->
|
|
280
362
|
# Return value from `:return`, `c_return`, and `b_return` event
|
|
281
363
|
#
|
|
282
364
|
def return_value: () -> untyped
|
|
283
365
|
|
|
366
|
+
# <!--
|
|
367
|
+
# rdoc-file=trace_point.rb
|
|
368
|
+
# - self()
|
|
369
|
+
# -->
|
|
284
370
|
# Return the trace object during event
|
|
285
371
|
#
|
|
286
|
-
# Same as
|
|
372
|
+
# Same as the following, except it returns the correct object (the method
|
|
373
|
+
# receiver) for `c_call` and `c_return` events:
|
|
374
|
+
#
|
|
287
375
|
# trace.binding.eval('self')
|
|
288
376
|
#
|
|
289
377
|
def self: () -> Binding
|
data/core/true_class.rbs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=object.c -->
|
|
1
2
|
# The global value `true` is the only instance of class TrueClass and represents
|
|
2
3
|
# a logically true value in boolean expressions. The class provides operators
|
|
3
4
|
# allowing `true` to be used in logical expressions.
|
|
@@ -7,12 +8,20 @@ class TrueClass
|
|
|
7
8
|
|
|
8
9
|
def !: () -> false
|
|
9
10
|
|
|
11
|
+
# <!--
|
|
12
|
+
# rdoc-file=object.c
|
|
13
|
+
# - true & obj -> true or false
|
|
14
|
+
# -->
|
|
10
15
|
# And---Returns `false` if *obj* is `nil` or `false`, `true` otherwise.
|
|
11
16
|
#
|
|
12
17
|
def &: (nil) -> false
|
|
13
18
|
| (false) -> false
|
|
14
19
|
| (untyped obj) -> true
|
|
15
20
|
|
|
21
|
+
# <!--
|
|
22
|
+
# rdoc-file=object.c
|
|
23
|
+
# - obj === other -> true or false
|
|
24
|
+
# -->
|
|
16
25
|
# Case Equality -- For class Object, effectively the same as calling `#==`, but
|
|
17
26
|
# typically overridden by descendants to provide meaningful semantics in `case`
|
|
18
27
|
# statements.
|
|
@@ -20,18 +29,33 @@ class TrueClass
|
|
|
20
29
|
def ===: (true) -> true
|
|
21
30
|
| (untyped obj) -> bool
|
|
22
31
|
|
|
32
|
+
# <!--
|
|
33
|
+
# rdoc-file=object.c
|
|
34
|
+
# - true ^ obj -> !obj
|
|
35
|
+
# -->
|
|
23
36
|
# Exclusive Or---Returns `true` if *obj* is `nil` or `false`, `false` otherwise.
|
|
24
37
|
#
|
|
25
38
|
def ^: (nil) -> true
|
|
26
39
|
| (false) -> true
|
|
27
40
|
| (untyped obj) -> false
|
|
28
41
|
|
|
42
|
+
# <!-- rdoc-file=object.c -->
|
|
43
|
+
# The string representation of `true` is "true".
|
|
44
|
+
#
|
|
29
45
|
alias inspect to_s
|
|
30
46
|
|
|
47
|
+
# <!--
|
|
48
|
+
# rdoc-file=object.c
|
|
49
|
+
# - true.to_s -> "true"
|
|
50
|
+
# -->
|
|
31
51
|
# The string representation of `true` is "true".
|
|
32
52
|
#
|
|
33
53
|
def to_s: () -> "true"
|
|
34
54
|
|
|
55
|
+
# <!--
|
|
56
|
+
# rdoc-file=object.c
|
|
57
|
+
# - true | obj -> true
|
|
58
|
+
# -->
|
|
35
59
|
# Or---Returns `true`. As *obj* is an argument to a method call, it is always
|
|
36
60
|
# evaluated; there is no short-circuit evaluation in this case.
|
|
37
61
|
#
|
data/core/unbound_method.rbs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# <!-- rdoc-file=proc.c -->
|
|
1
2
|
# Ruby supports two forms of objectified methods. Class Method is used to
|
|
2
3
|
# represent methods that are associated with a particular object: these method
|
|
3
4
|
# objects are bound to that object. Bound method objects for an object can be
|
|
@@ -45,19 +46,28 @@
|
|
|
45
46
|
# um.bind(t).call #=> :original
|
|
46
47
|
#
|
|
47
48
|
class UnboundMethod
|
|
49
|
+
# <!--
|
|
50
|
+
# rdoc-file=proc.c
|
|
51
|
+
# - method.clone -> new_method
|
|
52
|
+
# -->
|
|
48
53
|
# Returns a clone of this method.
|
|
49
54
|
#
|
|
50
|
-
#
|
|
51
|
-
#
|
|
52
|
-
#
|
|
55
|
+
# class A
|
|
56
|
+
# def foo
|
|
57
|
+
# return "bar"
|
|
58
|
+
# end
|
|
53
59
|
# end
|
|
54
|
-
# end
|
|
55
60
|
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
61
|
+
# m = A.new.method(:foo)
|
|
62
|
+
# m.call # => "bar"
|
|
63
|
+
# n = m.clone.call # => "bar"
|
|
64
|
+
#
|
|
59
65
|
def clone: () -> self
|
|
60
66
|
|
|
67
|
+
# <!--
|
|
68
|
+
# rdoc-file=proc.c
|
|
69
|
+
# - meth.arity -> integer
|
|
70
|
+
# -->
|
|
61
71
|
# Returns an indication of the number of arguments accepted by a method. Returns
|
|
62
72
|
# a nonnegative integer for methods that take a fixed number of arguments. For
|
|
63
73
|
# Ruby methods that take a variable number of arguments, returns -n-1, where n
|
|
@@ -97,6 +107,10 @@ class UnboundMethod
|
|
|
97
107
|
#
|
|
98
108
|
def arity: () -> Integer
|
|
99
109
|
|
|
110
|
+
# <!--
|
|
111
|
+
# rdoc-file=proc.c
|
|
112
|
+
# - umeth.bind(obj) -> method
|
|
113
|
+
# -->
|
|
100
114
|
# Bind *umeth* to *obj*. If Klass was the class from which *umeth* was obtained,
|
|
101
115
|
# `obj.kind_of?(Klass)` must be true.
|
|
102
116
|
#
|
|
@@ -127,16 +141,28 @@ class UnboundMethod
|
|
|
127
141
|
#
|
|
128
142
|
def bind: (untyped obj) -> Method
|
|
129
143
|
|
|
144
|
+
# <!--
|
|
145
|
+
# rdoc-file=proc.c
|
|
146
|
+
# - meth.name -> symbol
|
|
147
|
+
# -->
|
|
130
148
|
# Returns the name of the method.
|
|
131
149
|
#
|
|
132
150
|
def name: () -> Symbol
|
|
133
151
|
|
|
152
|
+
# <!--
|
|
153
|
+
# rdoc-file=proc.c
|
|
154
|
+
# - meth.owner -> class_or_module
|
|
155
|
+
# -->
|
|
134
156
|
# Returns the class or module that defines the method. See also Method#receiver.
|
|
135
157
|
#
|
|
136
158
|
# (1..3).method(:map).owner #=> Enumerable
|
|
137
159
|
#
|
|
138
160
|
def owner: () -> Module
|
|
139
161
|
|
|
162
|
+
# <!--
|
|
163
|
+
# rdoc-file=proc.c
|
|
164
|
+
# - meth.parameters -> array
|
|
165
|
+
# -->
|
|
140
166
|
# Returns the parameter information of this method.
|
|
141
167
|
#
|
|
142
168
|
# def foo(bar); end
|
|
@@ -154,16 +180,52 @@ class UnboundMethod
|
|
|
154
180
|
def parameters: () -> ::Array[[ Symbol, Symbol ]]
|
|
155
181
|
| () -> ::Array[[ Symbol ]]
|
|
156
182
|
|
|
183
|
+
# <!--
|
|
184
|
+
# rdoc-file=proc.c
|
|
185
|
+
# - meth.private? -> true or false
|
|
186
|
+
# -->
|
|
187
|
+
# Returns whether the method is private.
|
|
188
|
+
#
|
|
189
|
+
def private?: () -> bool
|
|
190
|
+
|
|
191
|
+
# <!--
|
|
192
|
+
# rdoc-file=proc.c
|
|
193
|
+
# - meth.protected? -> true or false
|
|
194
|
+
# -->
|
|
195
|
+
# Returns whether the method is protected.
|
|
196
|
+
#
|
|
197
|
+
def protected?: () -> bool
|
|
198
|
+
|
|
199
|
+
# <!--
|
|
200
|
+
# rdoc-file=proc.c
|
|
201
|
+
# - meth.public? -> true or false
|
|
202
|
+
# -->
|
|
203
|
+
# Returns whether the method is public.
|
|
204
|
+
#
|
|
205
|
+
def public?: () -> bool
|
|
206
|
+
|
|
207
|
+
# <!--
|
|
208
|
+
# rdoc-file=proc.c
|
|
209
|
+
# - meth.source_location -> [String, Integer]
|
|
210
|
+
# -->
|
|
157
211
|
# Returns the Ruby source filename and line number containing this method or nil
|
|
158
212
|
# if this method was not defined in Ruby (i.e. native).
|
|
159
213
|
#
|
|
160
214
|
def source_location: () -> [ String, Integer ]?
|
|
161
215
|
|
|
216
|
+
# <!--
|
|
217
|
+
# rdoc-file=proc.c
|
|
218
|
+
# - meth.super_method -> method
|
|
219
|
+
# -->
|
|
162
220
|
# Returns a Method of superclass which would be called when super is used or nil
|
|
163
221
|
# if there is no method on superclass.
|
|
164
222
|
#
|
|
165
223
|
def super_method: () -> UnboundMethod?
|
|
166
224
|
|
|
225
|
+
# <!--
|
|
226
|
+
# rdoc-file=proc.c
|
|
227
|
+
# - meth.original_name -> symbol
|
|
228
|
+
# -->
|
|
167
229
|
# Returns the original name of the method.
|
|
168
230
|
#
|
|
169
231
|
# class C
|
|
@@ -174,6 +236,10 @@ class UnboundMethod
|
|
|
174
236
|
#
|
|
175
237
|
def original_name: () -> Symbol
|
|
176
238
|
|
|
239
|
+
# <!--
|
|
240
|
+
# rdoc-file=proc.c
|
|
241
|
+
# - umeth.bind_call(recv, args, ...) -> obj
|
|
242
|
+
# -->
|
|
177
243
|
# Bind *umeth* to *recv* and then invokes the method with the specified
|
|
178
244
|
# arguments. This is semantically equivalent to `umeth.bind(recv).call(args,
|
|
179
245
|
# ...)`.
|
data/core/warning.rbs
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
#
|
|
2
|
-
# method named
|
|
3
|
-
#
|
|
4
|
-
# [\#warn](Warning#method-i-warn) is called for all
|
|
1
|
+
# <!-- rdoc-file=error.c -->
|
|
2
|
+
# The Warning module contains a single method named #warn, and the module
|
|
3
|
+
# extends itself, making Warning.warn available. Warning.warn is called for all
|
|
5
4
|
# warnings issued by Ruby. By default, warnings are printed to $stderr.
|
|
6
5
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# warnings
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
6
|
+
# Changing the behavior of Warning.warn is useful to customize how warnings are
|
|
7
|
+
# handled by Ruby, for instance by filtering some warnings, and/or outputting
|
|
8
|
+
# warnings somewhere other than $stderr.
|
|
9
|
+
#
|
|
10
|
+
# If you want to change the behavior of Warning.warn you should use
|
|
11
|
+
# +Warning.extend(MyNewModuleWithWarnMethod)+ and you can use `super` to get the
|
|
12
|
+
# default behavior of printing the warning to $stderr.
|
|
13
|
+
#
|
|
14
|
+
# Example:
|
|
15
|
+
# module MyWarningFilter
|
|
16
|
+
# def warn(message, category: nil, **kwargs)
|
|
17
|
+
# if /some warning I want to ignore/.match?(message)
|
|
18
|
+
# # ignore
|
|
19
|
+
# else
|
|
20
|
+
# super
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
# end
|
|
24
|
+
# Warning.extend MyWarningFilter
|
|
25
|
+
#
|
|
26
|
+
# You should never redefine Warning#warn (the instance method), as that will
|
|
27
|
+
# then no longer provide a way to use the default behavior.
|
|
28
|
+
#
|
|
29
|
+
# The `warning` gem provides convenient ways to customize Warning.warn.
|
|
30
|
+
#
|
|
13
31
|
module Warning
|
|
14
|
-
#
|
|
15
|
-
#
|
|
32
|
+
# <!--
|
|
33
|
+
# rdoc-file=error.c
|
|
34
|
+
# - warn(msg, category: nil) -> nil
|
|
35
|
+
# -->
|
|
36
|
+
# Writes warning message `msg` to $stderr. This method is called by Ruby for all
|
|
37
|
+
# emitted warnings. A `category` may be included with the warning.
|
|
38
|
+
#
|
|
39
|
+
# See the documentation of the Warning module for how to customize this.
|
|
40
|
+
#
|
|
16
41
|
def warn: (String) -> nil
|
|
17
42
|
end
|
data/docs/CONTRIBUTING.md
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
1
|
-
# Standard Library Signatures Contribution Guide
|
|
1
|
+
# Core and Standard Library Signatures Contribution Guide
|
|
2
2
|
|
|
3
3
|
## Guides
|
|
4
4
|
|
|
5
|
-
* [
|
|
6
|
-
* [Syntax](syntax.md)
|
|
5
|
+
* [RBS by Example](rbs_by_example.md)
|
|
7
6
|
* [Writing Signature Guide](sigs.md)
|
|
7
|
+
* [Testing Core API and Standard Library Types](stdlib.md)
|
|
8
|
+
* [Syntax](syntax.md)
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
+
## Introduction
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- Committing the sorted RBSs is recommended.
|
|
16
|
-
4. Add method prototypes.
|
|
17
|
-
- Use `rbs prototype runtime --merge CLASS_NAME` command to generate the missing method definitions.
|
|
18
|
-
- Committing the auto generated signatures is recommended.
|
|
19
|
-
5. Annotate with RDoc.
|
|
20
|
-
- You'll need RDoc installed. Rvm users should use `rvm docs generate` first.
|
|
21
|
-
- Use `bin/annotate-with-rdoc stdlib/path/to/signature.rbs` to annotate the RBS files.
|
|
22
|
-
- Committing the generated annotations is recommended.
|
|
23
|
-
6. Fix method types and comments.
|
|
24
|
-
- The auto generated RDoc comments include `arglists` section, which we don't expect to be included the RBS files.
|
|
25
|
-
- Delete the `arglists` sections.
|
|
26
|
-
- Give methods correct types.
|
|
27
|
-
- Write tests, if possible. (If it is too difficult to write test, skip it.)
|
|
12
|
+
The RBS repository contains the type definitions of Core API and Standard Libraries.
|
|
13
|
+
There are some discussions whether if it is the best to have them in this repository, but we have them and continue updating the files meanwhile.
|
|
14
|
+
|
|
15
|
+
The target version of the bundled type definitions is the latest _release_ of Ruby -- `3.1` as of January 2022.
|
|
28
16
|
|
|
29
|
-
|
|
17
|
+
**The core API** type definitions are in `core` directory.
|
|
18
|
+
You will find the familiar class names in the directory, like `string.rbs` or `array.rbs`.
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
**The standard libraries** type definitions are in `stdlib` directory.
|
|
21
|
+
They have the [third party repository](repo.md) structure.
|
|
22
|
+
There is a `set` directory for the `set` library, and it contains `0` directory.
|
|
23
|
+
Because RBS supports the latest release of Ruby, we have one set of RBS files which corresponds to the bundled versions of the libraries.
|
|
33
24
|
|
|
34
|
-
##
|
|
25
|
+
## Steps for Contribution
|
|
35
26
|
|
|
36
|
-
|
|
27
|
+
1. Pick the class/library you will work for.
|
|
28
|
+
2. Make a directory `stdlib/foo/0` if you work for one of the standard libraries.
|
|
29
|
+
3. Write RBS type definitions and tests.
|
|
37
30
|
|
|
38
|
-
|
|
31
|
+
You will typically follow the steps as follows:
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
1. Run `rbs prototype runtime` to generate list of methods.
|
|
34
|
+
2. Run `rbs annotate` to import RDoc comments.
|
|
35
|
+
3. Run `rbs generate:stdlib_test[LIB]` to generate a test case.
|
|
36
|
+
4. Write the type definitions and tests.
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
See the next *Useful Tools* section and the guides above for writing and testing RBS files.
|
|
44
39
|
|
|
45
40
|
## Useful Tools
|
|
46
41
|
|
|
@@ -49,9 +44,9 @@ You may find the *Good for first contributor* column where you can find some cla
|
|
|
49
44
|
* `--merge` tells to use the method types in RBS if exists.
|
|
50
45
|
* `rbs prototype runtime --merge --method-owner=Numeric Integer`
|
|
51
46
|
* You can use --method-owner if you want to print method of other classes too, for documentation purpose.
|
|
52
|
-
* `
|
|
53
|
-
*
|
|
54
|
-
*
|
|
47
|
+
* `rbs annotate core/string.rbs`
|
|
48
|
+
* Import RDoc comments.
|
|
49
|
+
* The imported docs contain the description, *arglists*, and filenames to help writing types.
|
|
55
50
|
* `bin/query-rdoc String#initialize`
|
|
56
51
|
* Print RDoc documents in the format you can copy-and-paste to RBS.
|
|
57
52
|
* `bin/sort core/string.rbs`
|
|
@@ -63,7 +58,7 @@ You may find the *Good for first contributor* column where you can find some cla
|
|
|
63
58
|
* `rake test/stdlib/Array_test.rb`
|
|
64
59
|
Run specific stdlib test with the path.
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
### Standard STDLIB Members Order
|
|
67
62
|
|
|
68
63
|
We define the standard members order so that ordering doesn't bother reading diffs or git-annotate outputs.
|
|
69
64
|
|
|
@@ -98,3 +93,14 @@ class HelloWorld[X]
|
|
|
98
93
|
def validate_locale: () -> void
|
|
99
94
|
end
|
|
100
95
|
```
|
|
96
|
+
|
|
97
|
+
## Q&A
|
|
98
|
+
|
|
99
|
+
### Some of the standard libraries are gems. Why we put the files in this repo?
|
|
100
|
+
|
|
101
|
+
You are correct. We want to move to their repos. We haven't started the migration yet.
|
|
102
|
+
|
|
103
|
+
### How can we handle incompatibilities of core APIs and standard libraries between Rubies
|
|
104
|
+
|
|
105
|
+
We ignore the incompatibilities for now.
|
|
106
|
+
We focus on the latest version of core APIs and standard libraries.
|