rbs 4.0.0.dev.4 → 4.0.0

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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -14
  3. data/.github/workflows/bundle-update.yml +60 -0
  4. data/.github/workflows/c-check.yml +18 -11
  5. data/.github/workflows/comments.yml +5 -3
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +27 -34
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +2 -2
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +1 -1
  12. data/CHANGELOG.md +323 -0
  13. data/README.md +1 -1
  14. data/Rakefile +43 -33
  15. data/Steepfile +1 -0
  16. data/config.yml +426 -24
  17. data/core/array.rbs +307 -227
  18. data/core/basic_object.rbs +9 -8
  19. data/core/binding.rbs +0 -2
  20. data/core/builtin.rbs +2 -2
  21. data/core/class.rbs +6 -5
  22. data/core/comparable.rbs +55 -34
  23. data/core/complex.rbs +104 -78
  24. data/core/dir.rbs +61 -49
  25. data/core/encoding.rbs +12 -15
  26. data/core/enumerable.rbs +179 -87
  27. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  28. data/core/enumerator.rbs +65 -2
  29. data/core/errno.rbs +11 -2
  30. data/core/errors.rbs +58 -29
  31. data/core/exception.rbs +13 -13
  32. data/core/fiber.rbs +74 -54
  33. data/core/file.rbs +280 -177
  34. data/core/file_test.rbs +3 -3
  35. data/core/float.rbs +257 -92
  36. data/core/gc.rbs +425 -281
  37. data/core/hash.rbs +1045 -739
  38. data/core/integer.rbs +135 -137
  39. data/core/io/buffer.rbs +53 -42
  40. data/core/io/wait.rbs +13 -35
  41. data/core/io.rbs +192 -144
  42. data/core/kernel.rbs +216 -155
  43. data/core/marshal.rbs +4 -4
  44. data/core/match_data.rbs +15 -13
  45. data/core/math.rbs +107 -66
  46. data/core/method.rbs +69 -33
  47. data/core/module.rbs +244 -106
  48. data/core/nil_class.rbs +7 -6
  49. data/core/numeric.rbs +74 -63
  50. data/core/object.rbs +9 -11
  51. data/core/object_space.rbs +30 -23
  52. data/core/pathname.rbs +1322 -0
  53. data/core/proc.rbs +95 -58
  54. data/core/process.rbs +222 -202
  55. data/core/ractor.rbs +371 -515
  56. data/core/random.rbs +21 -3
  57. data/core/range.rbs +159 -57
  58. data/core/rational.rbs +60 -89
  59. data/core/rbs/unnamed/argf.rbs +60 -53
  60. data/core/rbs/unnamed/env_class.rbs +19 -14
  61. data/core/rbs/unnamed/main_class.rbs +123 -0
  62. data/core/rbs/unnamed/random.rbs +11 -118
  63. data/core/regexp.rbs +258 -214
  64. data/core/ruby.rbs +53 -0
  65. data/core/ruby_vm.rbs +38 -34
  66. data/core/rubygems/config_file.rbs +5 -5
  67. data/core/rubygems/errors.rbs +4 -71
  68. data/core/rubygems/requirement.rbs +5 -5
  69. data/core/rubygems/rubygems.rbs +16 -82
  70. data/core/rubygems/version.rbs +2 -3
  71. data/core/set.rbs +490 -360
  72. data/core/signal.rbs +26 -16
  73. data/core/string.rbs +3234 -1285
  74. data/core/struct.rbs +27 -26
  75. data/core/symbol.rbs +41 -34
  76. data/core/thread.rbs +135 -67
  77. data/core/time.rbs +81 -50
  78. data/core/trace_point.rbs +41 -35
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +24 -16
  81. data/core/warning.rbs +7 -7
  82. data/docs/aliases.md +79 -0
  83. data/docs/collection.md +3 -3
  84. data/docs/config.md +171 -0
  85. data/docs/encoding.md +56 -0
  86. data/docs/gem.md +0 -1
  87. data/docs/inline.md +576 -0
  88. data/docs/sigs.md +3 -3
  89. data/docs/syntax.md +46 -16
  90. data/docs/type_fingerprint.md +21 -0
  91. data/exe/rbs +1 -1
  92. data/ext/rbs_extension/ast_translation.c +544 -116
  93. data/ext/rbs_extension/ast_translation.h +3 -0
  94. data/ext/rbs_extension/class_constants.c +16 -2
  95. data/ext/rbs_extension/class_constants.h +8 -0
  96. data/ext/rbs_extension/extconf.rb +5 -1
  97. data/ext/rbs_extension/legacy_location.c +33 -56
  98. data/ext/rbs_extension/legacy_location.h +37 -0
  99. data/ext/rbs_extension/main.c +44 -35
  100. data/include/rbs/ast.h +448 -173
  101. data/include/rbs/defines.h +27 -0
  102. data/include/rbs/lexer.h +30 -11
  103. data/include/rbs/location.h +25 -44
  104. data/include/rbs/parser.h +6 -6
  105. data/include/rbs/string.h +0 -2
  106. data/include/rbs/util/rbs_allocator.h +34 -13
  107. data/include/rbs/util/rbs_assert.h +12 -1
  108. data/include/rbs/util/rbs_constant_pool.h +0 -3
  109. data/include/rbs/util/rbs_encoding.h +2 -0
  110. data/include/rbs/util/rbs_unescape.h +2 -1
  111. data/include/rbs.h +8 -0
  112. data/lib/rbs/ast/annotation.rb +1 -1
  113. data/lib/rbs/ast/comment.rb +1 -1
  114. data/lib/rbs/ast/declarations.rb +10 -10
  115. data/lib/rbs/ast/members.rb +14 -14
  116. data/lib/rbs/ast/ruby/annotations.rb +293 -3
  117. data/lib/rbs/ast/ruby/comment_block.rb +24 -0
  118. data/lib/rbs/ast/ruby/declarations.rb +198 -3
  119. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
  120. data/lib/rbs/ast/ruby/members.rb +532 -22
  121. data/lib/rbs/ast/type_param.rb +24 -4
  122. data/lib/rbs/buffer.rb +20 -15
  123. data/lib/rbs/cli/diff.rb +16 -15
  124. data/lib/rbs/cli/validate.rb +38 -106
  125. data/lib/rbs/cli.rb +52 -19
  126. data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
  127. data/lib/rbs/collection/sources/git.rb +1 -0
  128. data/lib/rbs/definition.rb +1 -1
  129. data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
  130. data/lib/rbs/definition_builder/method_builder.rb +20 -0
  131. data/lib/rbs/definition_builder.rb +147 -25
  132. data/lib/rbs/diff.rb +7 -1
  133. data/lib/rbs/environment.rb +227 -74
  134. data/lib/rbs/environment_loader.rb +0 -6
  135. data/lib/rbs/errors.rb +27 -18
  136. data/lib/rbs/inline_parser.rb +342 -6
  137. data/lib/rbs/location_aux.rb +1 -1
  138. data/lib/rbs/locator.rb +5 -1
  139. data/lib/rbs/method_type.rb +5 -3
  140. data/lib/rbs/parser_aux.rb +20 -7
  141. data/lib/rbs/prototype/helpers.rb +57 -0
  142. data/lib/rbs/prototype/rb.rb +3 -28
  143. data/lib/rbs/prototype/rbi.rb +3 -20
  144. data/lib/rbs/prototype/runtime.rb +8 -0
  145. data/lib/rbs/resolver/constant_resolver.rb +2 -2
  146. data/lib/rbs/resolver/type_name_resolver.rb +116 -38
  147. data/lib/rbs/subtractor.rb +3 -1
  148. data/lib/rbs/test/type_check.rb +19 -2
  149. data/lib/rbs/type_name.rb +1 -1
  150. data/lib/rbs/types.rb +88 -78
  151. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  152. data/lib/rbs/validator.rb +2 -2
  153. data/lib/rbs/version.rb +1 -1
  154. data/lib/rbs.rb +1 -2
  155. data/lib/rdoc/discover.rb +1 -1
  156. data/lib/rdoc_plugin/parser.rb +1 -1
  157. data/rbs.gemspec +4 -3
  158. data/rust/.gitignore +1 -0
  159. data/rust/Cargo.lock +378 -0
  160. data/rust/Cargo.toml +7 -0
  161. data/rust/ruby-rbs/Cargo.toml +22 -0
  162. data/rust/ruby-rbs/build.rs +764 -0
  163. data/rust/ruby-rbs/examples/locations.rs +60 -0
  164. data/rust/ruby-rbs/src/lib.rs +1 -0
  165. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  166. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  167. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  168. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  169. data/rust/ruby-rbs-sys/build.rs +204 -0
  170. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  171. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  172. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  173. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  174. data/schema/typeParam.json +17 -1
  175. data/sig/ast/ruby/annotations.rbs +315 -4
  176. data/sig/ast/ruby/comment_block.rbs +8 -0
  177. data/sig/ast/ruby/declarations.rbs +102 -4
  178. data/sig/ast/ruby/members.rbs +108 -2
  179. data/sig/cli/diff.rbs +5 -11
  180. data/sig/cli/validate.rbs +12 -8
  181. data/sig/cli.rbs +18 -18
  182. data/sig/definition.rbs +6 -1
  183. data/sig/definition_builder.rbs +2 -0
  184. data/sig/environment.rbs +70 -12
  185. data/sig/errors.rbs +13 -14
  186. data/sig/inline_parser.rbs +39 -2
  187. data/sig/locator.rbs +0 -2
  188. data/sig/manifest.yaml +0 -1
  189. data/sig/method_builder.rbs +3 -1
  190. data/sig/parser.rbs +31 -13
  191. data/sig/prototype/helpers.rbs +2 -0
  192. data/sig/resolver/type_name_resolver.rbs +35 -7
  193. data/sig/source.rbs +3 -3
  194. data/sig/type_param.rbs +13 -8
  195. data/sig/types.rbs +6 -7
  196. data/sig/unit_test/spy.rbs +0 -8
  197. data/sig/unit_test/type_assertions.rbs +11 -0
  198. data/src/ast.c +410 -153
  199. data/src/lexer.c +1392 -1313
  200. data/src/lexer.re +3 -0
  201. data/src/lexstate.c +58 -37
  202. data/src/location.c +8 -48
  203. data/src/parser.c +977 -516
  204. data/src/string.c +0 -48
  205. data/src/util/rbs_allocator.c +89 -71
  206. data/src/util/rbs_assert.c +1 -1
  207. data/src/util/rbs_buffer.c +2 -2
  208. data/src/util/rbs_constant_pool.c +10 -14
  209. data/src/util/rbs_encoding.c +4 -8
  210. data/src/util/rbs_unescape.c +56 -20
  211. data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
  212. data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
  213. data/stdlib/cgi/0/core.rbs +9 -393
  214. data/stdlib/cgi/0/manifest.yaml +1 -0
  215. data/stdlib/cgi-escape/0/escape.rbs +171 -0
  216. data/stdlib/coverage/0/coverage.rbs +7 -4
  217. data/stdlib/date/0/date.rbs +92 -79
  218. data/stdlib/date/0/date_time.rbs +25 -24
  219. data/stdlib/delegate/0/delegator.rbs +10 -7
  220. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  221. data/stdlib/digest/0/digest.rbs +110 -0
  222. data/stdlib/erb/0/erb.rbs +748 -347
  223. data/stdlib/etc/0/etc.rbs +55 -50
  224. data/stdlib/fileutils/0/fileutils.rbs +158 -139
  225. data/stdlib/forwardable/0/forwardable.rbs +13 -10
  226. data/stdlib/io-console/0/io-console.rbs +2 -2
  227. data/stdlib/json/0/json.rbs +217 -136
  228. data/stdlib/monitor/0/monitor.rbs +3 -3
  229. data/stdlib/net-http/0/net-http.rbs +162 -134
  230. data/stdlib/objspace/0/objspace.rbs +17 -34
  231. data/stdlib/open-uri/0/open-uri.rbs +48 -8
  232. data/stdlib/open3/0/open3.rbs +469 -10
  233. data/stdlib/openssl/0/openssl.rbs +475 -357
  234. data/stdlib/optparse/0/optparse.rbs +26 -17
  235. data/stdlib/pathname/0/pathname.rbs +11 -1381
  236. data/stdlib/pp/0/pp.rbs +9 -8
  237. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  238. data/stdlib/pstore/0/pstore.rbs +35 -30
  239. data/stdlib/psych/0/psych.rbs +65 -12
  240. data/stdlib/psych/0/store.rbs +2 -4
  241. data/stdlib/pty/0/pty.rbs +9 -6
  242. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  243. data/stdlib/rdoc/0/code_object.rbs +2 -1
  244. data/stdlib/rdoc/0/parser.rbs +1 -1
  245. data/stdlib/rdoc/0/rdoc.rbs +1 -1
  246. data/stdlib/rdoc/0/store.rbs +1 -1
  247. data/stdlib/resolv/0/resolv.rbs +25 -68
  248. data/stdlib/ripper/0/ripper.rbs +22 -19
  249. data/stdlib/securerandom/0/manifest.yaml +2 -0
  250. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  251. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  252. data/stdlib/singleton/0/singleton.rbs +3 -0
  253. data/stdlib/socket/0/addrinfo.rbs +7 -7
  254. data/stdlib/socket/0/basic_socket.rbs +3 -3
  255. data/stdlib/socket/0/ip_socket.rbs +10 -8
  256. data/stdlib/socket/0/socket.rbs +23 -10
  257. data/stdlib/socket/0/tcp_server.rbs +1 -1
  258. data/stdlib/socket/0/tcp_socket.rbs +11 -3
  259. data/stdlib/socket/0/udp_socket.rbs +1 -1
  260. data/stdlib/socket/0/unix_server.rbs +1 -1
  261. data/stdlib/stringio/0/stringio.rbs +1177 -85
  262. data/stdlib/strscan/0/string_scanner.rbs +27 -25
  263. data/stdlib/tempfile/0/tempfile.rbs +25 -21
  264. data/stdlib/time/0/time.rbs +8 -6
  265. data/stdlib/timeout/0/timeout.rbs +63 -7
  266. data/stdlib/tsort/0/cyclic.rbs +3 -0
  267. data/stdlib/tsort/0/tsort.rbs +7 -6
  268. data/stdlib/uri/0/common.rbs +42 -20
  269. data/stdlib/uri/0/file.rbs +3 -3
  270. data/stdlib/uri/0/generic.rbs +26 -18
  271. data/stdlib/uri/0/http.rbs +2 -2
  272. data/stdlib/uri/0/ldap.rbs +2 -2
  273. data/stdlib/uri/0/mailto.rbs +3 -3
  274. data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
  275. data/stdlib/zlib/0/deflate.rbs +4 -3
  276. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  277. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  278. data/stdlib/zlib/0/inflate.rbs +1 -1
  279. data/stdlib/zlib/0/need_dict.rbs +1 -1
  280. data/stdlib/zlib/0/zstream.rbs +1 -0
  281. metadata +50 -6
