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.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +34 -0
  3. data/.github/workflows/ruby.yml +5 -0
  4. data/CHANGELOG.md +82 -0
  5. data/README.md +6 -1
  6. data/Rakefile +56 -21
  7. data/core/array.rbs +2866 -1086
  8. data/core/basic_object.rbs +150 -30
  9. data/core/binding.rbs +33 -0
  10. data/core/builtin.rbs +4 -4
  11. data/core/class.rbs +43 -5
  12. data/core/comparable.rbs +57 -0
  13. data/core/complex.rbs +170 -4
  14. data/core/constants.rbs +51 -0
  15. data/core/deprecated.rbs +7 -0
  16. data/core/dir.rbs +305 -20
  17. data/core/encoding.rbs +1214 -77
  18. data/core/enumerable.rbs +2173 -234
  19. data/core/enumerator.rbs +448 -182
  20. data/core/env.rbs +448 -1
  21. data/core/errno.rbs +1 -10
  22. data/core/errors.rbs +152 -2
  23. data/core/exception.rbs +201 -127
  24. data/core/false_class.rbs +27 -0
  25. data/core/fiber.rbs +118 -37
  26. data/core/fiber_error.rbs +8 -9
  27. data/core/file.rbs +1060 -142
  28. data/core/file_test.rbs +287 -32
  29. data/core/float.rbs +776 -300
  30. data/core/gc.rbs +185 -34
  31. data/core/global_variables.rbs +5 -1
  32. data/core/hash.rbs +1582 -649
  33. data/core/integer.rbs +974 -204
  34. data/core/io/buffer.rbs +710 -0
  35. data/core/io/wait.rbs +29 -8
  36. data/core/io.rbs +2438 -417
  37. data/core/kernel.rbs +2319 -318
  38. data/core/marshal.rbs +37 -2
  39. data/core/match_data.rbs +123 -6
  40. data/core/math.rbs +126 -6
  41. data/core/method.rbs +226 -102
  42. data/core/module.rbs +421 -45
  43. data/core/nil_class.rbs +64 -0
  44. data/core/numeric.rbs +620 -142
  45. data/core/object.rbs +453 -81
  46. data/core/object_space.rbs +92 -2
  47. data/core/proc.rbs +482 -285
  48. data/core/process.rbs +443 -34
  49. data/core/ractor.rbs +232 -9
  50. data/core/random.rbs +151 -52
  51. data/core/range.rbs +885 -160
  52. data/core/rational.rbs +122 -6
  53. data/core/rb_config.rbs +14 -4
  54. data/core/refinement.rbs +44 -0
  55. data/core/regexp.rbs +156 -14
  56. data/core/ruby_vm.rbs +42 -3
  57. data/core/signal.rbs +78 -39
  58. data/core/string.rbs +2123 -567
  59. data/core/string_io.rbs +204 -0
  60. data/core/struct.rbs +283 -28
  61. data/core/symbol.rbs +304 -30
  62. data/core/thread.rbs +1288 -688
  63. data/core/thread_group.rbs +66 -10
  64. data/core/time.rbs +643 -217
  65. data/core/trace_point.rbs +100 -12
  66. data/core/true_class.rbs +24 -0
  67. data/core/unbound_method.rbs +73 -7
  68. data/core/warning.rbs +37 -12
  69. data/docs/CONTRIBUTING.md +40 -34
  70. data/docs/stdlib.md +3 -102
  71. data/docs/syntax.md +54 -11
  72. data/ext/rbs_extension/extconf.rb +1 -0
  73. data/ext/rbs_extension/lexer.h +5 -0
  74. data/ext/rbs_extension/lexstate.c +6 -0
  75. data/ext/rbs_extension/parser.c +85 -10
  76. data/ext/rbs_extension/ruby_objs.c +4 -2
  77. data/ext/rbs_extension/ruby_objs.h +2 -2
  78. data/goodcheck.yml +0 -11
  79. data/lib/rbs/annotate/annotations.rb +197 -0
  80. data/lib/rbs/annotate/formatter.rb +80 -0
  81. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  82. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  83. data/lib/rbs/annotate.rb +6 -0
  84. data/lib/rbs/ast/members.rb +21 -13
  85. data/lib/rbs/buffer.rb +17 -11
  86. data/lib/rbs/cli.rb +48 -1
  87. data/lib/rbs/definition_builder/method_builder.rb +28 -16
  88. data/lib/rbs/definition_builder.rb +6 -2
  89. data/lib/rbs/environment.rb +8 -4
  90. data/lib/rbs/location_aux.rb +12 -0
  91. data/lib/rbs/namespace.rb +1 -1
  92. data/lib/rbs/prototype/rb.rb +12 -0
  93. data/lib/rbs/type_alias_regularity.rb +6 -4
  94. data/lib/rbs/type_name.rb +1 -1
  95. data/lib/rbs/types.rb +1 -1
  96. data/lib/rbs/validator.rb +6 -0
  97. data/lib/rbs/version.rb +1 -1
  98. data/lib/rbs/writer.rb +54 -4
  99. data/lib/rbs.rb +0 -2
  100. data/schema/typeParam.json +3 -3
  101. data/sig/annotate/annotations.rbs +102 -0
  102. data/sig/annotate/formatter.rbs +24 -0
  103. data/sig/annotate/rdoc_annotater.rbs +82 -0
  104. data/sig/annotate/rdoc_source.rbs +30 -0
  105. data/sig/buffer.rbs +6 -2
  106. data/sig/cli.rbs +2 -0
  107. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  108. data/sig/location.rbs +6 -0
  109. data/sig/members.rbs +24 -18
  110. data/sig/method_builder.rbs +5 -4
  111. data/sig/method_types.rbs +5 -1
  112. data/sig/polyfill.rbs +78 -0
  113. data/sig/validator.rbs +3 -1
  114. data/sig/writer.rbs +79 -2
  115. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  116. data/stdlib/abbrev/0/array.rbs +26 -0
  117. data/stdlib/base64/0/base64.rbs +31 -0
  118. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  119. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  120. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  121. data/stdlib/cgi/0/core.rbs +649 -21
  122. data/stdlib/coverage/0/coverage.rbs +164 -2
  123. data/stdlib/csv/0/csv.rbs +2862 -398
  124. data/stdlib/date/0/date.rbs +483 -25
  125. data/stdlib/date/0/date_time.rbs +187 -12
  126. data/stdlib/dbm/0/dbm.rbs +152 -17
  127. data/stdlib/digest/0/digest.rbs +146 -0
  128. data/stdlib/erb/0/erb.rbs +65 -245
  129. data/stdlib/fiber/0/fiber.rbs +73 -91
  130. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  131. data/stdlib/find/0/find.rbs +9 -0
  132. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  133. data/stdlib/io-console/0/io-console.rbs +227 -15
  134. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  135. data/stdlib/json/0/json.rbs +1147 -145
  136. data/stdlib/logger/0/formatter.rbs +24 -0
  137. data/stdlib/logger/0/log_device.rbs +64 -0
  138. data/stdlib/logger/0/logger.rbs +165 -13
  139. data/stdlib/logger/0/period.rbs +10 -0
  140. data/stdlib/logger/0/severity.rbs +26 -0
  141. data/stdlib/monitor/0/monitor.rbs +163 -0
  142. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  143. data/stdlib/net-http/0/manifest.yaml +1 -0
  144. data/stdlib/net-http/0/net-http.rbs +1513 -683
  145. data/stdlib/nkf/0/nkf.rbs +372 -0
  146. data/stdlib/objspace/0/objspace.rbs +149 -90
  147. data/stdlib/openssl/0/openssl.rbs +8108 -71
  148. data/stdlib/optparse/0/optparse.rbs +487 -19
  149. data/stdlib/pathname/0/pathname.rbs +425 -124
  150. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  151. data/stdlib/prime/0/integer-extension.rbs +20 -2
  152. data/stdlib/prime/0/prime.rbs +88 -21
  153. data/stdlib/pstore/0/pstore.rbs +102 -0
  154. data/stdlib/pty/0/pty.rbs +64 -14
  155. data/stdlib/resolv/0/resolv.rbs +420 -31
  156. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  157. data/stdlib/rubygems/0/config_file.rbs +33 -1
  158. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  159. data/stdlib/rubygems/0/installer.rbs +13 -1
  160. data/stdlib/rubygems/0/path_support.rbs +4 -1
  161. data/stdlib/rubygems/0/platform.rbs +5 -1
  162. data/stdlib/rubygems/0/request_set.rbs +44 -2
  163. data/stdlib/rubygems/0/requirement.rbs +65 -2
  164. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  165. data/stdlib/rubygems/0/source_list.rbs +13 -0
  166. data/stdlib/rubygems/0/specification.rbs +21 -1
  167. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  168. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  169. data/stdlib/rubygems/0/version.rbs +60 -157
  170. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  171. data/stdlib/set/0/set.rbs +423 -109
  172. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  173. data/stdlib/singleton/0/singleton.rbs +20 -0
  174. data/stdlib/socket/0/addrinfo.rbs +210 -9
  175. data/stdlib/socket/0/basic_socket.rbs +103 -11
  176. data/stdlib/socket/0/ip_socket.rbs +31 -9
  177. data/stdlib/socket/0/socket.rbs +586 -38
  178. data/stdlib/socket/0/tcp_server.rbs +22 -2
  179. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  180. data/stdlib/socket/0/udp_socket.rbs +25 -2
  181. data/stdlib/socket/0/unix_server.rbs +22 -2
  182. data/stdlib/socket/0/unix_socket.rbs +45 -5
  183. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  184. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  185. data/stdlib/time/0/time.rbs +208 -116
  186. data/stdlib/timeout/0/timeout.rbs +10 -0
  187. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  188. data/stdlib/tsort/0/cyclic.rbs +1 -0
  189. data/stdlib/tsort/0/interfaces.rbs +1 -0
  190. data/stdlib/tsort/0/tsort.rbs +42 -0
  191. data/stdlib/uri/0/common.rbs +57 -8
  192. data/stdlib/uri/0/file.rbs +55 -109
  193. data/stdlib/uri/0/ftp.rbs +6 -3
  194. data/stdlib/uri/0/generic.rbs +558 -329
  195. data/stdlib/uri/0/http.rbs +60 -114
  196. data/stdlib/uri/0/https.rbs +8 -102
  197. data/stdlib/uri/0/ldap.rbs +143 -137
  198. data/stdlib/uri/0/ldaps.rbs +8 -102
  199. data/stdlib/uri/0/mailto.rbs +3 -0
  200. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  201. data/stdlib/uri/0/ws.rbs +6 -3
  202. data/stdlib/uri/0/wss.rbs +5 -3
  203. data/stdlib/yaml/0/dbm.rbs +151 -87
  204. data/stdlib/yaml/0/store.rbs +6 -0
  205. data/stdlib/zlib/0/zlib.rbs +90 -31
  206. metadata +18 -6
  207. data/lib/rbs/location.rb +0 -221
  208. data/sig/char_scanner.rbs +0 -9
