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
@@ -1,6 +1,10 @@
1
+ # <!-- rdoc-file=ext/coverage/coverage.c -->
1
2
  # Coverage provides coverage measurement feature for Ruby. This feature is
2
3
  # experimental, so these APIs may be changed in future.
3
4
  #
5
+ # Caveat: Currently, only process-global coverage measurement is supported. You
6
+ # cannot measure per-thread covearge.
7
+ #
4
8
  # # Usage
5
9
  #
6
10
  # 1. require "coverage"
@@ -12,7 +16,7 @@
12
16
  # disabled for this line (lines like `else` and `end`).
13
17
  #
14
18
  #
15
- # # Example
19
+ # # Examples
16
20
  #
17
21
  # [foo.rb]
18
22
  # s = 0
@@ -32,9 +36,129 @@
32
36
  # require "foo.rb"
33
37
  # p Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
34
38
  #
39
+ # ## Lines Coverage
40
+ #
41
+ # If a coverage mode is not explicitly specified when starting coverage, lines
42
+ # coverage is what will run. It reports the number of line executions for each
43
+ # line.
44
+ #
45
+ # require "coverage"
46
+ # Coverage.start(lines: true)
47
+ # require "foo.rb"
48
+ # p Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}}
49
+ #
50
+ # The value of the lines coverage result is an array containing how many times
51
+ # each line was executed. Order in this array is important. For example, the
52
+ # first item in this array, at index 0, reports how many times line 1 of this
53
+ # file was executed while coverage was run (which, in this example, is one
54
+ # time).
55
+ #
56
+ # A `nil` value means coverage is disabled for this line (lines like `else` and
57
+ # `end`).
58
+ #
59
+ # ## Oneshot Lines Coverage
60
+ #
61
+ # Oneshot lines coverage tracks and reports on the executed lines while coverage
62
+ # is running. It will not report how many times a line was executed, only that
63
+ # it was executed.
64
+ #
65
+ # require "coverage"
66
+ # Coverage.start(oneshot_lines: true)
67
+ # require "foo.rb"
68
+ # p Coverage.result #=> {"foo.rb"=>{:oneshot_lines=>[1, 2, 3, 6, 7]}}
69
+ #
70
+ # The value of the oneshot lines coverage result is an array containing the line
71
+ # numbers that were executed.
72
+ #
73
+ # ## Branches Coverage
74
+ #
75
+ # Branches coverage reports how many times each branch within each conditional
76
+ # was executed.
77
+ #
78
+ # require "coverage"
79
+ # Coverage.start(branches: true)
80
+ # require "foo.rb"
81
+ # p Coverage.result #=> {"foo.rb"=>{:branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}}}
82
+ #
83
+ # Each entry within the branches hash is a conditional, the value of which is
84
+ # another hash where each entry is a branch in that conditional. The values are
85
+ # the number of times the method was executed, and the keys are identifying
86
+ # information about the branch.
87
+ #
88
+ # The information that makes up each key identifying branches or conditionals is
89
+ # the following, from left to right:
90
+ #
91
+ # 1. A label for the type of branch or conditional.
92
+ # 2. A unique identifier.
93
+ # 3. The starting line number it appears on in the file.
94
+ # 4. The starting column number it appears on in the file.
95
+ # 5. The ending line number it appears on in the file.
96
+ # 6. The ending column number it appears on in the file.
97
+ #
98
+ #
99
+ # ## Methods Coverage
100
+ #
101
+ # Methods coverage reports how many times each method was executed.
102
+ #
103
+ # [foo_method.rb]
104
+ # class Greeter
105
+ # def greet
106
+ # "welcome!"
107
+ # end
108
+ # end
109
+ #
110
+ # def hello
111
+ # "Hi"
112
+ # end
113
+ #
114
+ # hello()
115
+ # Greeter.new.greet()
116
+ # [EOF]
117
+ #
118
+ # require "coverage"
119
+ # Coverage.start(methods: true)
120
+ # require "foo_method.rb"
121
+ # p Coverage.result #=> {"foo_method.rb"=>{:methods=>{[Object, :hello, 7, 0, 9, 3]=>1, [Greeter, :greet, 2, 2, 4, 5]=>1}}}
122
+ #
123
+ # Each entry within the methods hash represents a method. The values in this
124
+ # hash are the number of times the method was executed, and the keys are
125
+ # identifying information about the method.
126
+ #
127
+ # The information that makes up each key identifying a method is the following,
128
+ # from left to right:
129
+ #
130
+ # 1. The class.
131
+ # 2. The method name.
132
+ # 3. The starting line number the method appears on in the file.
133
+ # 4. The starting column number the method appears on in the file.
134
+ # 5. The ending line number the method appears on in the file.
135
+ # 6. The ending column number the method appears on in the file.
136
+ #
137
+ #
138
+ # ## All Coverage Modes
139
+ #
140
+ # You can also run all modes of coverage simultaneously with this shortcut. Note
141
+ # that running all coverage modes does not run both lines and oneshot lines.
142
+ # Those modes cannot be run simultaneously. Lines coverage is run in this case,
143
+ # because you can still use it to determine whether or not a line was executed.
144
+ #
145
+ # require "coverage"
146
+ # Coverage.start(:all)
147
+ # require "foo.rb"
148
+ # p Coverage.result #=> {"foo.rb"=>{:lines=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil], :branches=>{[:if, 0, 6, 0, 10, 3]=>{[:then, 1, 7, 2, 7, 7]=>1, [:else, 2, 9, 2, 9, 7]=>0}}, :methods=>{}}}
149
+ #
35
150
  module Coverage