data/core/rational.rbs CHANGED
@@ -53,15 +53,16 @@ class Rational < Numeric
53
53
 
54
54
  # <!--
55
55
  # rdoc-file=rational.c
56
- # - rat * numeric -> numeric
56
+ # - self * other -> numeric
57
57
  # -->
58
- # Performs multiplication.
58
+ # Returns the numeric product of `self` and `other`:
59
59
  #
60
- # Rational(2, 3) * Rational(2, 3) #=> (4/9)
61
- # Rational(900) * Rational(1) #=> (900/1)
62
- # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
63
- # Rational(9, 8) * 4 #=> (9/2)
64
- # Rational(20, 9) * 9.8 #=> 21.77777777777778
60
+ # Rational(9, 8) * 4 #=> (9/2)
61
+ # Rational(20, 9) * 9.8 #=> 21.77777777777778
62
+ # Rational(9, 8) * Complex(1, 2) # => ((9/8)+(9/4)*i)
63
+ # Rational(2, 3) * Rational(2, 3) #=> (4/9)
64
+ # Rational(900) * Rational(1) #=> (900/1)
65
+ # Rational(-2, 9) * Rational(-9, 2) #=> (1/1)
65
66
  #
66
67
  def *: (Integer) -> Rational
67
68
  | (Rational) -> Rational