data/core/regexp.rbs CHANGED
@@ -1,7 +1,13 @@
1
+ # <!-- rdoc-file=re.c -->
1
2
  # A Regexp holds a regular expression, used to match a pattern against strings.
2
3
  # Regexps are created using the `/.../` and `%r{...}` literals, and by the
3
4
  # Regexp::new constructor.
4
5
  #
6
+ # You can create a Regexp object explicitly with:
7
+ #
8
+ # * A [regexp literal](doc/syntax/literals_rdoc.html#label-Regexp+Literals).
9
+ #
10
+ #
5
11
  # Regular expressions (*regexp*s) are patterns which describe the contents of a
6
12
  # string. They're used for testing whether a string contains a given pattern, or
7
13
  # extracting the portions that match. They are created with the `/`*pat*`/` and
@@ -184,6 +190,8 @@
184
190
  #
185
191
  # "Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/) #=> #<MatchData "Hello">
186
192
  #
193
+ # ### Greedy match
194
+ #
187
195
  # Repetition is *greedy* by default: as many occurrences as possible are matched
188
196
  # while still allowing the overall match to succeed. By contrast, *lazy*
189
197
  # matching makes the minimal amount of matches necessary for overall success.
@@ -199,20 +207,26 @@
199
207
  # /<.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
200
208
  # /<.+?>/.match("<a><b>") #=> #<MatchData "<a>">