151
+ # <!--
152
+ # rdoc-file=ext/coverage/lib/coverage.rb
153
+ # - line_stub(file)
154
+ # -->
155
+ #
36
156
  def self.line_stub: () -> Array[Integer?]
37
157
 
158
+ # <!--
159
+ # rdoc-file=ext/coverage/coverage.c
160
+ # - Coverage.peek_result => hash
161
+ # -->
38
162
  # Returns a hash that contains filename as key and coverage array as value. This
39
163
  # is the same as `Coverage.result(stop: false, clear: false)`.
40
164
  #
@@ -45,18 +169,56 @@ module Coverage
45
169
  #
46
170
  def self.peek_result: () -> Hash[String, untyped]
47
171
 
172
+ # <!--
173
+ # rdoc-file=ext/coverage/coverage.c
174
+ # - Coverage.result(stop: true, clear: true) => hash
175
+ # -->
48
176
  # Returns a hash that contains filename as key and coverage array as value. If
49
177
  # `clear` is true, it clears the counters to zero. If `stop` is true, it
50
178
  # disables coverage measurement.
51
179
  #
52
180
  def self.result: (?stop: boolish, ?clear: boolish) -> Hash[String, untyped]
53
181
 
182
+ # <!--
183
+ # rdoc-file=ext/coverage/coverage.c
184
+ # - Coverage.running? => bool
185
+ # -->
54
186
  # Returns true if coverage stats are currently being collected (after
55
187
  # Coverage.start call, but before Coverage.result call)
56
188
  #
57
189
  def self.running?: () -> bool
58
190
 
59
- # Enables coverage measurement.
191
+ # <!--
192
+ # rdoc-file=ext/coverage/coverage.c
193
+ # - Coverage.start => nil
194
+ # - Coverage.start(:all) => nil
195
+ # - Coverage.start(lines: bool, branches: bool, methods: bool) => nil
196
+ # - Coverage.start(oneshot_lines: true) => nil
197
+ # -->
198
+ # Enables the coverage measurement. See the documentation of Coverage class in
199
+ # detail. This is equivalent to Coverage.setup and Coverage.resume.
60
200
  #
61
201
  def self.start: (?lines: boolish, ?branches: boolish, ?methods: boolish, ?oneshot_lines: boolish) -> nil
202
+
203
+ # <!--
204
+ # rdoc-file=ext/coverage/coverage.c
205
+ # - Coverage.resume => nil
206
+ # -->
207
+ # Start/resume the coverage measurement.
208
+ #
209
+ # Caveat: Currently, only process-global coverage measurement is supported. You
210
+ # cannot measure per-thread covearge. If your process has multiple thread, using
211
+ # Coverage.resume/suspend to capture code coverage executed from only a limited
212
+ # code block, may yield misleading results.
213
+ #
214
+ def self.resume: () -> nil
215
+
216
+ # <!--
217
+ # rdoc-file=ext/coverage/coverage.c
218
+ # - Coverage.suspend => nil
219
+ # -->
220
+ # Suspend the coverage measurement. You can use Coverage.resume to restart the
221
+ # measurement.
222
+ #
223
+ def self.suspend: () -> nil
62
224
  end