@@ -69,9 +70,9 @@ class Rational < Numeric
69
70
 
70
71
  # <!--
71
72
  # rdoc-file=rational.c
72
- # - rat ** numeric -> numeric
73
+ # - self ** exponent -> numeric
73
74
  # -->
74
- # Performs exponentiation.
75
+ # Returns `self` raised to the power `exponent`:
75
76
  #
76
77
  # Rational(2) ** Rational(3) #=> (8/1)
77
78
  # Rational(10) ** -2 #=> (1/100)
@@ -85,27 +86,35 @@ class Rational < Numeric
85
86
 
86
87
  # <!--
87
88
  # rdoc-file=rational.c
88
- # - rat + numeric -> numeric
89
+ # - self + other -> numeric
89
90
  # -->
90
- # Performs addition.
91
+ # Returns the sum of `self` and `other`:
91
92
  #
92
- # Rational(2, 3) + Rational(2, 3) #=> (4/3)
93
- # Rational(900) + Rational(1) #=> (901/1)
94
- # Rational(-2, 9) + Rational(-9, 2) #=> (-85/18)
95
- # Rational(9, 8) + 4 #=> (41/8)
96
- # Rational(20, 9) + 9.8 #=> 12.022222222222222
93
+ # Rational(2, 3) + 0 # => (2/3)
94
+ # Rational(2, 3) + 1 # => (5/3)
95
+ # Rational(2, 3) + -1 # => (-1/3)
96
+ #
97
+ # Rational(2, 3) + Complex(1, 0) # => ((5/3)+0i)
98
+ #
99
+ # Rational(2, 3) + Rational(1, 1) # => (5/3)
100
+ # Rational(2, 3) + Rational(3, 2) # => (13/6)
101
+ # Rational(2, 3) + Rational(3.0, 2.0) # => (13/6)
102
+ # Rational(2, 3) + Rational(3.1, 2.1) # => (30399297484750849/14186338826217063)
103
+ #
104
+ # For a computation involving Floats, the result may be inexact (see Float#+):
105
+ #
106
+ # Rational(2, 3) + 1.0 # => 1.6666666666666665
107
+ # Rational(2, 3) + Complex(1.0, 0.0) # => (1.6666666666666665+0.0i)
97
108
  #