201
209
  #
210
+ # ### Possessive match
211
+ #
202
212
  # A quantifier followed by `+` matches *possessively*: once it has matched it
203
213
  # does not backtrack. They behave like greedy quantifiers, but having matched
204
214
  # they refuse to "give up" their match even if this jeopardises the overall
205
215
  # match.
206
216
  #
217
+ # /<.*><.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
218
+ # /<.*+><.+>/.match("<a><b>") #=> nil
219
+ # /<.*><.++>/.match("<a><b>") #=> nil
220
+ #
207
221
  # ## Capturing
208
222
  #
209
- # Parentheses can be used for *capturing*. The text enclosed by the
210
- # *n*<sup>th</sup> group of parentheses can be subsequently referred to with
211
- # *n*. Within a pattern use the *backreference* `\n`; outside of the pattern use
212
- # `MatchData[n]`.
223
+ # Parentheses can be used for *capturing*. The text enclosed by the *n*th group
224
+ # of parentheses can be subsequently referred to with *n*. Within a pattern use
225
+ # the *backreference* `\n` (e.g. `\1`); outside of the pattern use
226
+ # `MatchData[n]` (e.g. `MatchData[1]`).
213
227
  #
214
- # 'at' is captured by the first group of parentheses, then referred to later
215
- # with `\1`:
228
+ # In this example, `'at'` is captured by the first group of parentheses, then
229
+ # referred to later with `\1`:
216
230
  #
217
231
  # /[csh](..) [csh]\1 in/.match("The cat sat in the hat")
218
232
  # #=> #<MatchData "cat sat in" 1:"at">
@@ -222,6 +236,21 @@
222
236
  #
223
237
  # /[csh](..) [csh]\1 in/.match("The cat sat in the hat")[1] #=> 'at'
224
238
  #