98
109
  def +: (Float) -> Float
99
110
  | (Complex) -> Complex
100
111
  | (Numeric) -> Rational
101
112
 
102
- def +@: () -> Rational
103
-
104
113
  # <!--
105
114
  # rdoc-file=rational.c
106
- # - rat - numeric -> numeric
115
+ # - self - other -> numeric
107
116
  # -->
108
- # Performs subtraction.
117
+ # Returns the difference of `self` and `other`:
109
118
  #
110
119
  # Rational(2, 3) - Rational(2, 3) #=> (0/1)
111
120
  # Rational(900) - Rational(1) #=> (899/1)
@@ -119,18 +128,20 @@ class Rational < Numeric
119
128
 
120
129
  # <!--
121
130
  # rdoc-file=rational.c
122
- # - -rat -> rational
131
+ # - -self -> rational
123
132
  # -->
124
- # Negates `rat`.
133
+ # Returns `self`, negated:
134
+ #
135
+ # -(1/3r) # => (-1/3)
136
+ # -(-1/3r) # => (1/3)
125
137
  #
126
138
  def -@: () -> Rational
127
139
 
128
140
  # <!--
129
141
  # rdoc-file=rational.c
130
- # - rat / numeric -> numeric
131
- # - rat.quo(numeric) -> numeric
142
+ # - self / other -> numeric
132
143
  # -->
133
- # Performs division.
144
+ # Returns the quotient of `self` and `other`:
134
145
  #
135
146
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
136
147
  # Rational(900) / Rational(1) #=> (900/1)
@@ -144,20 +155,29 @@ class Rational < Numeric
144
155
 
145
156
  # <!--
146
157
  # rdoc-file=rational.c
147
- # - rational <=> numeric -> -1, 0, +1, or nil
158
+ # - self <=> other -> -1, 0, 1, or nil
148
159
  # -->
149
- # Returns -1, 0, or +1 depending on whether `rational` is less than, equal to,
150
- # or greater than `numeric`.
160
+ # Compares `self` and `other`.
161
+ #
162
+ # Returns:
163
+ #
164
+ # * <code>-1</code>, if `self` is less than `other`.
165
+ # * `0`, if the two values are the same.
166
+ # * `1`, if `self` is greater than `other`.
167
+ # * `nil`, if the two values are incomparable.
151
168
  #
152
- # `nil` is returned if the two values are incomparable.
169
+ # Examples:
153
170
  #
154
- # Rational(2, 3) <=> Rational(2, 3) #=> 0
155
- # Rational(5) <=> 5 #=> 0
156
- # Rational(2, 3) <=> Rational(1, 3) #=> 1
157
- # Rational(1, 3) <=> 1 #=> -1
158
- # Rational(1, 3) <=> 0.3 #=> 1
171
+ # Rational(2, 3) <=> Rational(4, 3) # => -1
172
+ # Rational(2, 1) <=> Rational(2, 1) # => 0
173
+ # Rational(2, 1) <=> 2 # => 0
174
+ # Rational(2, 1) <=> 2.0 # => 0
175
+ # Rational(2, 1) <=> Complex(2, 0) # => 0
176
+ # Rational(4, 3) <=> Rational(2, 3) # => 1
177
+ # Rational(4, 3) <=> :foo # => nil
159
178
  #
160
- # Rational(1, 3) <=> "0.3" #=> nil
179
+ # Class Rational includes module Comparable, each of whose methods uses
180
+ # Rational#<=> for comparison.
161
181
  #
162
182
  def <=>: (Integer | Rational) -> Integer
163
183
  | (untyped) -> Integer?
@@ -188,12 +208,6 @@ class Rational < Numeric
188
208
  #