239
+ # While Ruby supports an arbitrary number of numbered captured groups, only
240
+ # groups 1-9 are supported using the `\n` backreference syntax.
241
+ #
242
+ # Ruby also supports `\0` as a special backreference, which references the
243
+ # entire matched string. This is also available at `MatchData[0]`. Note that
244
+ # the `\0` backreference cannot be used inside the regexp, as backreferences can
245
+ # only be used after the end of the capture group, and the `\0` backreference
246
+ # uses the implicit capture group of the entire match. However, you can use
247
+ # this backreference when doing substitution:
248
+ #
249
+ # "The cat sat in the hat".gsub(/[csh]at/, '\0s')
250
+ # # => "The cats sats in the hats"
251
+ #
252
+ # ### Named captures
253
+ #
225
254
  # Capture groups can be referred to by name when defined with the
226
255
  # `(?<`*name*`>)` or `(?'`*name*`')` constructs.
227
256
  #
@@ -348,8 +377,8 @@
348
377
  #
349
378
  # ## Alternation
350
379
  #
351
- # The vertical bar metacharacter (`|`) combines two expressions into a single
352
- # one that matches either of the expressions. Each expression is an
380
+ # The vertical bar metacharacter (`|`) combines several expressions into a
381
+ # single one that matches any of the expressions. Each expression is an
353
382
  # *alternative*.
354
383
  #
355
384
  # /\w(and|or)\w/.match("Feliformia") #=> #<MatchData "form" 1:"or">
@@ -494,6 +523,16 @@
494
523
  # * `(?<!`*pat*`)` - *Negative lookbehind* assertion: ensures that the
495
524
  # preceding characters do not match *pat*, but doesn't include those
496
525
  # characters in the matched text
526
+ # * `\K` - Uses an positive lookbehind of the content preceding `\K` in the
527
+ # regexp. For example, the following two regexps are almost equivalent:
528
+ #
529
+ # /ab\Kc/
530
+ # /(?<=ab)c/
531
+ #
532
+ # As are the following two regexps:
533
+ #
534
+ # /(a)\K(b)\Kc/
535
+ # /(?<=(?<=(a))(b))c/
497
536
  #
498
537
  #
499
538
  # If a pattern isn't anchored it can begin at any point in the string:
@@ -700,6 +739,13 @@
700
739
  # Regexp.new('a{0,29}' + 'a' * 29) =~ 'a' * 29
701
740
  #
702
741
  class Regexp
742
+ # <!--
743
+ # rdoc-file=re.c
744
+ # - Regexp.new(string, [options]) -> regexp
745
+ # - Regexp.new(regexp) -> regexp
746
+ # - Regexp.compile(string, [options]) -> regexp
747
+ # - Regexp.compile(regexp) -> regexp
748
+ # -->
703
749
  # Constructs a new regular expression from `pattern`, which can be either a
704
750
  # String or a Regexp (in which case that regexp's options are propagated), and
705
751
  # new options may not be specified (a change as of Ruby 1.8).
@@ -717,11 +763,20 @@ class Regexp
717
763
  def initialize: (String string, ?untyped options, ?String kcode) -> Object
718
764
  | (Regexp regexp) -> void
719
765
 
766
+ # <!--
767
+ # rdoc-file=re.c
768
+ # - compile(*args)
769
+ # -->
720
770
  # Alias for Regexp.new
721
771
  #
722
772
  def self.compile: (String string, ?untyped options, ?String kcode) -> Regexp
723
773
  | (Regexp regexp) -> Regexp
724
774
 
775
+ # <!--
776
+ # rdoc-file=re.c
777
+ # - Regexp.escape(str) -> string
778
+ # - Regexp.quote(str) -> string
779
+ # -->
725
780
  # Escapes any characters that would have special meaning in a regular
726
781
  # expression. Returns a new escaped string with the same or compatible encoding.
727
782
  # For any string, `Regexp.new(Regexp.escape(*str*))=~*str`* will be true.
@@ -730,6 +785,11 @@ class Regexp
730
785
  #
731
786
  def self.escape: (String | Symbol str) -> String
732
787
 
788
+ # <!--
789
+ # rdoc-file=re.c
790
+ # - Regexp.last_match -> matchdata
791
+ # - Regexp.last_match(n) -> str
792
+ # -->
733
793
  # The first form returns the MatchData object generated by the last successful
734
794
  # pattern match. Equivalent to reading the special global variable `$~` (see
735
795
  # Special global variables in Regexp for details).
@@ -755,6 +815,11 @@ class Regexp
755
815
  | (Integer n) -> String?
756
816
  | (Symbol | String n) -> String?
757
817
 
818
+ # <!--
819
+ # rdoc-file=re.c
820
+ # - Regexp.escape(str) -> string
821
+ # - Regexp.quote(str) -> string
822
+ # -->
758
823
  # Escapes any characters that would have special meaning in a regular
759
824
  # expression. Returns a new escaped string with the same or compatible encoding.
760
825
  # For any string, `Regexp.new(Regexp.escape(*str*))=~*str`* will be true.
@@ -763,6 +828,10 @@ class Regexp
763
828
  #
764
829
  def self.quote: (String | Symbol str) -> String
765
830
 
831
+ # <!--
832
+ # rdoc-file=re.c
833
+ # - Regexp.try_convert(obj) -> re or nil
834
+ # -->
766
835
  # Try to convert *obj* into a Regexp, using to_regexp method. Returns converted
767
836
  # regexp or nil if *obj* cannot be converted for any reason.
768
837
  #
@@ -776,6 +845,11 @@ class Regexp
776
845
  #
777
846
  def self.try_convert: (untyped obj) -> Regexp?
778
847
 
848
+ # <!--
849
+ # rdoc-file=re.c
850
+ # - Regexp.union(pat1, pat2, ...) -> new_regexp
851
+ # - Regexp.union(pats_ary) -> new_regexp
852
+ # -->
779
853
  # Return a Regexp object that is the union of the given *pattern*s, i.e., will
780
854
  # match any of its parts. The *pattern*s can be Regexp objects, in which case
781
855
  # their options will be preserved, or Strings. If no patterns are given, returns
@@ -798,6 +872,7 @@ class Regexp
798
872
 
799
873
  public
800
874
 
875
+ # <!-- rdoc-file=re.c -->
801
876
  # Equality---Two regexps are equal if their patterns are identical, they have
802
877
  # the same character set code, and their `casefold?` values are the same.
803
878
  #
@@ -808,6 +883,10 @@ class Regexp
808
883
  #
809
884
  def ==: (untyped other) -> bool
810
885
 
886
+ # <!--
887
+ # rdoc-file=re.c
888
+ # - rxp === str -> true or false
889
+ # -->
811
890
  # Case Equality---Used in case statements.
812
891
  #
813
892
  # a = "HELLO"
@@ -826,6 +905,10 @@ class Regexp
826
905
  #
827
906
  def ===: (untyped other) -> bool
828
907
 
908
+ # <!--
909
+ # rdoc-file=re.c
910
+ # - rxp =~ str -> integer or nil
911
+ # -->
829
912
  # Match---Matches *rxp* against *str*.
830
913
  #
831
914
  # /at/ =~ "input data" #=> 7
@@ -868,6 +951,10 @@ class Regexp
868
951
  #
869
952
  def =~: (String? str) -> Integer?
870
953
 
954
+ # <!--
955
+ # rdoc-file=re.c
956
+ # - rxp.casefold? -> true or false
957
+ # -->
871
958
  # Returns the value of the case-insensitive flag.
872
959
  #
873
960
  # /a/.casefold? #=> false
@@ -876,10 +963,19 @@ class Regexp
876
963
  #
877
964
  def casefold?: () -> bool
878
965
 
966
+ # <!--
967
+ # rdoc-file=re.c
968
+ # - obj.encoding -> encoding
969
+ # -->
879
970
  # Returns the Encoding object that represents the encoding of obj.
880
971
  #
881
972
  def encoding: () -> Encoding
882
973
 
974
+ # <!--
975
+ # rdoc-file=re.c
976
+ # - rxp == other_rxp -> true or false
977
+ # - rxp.eql?(other_rxp) -> true or false
978
+ # -->
883
979
  # Equality---Two regexps are equal if their patterns are identical, they have
884
980
  # the same character set code, and their `casefold?` values are the same.
885
981
  #
@@ -890,6 +986,10 @@ class Regexp
890
986
  #
891
987
  def eql?: (untyped other) -> bool
892
988
 
989
+ # <!--
990
+ # rdoc-file=re.c
991
+ # - rxp.fixed_encoding? -> true or false
992
+ # -->
893
993
  # Returns false if rxp is applicable to a string with any ASCII compatible
894
994
  # encoding. Returns true otherwise.
895
995
  #
@@ -915,12 +1015,20 @@ class Regexp
915
1015
  #
916
1016
  def fixed_encoding?: () -> bool
917
1017
 
1018
+ # <!--
1019
+ # rdoc-file=re.c
1020
+ # - rxp.hash -> integer
1021
+ # -->
918
1022
  # Produce a hash based on the text and options of this regular expression.
919
1023
  #
920
1024
  # See also Object#hash.
921
1025
  #
922
1026
  def hash: () -> Integer
923
1027
 
1028
+ # <!--
1029
+ # rdoc-file=re.c
1030
+ # - rxp.inspect -> string
1031
+ # -->
924
1032
  # Produce a nicely formatted string-version of *rxp*. Perhaps surprisingly,
925
1033
  # `#inspect` actually produces the more natural version of the string than
926
1034
  # `#to_s`.
@@ -929,6 +1037,11 @@ class Regexp
929
1037
  #