189
209
  def abs: () -> Rational
190
210
 
191
- def abs2: () -> Rational
192
-
193
- def angle: () -> (Integer | Float)
194
-
195
- alias arg angle
196
-
197
211
  # <!--
198
212
  # rdoc-file=rational.c
199
213
  # - rat.ceil([ndigits]) -> integer or rational
@@ -202,7 +216,7 @@ class Rational < Numeric
202
216
  # `ndigits` decimal digits (default: 0).
203
217
  #
204
218
  # When the precision is negative, the returned value is an integer with at least
205
- # `ndigits.abs` trailing zeros.
219
+ # <code>ndigits.abs</code> trailing zeros.
206
220
  #
207
221
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
208
222
  #
@@ -222,10 +236,6 @@ class Rational < Numeric
222
236
 
223
237
  def coerce: (Numeric) -> [ Numeric, Numeric ]
224
238
 
225
- def conj: () -> Rational
226
-
227
- def conjugate: () -> Rational
228
-
229
239
  # <!--
230
240
  # rdoc-file=rational.c
231
241
  # - rat.denominator -> integer
@@ -239,15 +249,9 @@ class Rational < Numeric
239
249
  #
240
250
  def denominator: () -> Integer
241
251
 
242
- def div: (Numeric) -> Integer
243
-
244
252
  def divmod: (Integer | Float | Rational) -> [ Integer, Rational ]
245
253
  | (Numeric) -> [ Numeric, Numeric ]
246
254
 
247
- def dup: () -> self
248
-
249
- def eql?: (untyped) -> bool
250
-
251
255
  # <!--
252
256
  # rdoc-file=rational.c
253
257
  # - rat.fdiv(numeric) -> float
@@ -260,8 +264,6 @@ class Rational < Numeric
260
264
  #
261
265
  def fdiv: (Numeric) -> Float
262
266
 
263
- def finite?: () -> bool
264
-
265
267
  # <!--
266
268
  # rdoc-file=rational.c
267
269
  # - rat.floor([ndigits]) -> integer or rational
@@ -270,7 +272,7 @@ class Rational < Numeric
270
272
  # `ndigits` decimal digits (default: 0).
271
273
  #
272
274
  # When the precision is negative, the returned value is an integer with at least
273
- # `ndigits.abs` trailing zeros.
275
+ # <code>ndigits.abs</code> trailing zeros.
274
276
  #
275
277
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
276
278
  #
@@ -295,14 +297,6 @@ class Rational < Numeric
295
297
  #
296
298
  def hash: () -> Integer
297
299
 
298
- def i: () -> Complex
299
-
300
- def imag: () -> Integer
301
-
302
- def imaginary: () -> Integer
303
-
304
- def infinite?: () -> Integer?
305
-
306
300
  # <!--
307
301
  # rdoc-file=rational.c
308
302
  # - rat.inspect -> string
@@ -315,8 +309,6 @@ class Rational < Numeric
315
309
  #
316
310
  def inspect: () -> String
317
311
 
318
- def integer?: () -> bool
319
-
320
312
  # <!-- rdoc-file=rational.c -->
321
313
  # Returns the absolute value of `rat`.
322
314
  #
@@ -336,8 +328,6 @@ class Rational < Numeric
336
328
  #
337
329
  def negative?: () -> bool
338
330
 
339
- def nonzero?: () -> self?
340
-
341
331
  # <!--
342
332
  # rdoc-file=rational.c
343
333
  # - rat.numerator -> integer
@@ -351,8 +341,6 @@ class Rational < Numeric
351
341
  #
352
342
  def numerator: () -> Integer
353
343
 
354
- alias phase angle
355
-
356
344
  def polar: () -> [ Rational, Integer | Float ]
357
345
 
358
346
  # <!--
@@ -364,7 +352,7 @@ class Rational < Numeric
364
352
  def positive?: () -> bool
365
353
 
366
354
  # <!-- rdoc-file=rational.c -->
367
- # Performs division.
355
+ # Returns the quotient of `self` and `other`:
368
356
  #
369
357
  # Rational(2, 3) / Rational(2, 3) #=> (1/1)
370
358
  # Rational(900) / Rational(1) #=> (900/1)
@@ -391,14 +379,8 @@ class Rational < Numeric
391
379
  #
392
380
  def rationalize: (?Numeric eps) -> Rational
393
381
 
394
- def real: () -> Rational
395
-
396
- def real?: () -> true
397
-
398
382
  def rect: () -> [ Rational, Numeric ]
399
383
 
400
- alias rectangular rect
401
-
402
384
  def remainder: (Float) -> Float
403
385
  | (Numeric) -> Rational
404
386
 
@@ -410,7 +392,7 @@ class Rational < Numeric
410
392
  # decimal digits (default: 0).
411
393
  #
412
394
  # When the precision is negative, the returned value is an integer with at least
413
- # `ndigits.abs` trailing zeros.
395
+ # <code>ndigits.abs</code> trailing zeros.
414
396
  #
415
397
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
416
398
  #
@@ -440,13 +422,6 @@ class Rational < Numeric
440
422
  def round: (?half: :up | :down | :even) -> Integer
441
423
  | (Integer digits, ?half: :up | :down | :even) -> (Integer | Rational)
442
424
 
443
- def step: (?Numeric limit, ?Numeric step) { (Rational) -> void } -> self
444
- | (?Numeric limit, ?Numeric step) -> Enumerator[Rational, self]
445
- | (?by: Numeric, ?to: Numeric) { (Rational) -> void } -> self
446
- | (?by: Numeric, ?to: Numeric) -> Enumerator[Rational, self]
447
-
448
- def to_c: () -> Complex
449
-
450
425
  # <!--