930
1038
  def inspect: () -> String
931
1039
 
1040
+ # <!--
1041
+ # rdoc-file=re.c
1042
+ # - rxp.match(str, pos=0) -> matchdata or nil
1043
+ # - rxp.match(str, pos=0) {|match| block } -> obj
1044
+ # -->
932
1045
  # Returns a MatchData object describing the match, or `nil` if there was no
933
1046
  # match. This is equivalent to retrieving the value of the special variable `$~`
934
1047
  # following a normal match. If the second parameter is present, it specifies
@@ -957,7 +1070,12 @@ class Regexp
957
1070
  def match: (String? | Symbol | _ToStr str, ?Integer pos) -> MatchData?
958
1071
  | [T] (String? | Symbol | _ToStr str, ?Integer pos) { (MatchData) -> T } -> T?
959
1072
 
960
- # Returns a `true` or `false` indicates whether the regexp is matched or not
1073
+ # <!--
1074
+ # rdoc-file=re.c
1075
+ # - rxp.match?(str) -> true or false
1076
+ # - rxp.match?(str, pos=0) -> true or false
1077
+ # -->
1078
+ # Returns `true` or `false` to indicate whether the regexp is matched or not
961
1079
  # without updating $~ and other related variables. If the second parameter is
962
1080
  # present, it specifies the position in the string to begin the search.
963
1081
  #
@@ -968,6 +1086,10 @@ class Regexp
968
1086
  #
969
1087
  def match?: (String? | Symbol | _ToStr str, ?Integer pos) -> bool
970
1088
 
1089
+ # <!--
1090
+ # rdoc-file=re.c
1091
+ # - rxp.named_captures -> hash
1092
+ # -->
971
1093
  # Returns a hash representing information about named captures of *rxp*.
972
1094
  #
973
1095
  # A key of the hash is a name of the named captures. A value of the hash is an
@@ -986,6 +1108,10 @@ class Regexp
986
1108
  #
987
1109
  def named_captures: () -> ::Hash[String, ::Array[Integer]]
988
1110
 
1111
+ # <!--
1112
+ # rdoc-file=re.c
1113
+ # - rxp.names -> [name1, name2, ...]
1114
+ # -->
989
1115
  # Returns a list of names of captures as an array of strings.
990
1116
  #
991
1117
  # /(?<foo>.)(?<bar>.)(?<baz>.)/.names
@@ -999,6 +1125,10 @@ class Regexp
999
1125
  #
1000
1126
  def names: () -> ::Array[String]
1001
1127
 
1128
+ # <!--
1129
+ # rdoc-file=re.c
1130
+ # - rxp.options -> integer
1131
+ # -->
1002
1132
  # Returns the set of bits corresponding to the options used when creating this
1003
1133
  # Regexp (see Regexp::new for details. Note that additional bits may be set in
1004
1134
  # the returned options: these are used internally by the regular expression
@@ -1018,6 +1148,10 @@ class Regexp
1018
1148
  #
1019
1149
  def options: () -> Integer
1020
1150
 
1151
+ # <!--
1152
+ # rdoc-file=re.c
1153
+ # - rxp.source -> str
1154
+ # -->
1021
1155
  # Returns the original string of the pattern.
1022
1156
  #
1023
1157
  # /ab+c/ix.source #=> "ab+c"
@@ -1028,6 +1162,10 @@ class Regexp
1028
1162
  #
1029
1163
  def source: () -> String
1030
1164
 
1165
+ # <!--
1166
+ # rdoc-file=re.c
1167
+ # - rxp.to_s -> str
1168
+ # -->
1031
1169
  # Returns a string containing the regular expression and its options (using the
1032
1170
  # `(?opts:source)` notation. This string can be fed back in to Regexp::new to a
1033
1171
  # regular expression with the same semantics as the original. (However,
@@ -1044,6 +1182,10 @@ class Regexp
1044
1182
  #
1045
1183
  def to_s: () -> String
1046
1184
 
1185
+ # <!--
1186
+ # rdoc-file=re.c
1187
+ # - ~ rxp -> integer or nil
1188
+ # -->
1047
1189
  # Match---Matches *rxp* against the contents of `$_`. Equivalent to *`rxp* =~
1048
1190
  # $_`.
1049
1191
  #
@@ -1057,27 +1199,27 @@ class Regexp
1057
1199
  def initialize_copy: (self object) -> self
1058
1200
  end
1059
1201
 
1202
+ # <!-- rdoc-file=re.c -->
1060
1203
  # see Regexp.options and Regexp.new
1061
1204
  #
1062
- #
1063
1205
  Regexp::EXTENDED: Integer
1064
1206
 
1207
+ # <!-- rdoc-file=re.c -->
1065
1208
  # see Regexp.options and Regexp.new
1066
1209
  #
1067
- #
1068
1210
  Regexp::FIXEDENCODING: Integer
1069
1211
 
1212
+ # <!-- rdoc-file=re.c -->
1070
1213
  # see Regexp.options and Regexp.new
1071
1214
  #
1072
- #
1073
1215
  Regexp::IGNORECASE: Integer
1074
1216
 
1217
+ # <!-- rdoc-file=re.c -->
1075
1218
  # see Regexp.options and Regexp.new
1076
1219
  #
1077
- #
1078
1220
  Regexp::MULTILINE: Integer
1079
1221
 
1222
+ # <!-- rdoc-file=re.c -->
1080
1223
  # see Regexp.options and Regexp.new
1081
1224
  #
1082
- #
1083
1225
  Regexp::NOENCODING: Integer
data/core/ruby_vm.rbs CHANGED
@@ -1,14 +1,53 @@
1
- # The [RubyVM](RubyVM) module provides some access to
2
- # Ruby internals. This module is for very limited purposes, such as
3
- # debugging, prototyping, and research. Normal users must not use it.
1
+ # <!-- rdoc-file=vm.c -->
2
+ # The RubyVM module only exists on MRI. `RubyVM` is not defined in other Ruby
3
+ # implementations such as JRuby and TruffleRuby.
4
+ #
5
+ # The RubyVM module provides some access to MRI internals. This module is for
6
+ # very limited purposes, such as debugging, prototyping, and research. Normal
7
+ # users must not use it. This module is not portable between Ruby
8
+ # implementations.
9
+ #
4
10
  class RubyVM < Object
5
11
  end
6
12
 
13
+ # <!-- rdoc-file=vm.c -->
14
+ # DEFAULT_PARAMS This constant exposes the VM's default parameters. Note that
15
+ # changing these values does not affect VM execution. Specification is not
16
+ # stable and you should not depend on this value. Of course, this constant is
17
+ # MRI specific.
18
+ #
7
19
  RubyVM::DEFAULT_PARAMS: Hash[Symbol, Integer]
8
20
 
21
+ # <!-- rdoc-file=vm.c -->
22
+ # INSTRUCTION_NAMES A list of bytecode instruction names in MRI. This constant
23
+ # is MRI specific.
24
+ #
9
25
  RubyVM::INSTRUCTION_NAMES: Array[String]
10
26
 
27
+ # <!-- rdoc-file=vm.c -->
28
+ # OPTS An Array of VM build options. This constant is MRI specific.
29
+ #
11
30
  RubyVM::OPTS: Array[String]
12
31
 
32
+ # <!-- rdoc-file=iseq.c -->
33
+ # The InstructionSequence class represents a compiled sequence of instructions
34
+ # for the Virtual Machine used in MRI. Not all implementations of Ruby may
35
+ # implement this class, and for the implementations that implement it, the
36
+ # methods defined and behavior of the methods can change in any version.
37
+ #
38
+ # With it, you can get a handle to the instructions that make up a method or a
39
+ # proc, compile strings of Ruby code down to VM instructions, and disassemble
40
+ # instruction sequences to strings for easy inspection. It is mostly useful if
41
+ # you want to learn how YARV works, but it also lets you control various
42
+ # settings for the Ruby iseq compiler.
43
+ #
44
+ # You can find the source for the VM instructions in `insns.def` in the Ruby
45
+ # source.
46
+ #
47
+ # The instruction sequence results will almost certainly change as Ruby changes,
48
+ # so example output in this documentation may be different from what you see.
49
+ #
50
+ # Of course, this class is MRI specific.
51
+ #
13
52
  class RubyVM::InstructionSequence < Object
14
53
  end
data/core/signal.rbs CHANGED
@@ -1,55 +1,94 @@
1
- # Many operating systems allow signals to be sent to running processes.
2
- # Some signals have a defined effect on the process, while others may be
3
- # trapped at the code level and acted upon. For example, your process may
4
- # trap the USR1 signal and use it to toggle debugging, and may use TERM to
5
- # initiate a controlled shutdown.
1
+ # <!-- rdoc-file=signal.c -->
2
+ # Many operating systems allow signals to be sent to running processes. Some
3
+ # signals have a defined effect on the process, while others may be trapped at
4
+ # the code level and acted upon. For example, your process may trap the USR1
5
+ # signal and use it to toggle debugging, and may use TERM to initiate a
6
+ # controlled shutdown.
6
7
  #
7
- # ```ruby
8
- # pid = fork do
9
- # Signal.trap("USR1") do
10
- # $debug = !$debug
11
- # puts "Debug now: #$debug"
12
- # end
13
- # Signal.trap("TERM") do
14
- # puts "Terminating..."
15
- # shutdown()
16
- # end
17
- # # . . . do some work . . .
18
- # end
8
+ # pid = fork do
9
+ # Signal.trap("USR1") do
10
+ # $debug = !$debug
11
+ # puts "Debug now: #$debug"
12
+ # end
13
+ # Signal.trap("TERM") do
14
+ # puts "Terminating..."
15
+ # shutdown()
16
+ # end
17
+ # # . . . do some work . . .
18
+ # end
19
19
  #