451
426
  # rdoc-file=rational.c
452
427
  # - rat.to_f -> float
@@ -476,8 +451,6 @@ class Rational < Numeric
476
451
  #
477
452
  def to_i: () -> Integer
478
453
 
479
- alias to_int to_i
480
-
481
454
  # <!--
482
455
  # rdoc-file=rational.c
483
456
  # - rat.to_r -> self
@@ -509,7 +482,7 @@ class Rational < Numeric
509
482
  # digits (default: 0).
510
483
  #
511
484
  # When the precision is negative, the returned value is an integer with at least
512
- # `ndigits.abs` trailing zeros.
485
+ # <code>ndigits.abs</code> trailing zeros.
513
486
  #
514
487
  # Returns a rational when `ndigits` is positive, otherwise returns an integer.
515
488
  #
@@ -526,6 +499,4 @@ class Rational < Numeric
526
499
  #
527
500
  def truncate: () -> Integer
528
501
  | (Integer ndigits) -> (Integer | Rational)
529
-
530
- def zero?: () -> bool
531
502
  end
@@ -4,7 +4,7 @@ module RBS
4
4
  # ## ARGF and `ARGV`
5
5
  #
6
6
  # The ARGF object works with the array at global variable `ARGV` to make
7
- # `$stdin` and file streams available in the Ruby program:
7
+ # <code>$stdin</code> and file streams available in the Ruby program:
8
8
  #
9
9
  # * **ARGV** may be thought of as the **argument vector** array.
10
10
  #
@@ -13,9 +13,9 @@ module RBS
13
13
  #
14
14
  # * **ARGF** may be thought of as the **argument files** object.
15
15
  #
16
- # It can access file streams and/or the `$stdin` stream, based on what it
17
- # finds in `ARGV`. This provides a convenient way for the command line to
18
- # specify streams for a Ruby program to read.
16
+ # It can access file streams and/or the <code>$stdin</code> stream, based on
17
+ # what it finds in `ARGV`. This provides a convenient way for the command
18
+ # line to specify streams for a Ruby program to read.
19
19
  #
20
20
  # ## Reading
21
21
  #
@@ -24,16 +24,16 @@ module RBS
24
24
  #
25
25
  # ### Simplest Case
26
26
  #
27
- # When the *very first* ARGF read occurs with an empty `ARGV` (`[]`), the source
28
- # is `$stdin`:
27
+ # When the *very first* ARGF read occurs with an empty `ARGV` (<code>[]</code>),
28
+ # the source is <code>$stdin</code>:
29
29
  #
30
- # * File `t.rb`:
30
+ # * File <code>t.rb</code>:
31
31
  #
32
32
  # p ['ARGV', ARGV]
33
33
  # p ['ARGF.read', ARGF.read]
34
34
  #
35
- # * Commands and outputs (see below for the content of files `foo.txt` and
36
- # `bar.txt`):
35
+ # * Commands and outputs (see below for the content of files
36
+ # <code>foo.txt</code> and <code>bar.txt</code>):
37
37
  #
38
38
  # $ echo "Open the pod bay doors, Hal." | ruby t.rb
39
39
  # ["ARGV", []]
@@ -45,7 +45,8 @@ module RBS
45
45
  #
46
46
  # ### About the Examples
47
47
  #
48
- # Many examples here assume the existence of files `foo.txt` and `bar.txt`:
48
+ # Many examples here assume the existence of files <code>foo.txt</code> and
49
+ # <code>bar.txt</code>:
49
50
  #
50
51
  # $ cat foo.txt
51
52
  # Foo 0
@@ -66,19 +67,20 @@ module RBS
66
67
  # one of:
67
68
  #
68
69
  # * The string path to a file that may be opened as a stream.
69
- # * The character `'-'`, meaning stream `$stdin`.
70
+ # * The character <code>'-'</code>, meaning stream <code>$stdin</code>.
70
71
  #
71
72
  # Each element that is *not* one of these should be removed from `ARGV` before
72
73
  # ARGF accesses that source.
73
74
  #
74
75
  # In the following example:
75
76
  #
76
- # * Filepaths `foo.txt` and `bar.txt` may be retained as potential sources.
77
- # * Options `--xyzzy` and `--mojo` should be removed.
77
+ # * Filepaths <code>foo.txt</code> and <code>bar.txt</code> may be retained as
78
+ # potential sources.
79
+ # * Options <code>--xyzzy</code> and <code>--mojo</code> should be removed.
78
80
  #
79
81
  # Example:
80
82
  #
81
- # * File `t.rb`:
83
+ # * File <code>t.rb</code>:
82
84
  #
83
85
  # # Print arguments (and options, if any) found on command line.
84
86
  # p ['ARGV', ARGV]
@@ -90,10 +92,10 @@ module RBS
90
92
  #
91
93
  # ARGF's stream access considers the elements of `ARGV`, left to right:
92
94
  #
93
- # * File `t.rb`:
95
+ # * File <code>t.rb</code>:
94
96
  #
95
97
  # p "ARGV: #{ARGV}"
96
- # p "Line: #{ARGF.read}" # Read everything from all specified streams.
98
+ # p "Read: #{ARGF.read}" # Read everything from all specified streams.
97
99
  #
98
100
  # * Command and output:
99
101
  #
@@ -112,7 +114,7 @@ module RBS
112
114
  # Each element in `ARGV` is removed when its corresponding source is accessed;
113
115
  # when all sources have been accessed, the array is empty:
114
116
  #
115
- # * File `t.rb`:
117
+ # * File <code>t.rb</code>:
116
118
  #