20
- # Process.detach(pid)
20
+ # Process.detach(pid)
21
21
  #
22
- # # Controlling program:
23
- # Process.kill("USR1", pid)
24
- # # ...
25
- # Process.kill("USR1", pid)
26
- # # ...
27
- # Process.kill("TERM", pid)
28
- # ```
22
+ # # Controlling program:
23
+ # Process.kill("USR1", pid)
24
+ # # ...
25
+ # Process.kill("USR1", pid)
26
+ # # ...
27
+ # Process.kill("TERM", pid)
29
28
  #
30
29
  # produces:
31
- #
32
- # ```
33
- # Debug now: true
34
- # Debug now: false
35
- # Terminating...
36
- # ```
30
+ # Debug now: true
31
+ # Debug now: false
32
+ # Terminating...
37
33
  #
38
34
  # The list of available signal names and their interpretation is system
39
- # dependent. [Signal](Signal) delivery semantics may
40
- # also vary between systems; in particular signal delivery may not always
41
- # be reliable.
35
+ # dependent. Signal delivery semantics may also vary between systems; in
36
+ # particular signal delivery may not always be reliable.
37
+ #
42
38
  module Signal
43
- # Returns a list of signal names mapped to the corresponding underlying
44
- # signal numbers.
39
+ # <!--
40
+ # rdoc-file=signal.c
41
+ # - Signal.list -> a_hash
42
+ # -->
43
+ # Returns a list of signal names mapped to the corresponding underlying signal
44
+ # numbers.
45
+ #
46
+ # Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
45
47
  #
46
- # ```ruby
47
- # Signal.list #=> {"EXIT"=>0, "HUP"=>1, "INT"=>2, "QUIT"=>3, "ILL"=>4, "TRAP"=>5, "IOT"=>6, "ABRT"=>6, "FPE"=>8, "KILL"=>9, "BUS"=>7, "SEGV"=>11, "SYS"=>31, "PIPE"=>13, "ALRM"=>14, "TERM"=>15, "URG"=>23, "STOP"=>19, "TSTP"=>20, "CONT"=>18, "CHLD"=>17, "CLD"=>17, "TTIN"=>21, "TTOU"=>22, "IO"=>29, "XCPU"=>24, "XFSZ"=>25, "VTALRM"=>26, "PROF"=>27, "WINCH"=>28, "USR1"=>10, "USR2"=>12, "PWR"=>30, "POLL"=>29}
48
- # ```
49
48
  def self.list: () -> ::Hash[String, Integer]
50
49
 
50
+ # <!--
51
+ # rdoc-file=signal.c
52
+ # - Signal.signame(signo) -> string or nil
53
+ # -->
54
+ # Convert signal number to signal name. Returns `nil` if the signo is an invalid
55
+ # signal number.
56
+ #
57
+ # Signal.trap("INT") { |signo| puts Signal.signame(signo) }
58
+ # Process.kill("INT", 0)
59
+ #
60
+ # *produces:*
61
+ #
62
+ # INT
63
+ #
51
64
  def self.signame: (Integer arg0) -> String?
52
65
 
66
+ # <!--
67
+ # rdoc-file=signal.c
68
+ # - Signal.trap( signal, command ) -> obj
69
+ # - Signal.trap( signal ) {| | block } -> obj
70
+ # -->
71
+ # Specifies the handling of signals. The first parameter is a signal name (a
72
+ # string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a signal number. The
73
+ # characters ``SIG'' may be omitted from the signal name. The command or block
74
+ # specifies code to be run when the signal is raised. If the command is the
75
+ # string ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the command
76
+ # is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler will be invoked. If
77
+ # the command is ``EXIT'', the script will be terminated by the signal. If the
78
+ # command is ``SYSTEM_DEFAULT'', the operating system's default handler will be
79
+ # invoked. Otherwise, the given command or block will be run. The special signal
80
+ # name ``EXIT'' or signal number zero will be invoked just prior to program
81
+ # termination. trap returns the previous handler for the given signal.
82
+ #
83
+ # Signal.trap(0, proc { puts "Terminating: #{$$}" })
84
+ # Signal.trap("CLD") { puts "Child died" }
85
+ # fork && Process.wait
86
+ #
87
+ # produces:
88
+ # Terminating: 27461
89
+ # Child died
90
+ # Terminating: 27460
91
+ #
53
92
  def self.trap: (Integer | String | Symbol signal, ?untyped command) -> (String | Proc)
54
93
  | (Integer | String | Symbol signal) { (Integer arg0) -> untyped } -> (String | Proc)
55
94
  end