117
119
  # until ARGV.empty? && ARGF.eof?
118
120
  # p "ARGV: #{ARGV}"
@@ -142,7 +144,7 @@ module RBS
142
144
  # This program prints what it reads from files at the paths specified on the
143
145
  # command line:
144
146
  #
145
- # * File `t.rb`:
147
+ # * File <code>t.rb</code>:
146
148
  #
147
149
  # p ['ARGV', ARGV]
148
150
  # # Read and print all content from the specified sources.
@@ -154,11 +156,12 @@ module RBS
154
156
  # ["ARGV", [foo.txt, bar.txt]
155
157
  # ["ARGF.read", "Foo 0\nFoo 1\nBar 0\nBar 1\nBar 2\nBar 3\n"]
156
158
  #
157
- # #### Specifying `$stdin` in `ARGV`
159
+ # #### Specifying <code>$stdin</code> in `ARGV`
158
160
  #
159
- # To specify stream `$stdin` in `ARGV`, us the character `'-'`:
161
+ # To specify stream <code>$stdin</code> in `ARGV`, us the character
162
+ # <code>'-'</code>:
160
163
  #
161
- # * File `t.rb`:
164
+ # * File <code>t.rb</code>:
162
165
  #
163
166
  # p ['ARGV', ARGV]
164
167
  # p ['ARGF.read', ARGF.read]
@@ -169,8 +172,9 @@ module RBS
169
172
  # ["ARGV", ["-"]]
170
173
  # ["ARGF.read", "Open the pod bay doors, Hal.\n"]
171
174
  #
172
- # When no character `'-'` is given, stream `$stdin` is ignored (exception: see
173
- # [Specifying $stdin in ARGV](rdoc-ref:ARGF@Specifying+-24stdin+in+ARGV)):
175
+ # When no character <code>'-'</code> is given, stream <code>$stdin</code> is
176
+ # ignored (exception: see [Specifying $stdin in
177
+ # ARGV](rdoc-ref:ARGF@Specifying+-24stdin+in+ARGV)):
174
178
  #
175
179
  # * Command and output:
176
180
  #
@@ -181,7 +185,7 @@ module RBS
181
185
  # #### Mixtures and Repetitions in `ARGV`
182
186
  #
183
187
  # For an ARGF reader, `ARGV` may contain any mixture of filepaths and character
184
- # `'-'`, including repetitions.
188
+ # <code>'-'</code>, including repetitions.
185
189
  #
186
190
  # #### Modifications to `ARGV`
187
191
  #
@@ -208,13 +212,13 @@ module RBS
208
212
  # ### About Enumerable
209
213
  #
210
214
  # ARGF includes module Enumerable. Virtually all methods in Enumerable call
211
- # method `#each` in the including class.
215
+ # method <code>#each</code> in the including class.
212
216
  #
213
217
  # **Note well**: In ARGF, method #each returns data from the *sources*, *not*
214
- # from `ARGV`; therefore, for example, `ARGF#entries` returns an array of lines
215
- # from the sources, not an array of the strings from `ARGV`:
218
+ # from `ARGV`; therefore, for example, <code>ARGF#entries</code> returns an
219
+ # array of lines from the sources, not an array of the strings from `ARGV`:
216
220
  #
217
- # * File `t.rb`:
221
+ # * File <code>t.rb</code>:
218
222
  #
219
223
  # p ['ARGV', ARGV]
220
224
  # p ['ARGF.entries', ARGF.entries]
@@ -521,8 +525,8 @@ module RBS
521
525
  # rdoc-file=io.c
522
526
  # - ARGF.file -> IO or File object
523
527
  # -->
524
- # Returns the current file as an IO or File object. `$stdin` is returned when
525
- # the current file is STDIN.
528
+ # Returns the current file as an IO or File object. <code>$stdin</code> is
529
+ # returned when the current file is STDIN.
526
530
  #
527
531
  # For example:
528
532
  #
@@ -630,8 +634,9 @@ module RBS
630
634
  # -->
631
635
  # Returns the next line from the current file in ARGF.
632
636
  #
633
- # By default lines are assumed to be separated by `$/`; to use a different
634
- # character as a separator, supply it as a String for the *sep* argument.
637
+ # By default lines are assumed to be separated by <code>$/</code>; to use a
638
+ # different character as a separator, supply it as a String for the *sep*
639
+ # argument.
635
640
  #
636
641
  # The optional *limit* argument specifies how many characters of each line to
637
642
  # return. By default all characters are returned.
@@ -647,7 +652,7 @@ module RBS
647
652
  # -->
648
653
  # Returns the file extension appended to the names of backup copies of modified
649
654
  # files under in-place edit mode. This value can be set using ARGF.inplace_mode=
650
- # or passing the `-i` switch to the Ruby binary.
655
+ # or passing the <code>-i</code> switch to the Ruby binary.
651
656
  #
652
657
  %a{annotate:rdoc:copy:ARGF#inplace_mode}
653
658
  def inplace_mode: () -> String?
@@ -668,8 +673,9 @@ module RBS
668
673
  # print line.sub("foo","bar")
669
674
  # end
670
675
  #
671
- # First, *file.txt.bak* is created as a backup copy of *file.txt*. Then, each
672
- # line of *file.txt* has the first occurrence of "foo" replaced with "bar".
676
+ # First, <em>file.txt.bak</em> is created as a backup copy of <em>file.txt</em>.
677
+ # Then, each line of <em>file.txt</em> has the first occurrence of "foo"
678
+ # replaced with "bar".
673
679
  #
674
680
  %a{annotate:rdoc:copy:ARGF#inplace_mode=}
675
681
  def inplace_mode=: (String) -> self
@@ -684,10 +690,10 @@ module RBS
684
690
  # object.
685
691
  #
686
692
  # If ARGF.set_encoding has been called with two encoding names, the second is
687
- # returned. Otherwise, if `Encoding.default_external` has been set, that value
688
- # is returned. Failing that, if a default external encoding was specified on the
689
- # command-line, that value is used. If the encoding is unknown, `nil` is
690
- # returned.
693
+ # returned. Otherwise, if <code>Encoding.default_external</code> has been set,
694
+ # that value is returned. Failing that, if a default external encoding was
695
+ # specified on the command-line, that value is used. If the encoding is unknown,
696
+ # `nil` is returned.
691
697
  #
692
698
  %a{annotate:rdoc:copy:ARGF#internal_encoding}
693
699
  def internal_encoding: () -> Encoding
@@ -778,15 +784,15 @@ module RBS
778
784
  # - print(*objects) -> nil
779
785
  # -->
780
786
  # Writes the given objects to the stream; returns `nil`. Appends the output
781
- # record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See
782
- # [Line IO](rdoc-ref:IO@Line+IO).
787
+ # record separator <code>$OUTPUT_RECORD_SEPARATOR</code> (<code>$\</code>), if
788
+ # it is not `nil`. See [Line IO](rdoc-ref:IO@Line+IO).
783
789
  #
784
790
  # With argument `objects` given, for each object:
785
791
  #
786
792
  # * Converts via its method `to_s` if not a string.
787
793
  # * Writes to the stream.
788
794
  # * If not the last object, writes the output field separator
789
- # `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
795
+ # <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code>) if it is not `nil`.
790
796
  #
791
797
  # With default separators:
792
798
  #
@@ -818,8 +824,8 @@ module RBS
818
824
  #
819
825
  # "0,0.0,0/1,0+0i,zero,zero\n"
820
826
  #
821
- # With no argument given, writes the content of `$_` (which is usually the most
822
- # recent user input):
827
+ # With no argument given, writes the content of <code>$_</code> (which is
828
+ # usually the most recent user input):
823
829
  #
824
830
  # f = File.open('t.tmp', 'w+')
825
831
  # gets # Sets $_ to the most recent user input.
@@ -836,7 +842,7 @@ module RBS
836
842
  # Formats and writes `objects` to the stream.
837
843
  #
838
844
  # For details on `format_string`, see [Format
839
- # Specifications](rdoc-ref:format_specifications.rdoc).
845
+ # Specifications](rdoc-ref:language/format_specifications.rdoc).
840
846
  #
841
847
  %a{annotate:rdoc:copy:ARGF#printf}
842
848
  def printf: (String format_string, *untyped args) -> nil
@@ -871,13 +877,13 @@ module RBS
871
877
  # newline sequence. If called without arguments, writes a newline. See [Line
872
878
  # IO](rdoc-ref:IO@Line+IO).
873
879
  #
874
- # Note that each added newline is the character `"\n"<//tt>, not the output
875
- # record separator (<tt>$\`).
880
+ # Note that each added newline is the character <code>"\n"<//tt>, not the output
881
+ # record separator (<tt>$\</code>).
876
882
  #
877
883
  # Treatment for each object:
878
884
  #
879
885
  # * String: writes the string.
880
- # * Neither string nor array: writes `object.to_s`.
886
+ # * Neither string nor array: writes <code>object.to_s</code>.
881
887
  # * Array: writes each element of the array; arrays may be nested.
882
888
  #
883
889
  # To keep these examples brief, we define this helper method:
@@ -930,7 +936,7 @@ module RBS
930
936
  # conversion is applied, if applicable. A string is returned even if EOF is
931
937
  # encountered before any data is read.
932
938
  #
933
- # If *length* is zero, it returns an empty string (`""`).
939
+ # If *length* is zero, it returns an empty string (<code>""</code>).
934
940
  #
935
941
  # If the optional *outbuf* argument is present, it must reference a String,
936
942
  # which will receive the data. The *outbuf* will contain only the received data
@@ -1015,8 +1021,9 @@ module RBS
1015
1021
  # -->
1016
1022
  # Returns the next line from the current file in ARGF.
1017
1023
  #
1018
- # By default lines are assumed to be separated by `$/`; to use a different
1019
- # character as a separator, supply it as a String for the *sep* argument.
1024
+ # By default lines are assumed to be separated by <code>$/</code>; to use a
1025
+ # different character as a separator, supply it as a String for the *sep*
1026
+ # argument.
1020
1027
  #
1021
1028
  # The optional *limit* argument specifies how many characters of each line to
1022
1029
  # return. By default all characters are returned.
@@ -1041,7 +1048,7 @@ module RBS
1041
1048
  # lines = ARGF.readlines
1042
1049
  # lines[0] #=> "This is line one\n"
1043
1050
  #
1044
- # See `IO.readlines` for a full description of all options.
1051
+ # See <code>IO.readlines</code> for a full description of all options.
1045
1052
  #
1046
1053
  %a{annotate:rdoc:copy:ARGF#readlines}
1047
1054
  def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
@@ -1161,7 +1168,7 @@ module RBS
1161
1168
  # lines = ARGF.readlines
1162
1169
  # lines[0] #=> "This is line one\n"
1163
1170
  #
1164
- # See `IO.readlines` for a full description of all options.
1171
+ # See <code>IO.readlines</code> for a full description of all options.
1165
1172
  #
1166
1173
  %a{annotate:rdoc:copy:ARGF#to_a}
1167
1174
  def to_a: (?String sep, ?Integer limit) -> ::Array[String]