rbs 4.0.0.dev.5 → 4.0.1.dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +1 -0
  3. data/.github/workflows/c-check.yml +8 -4
  4. data/.github/workflows/comments.yml +3 -1
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +10 -0
  7. data/.github/workflows/rust.yml +95 -0
  8. data/CHANGELOG.md +323 -0
  9. data/Rakefile +12 -29
  10. data/Steepfile +1 -0
  11. data/config.yml +393 -37
  12. data/core/array.rbs +218 -188
  13. data/core/basic_object.rbs +9 -8
  14. data/core/class.rbs +6 -5
  15. data/core/comparable.rbs +45 -31
  16. data/core/complex.rbs +52 -40
  17. data/core/dir.rbs +57 -45
  18. data/core/encoding.rbs +5 -5
  19. data/core/enumerable.rbs +96 -91
  20. data/core/enumerator.rbs +4 -3
  21. data/core/errno.rbs +3 -2
  22. data/core/errors.rbs +31 -29
  23. data/core/exception.rbs +12 -12
  24. data/core/fiber.rbs +36 -36
  25. data/core/file.rbs +186 -113
  26. data/core/file_test.rbs +2 -2
  27. data/core/float.rbs +41 -32
  28. data/core/gc.rbs +78 -70
  29. data/core/hash.rbs +70 -60
  30. data/core/integer.rbs +32 -28
  31. data/core/io/buffer.rbs +36 -36
  32. data/core/io/wait.rbs +7 -7
  33. data/core/io.rbs +120 -135
  34. data/core/kernel.rbs +189 -139
  35. data/core/marshal.rbs +3 -3
  36. data/core/match_data.rbs +14 -12
  37. data/core/math.rbs +69 -67
  38. data/core/method.rbs +6 -6
  39. data/core/module.rbs +146 -85
  40. data/core/nil_class.rbs +4 -3
  41. data/core/numeric.rbs +35 -32
  42. data/core/object.rbs +6 -8
  43. data/core/object_space.rbs +11 -10
  44. data/core/pathname.rbs +131 -81
  45. data/core/proc.rbs +65 -33
  46. data/core/process.rbs +219 -201
  47. data/core/ractor.rbs +15 -11
  48. data/core/random.rbs +4 -3
  49. data/core/range.rbs +52 -47
  50. data/core/rational.rbs +5 -5
  51. data/core/rbs/unnamed/argf.rbs +58 -51
  52. data/core/rbs/unnamed/env_class.rbs +18 -13
  53. data/core/rbs/unnamed/main_class.rbs +123 -0
  54. data/core/rbs/unnamed/random.rbs +7 -5
  55. data/core/regexp.rbs +236 -197
  56. data/core/ruby.rbs +1 -1
  57. data/core/ruby_vm.rbs +32 -30
  58. data/core/rubygems/config_file.rbs +5 -5
  59. data/core/rubygems/errors.rbs +1 -1
  60. data/core/rubygems/requirement.rbs +5 -5
  61. data/core/rubygems/rubygems.rbs +5 -3
  62. data/core/set.rbs +17 -16
  63. data/core/signal.rbs +2 -2
  64. data/core/string.rbs +311 -292
  65. data/core/struct.rbs +26 -25
  66. data/core/symbol.rbs +25 -24
  67. data/core/thread.rbs +40 -34
  68. data/core/time.rbs +47 -42
  69. data/core/trace_point.rbs +34 -31
  70. data/core/true_class.rbs +2 -2
  71. data/core/unbound_method.rbs +10 -10
  72. data/core/warning.rbs +7 -7
  73. data/docs/collection.md +1 -1
  74. data/docs/config.md +171 -0
  75. data/docs/inline.md +110 -4
  76. data/docs/syntax.md +13 -12
  77. data/ext/rbs_extension/ast_translation.c +489 -135
  78. data/ext/rbs_extension/class_constants.c +8 -0
  79. data/ext/rbs_extension/class_constants.h +4 -0
  80. data/ext/rbs_extension/legacy_location.c +28 -51
  81. data/ext/rbs_extension/legacy_location.h +37 -0
  82. data/ext/rbs_extension/main.c +12 -20
  83. data/include/rbs/ast.h +423 -195
  84. data/include/rbs/lexer.h +2 -2
  85. data/include/rbs/location.h +25 -44
  86. data/include/rbs/parser.h +2 -2
  87. data/include/rbs/util/rbs_constant_pool.h +0 -3
  88. data/include/rbs.h +8 -0
  89. data/lib/rbs/ast/ruby/annotations.rb +157 -4
  90. data/lib/rbs/ast/ruby/members.rb +374 -22
  91. data/lib/rbs/cli/validate.rb +5 -60
  92. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  93. data/lib/rbs/definition_builder.rb +60 -27
  94. data/lib/rbs/errors.rb +0 -11
  95. data/lib/rbs/inline_parser.rb +1 -1
  96. data/lib/rbs/parser_aux.rb +20 -7
  97. data/lib/rbs/prototype/helpers.rb +57 -0
  98. data/lib/rbs/prototype/rb.rb +1 -26
  99. data/lib/rbs/prototype/rbi.rb +1 -20
  100. data/lib/rbs/test/type_check.rb +3 -0
  101. data/lib/rbs/types.rb +62 -52
  102. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  103. data/lib/rbs/version.rb +1 -1
  104. data/lib/rbs.rb +0 -1
  105. data/rbs.gemspec +1 -1
  106. data/rust/.gitignore +1 -0
  107. data/rust/Cargo.lock +378 -0
  108. data/rust/Cargo.toml +7 -0
  109. data/rust/ruby-rbs/Cargo.toml +22 -0
  110. data/rust/ruby-rbs/build.rs +764 -0
  111. data/rust/ruby-rbs/examples/locations.rs +60 -0
  112. data/rust/ruby-rbs/src/lib.rs +1 -0
  113. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  114. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  115. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  116. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  117. data/rust/ruby-rbs-sys/build.rs +204 -0
  118. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  119. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  120. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  121. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  122. data/sig/ast/ruby/annotations.rbs +191 -4
  123. data/sig/ast/ruby/members.rbs +21 -1
  124. data/sig/cli/validate.rbs +1 -6
  125. data/sig/definition_builder.rbs +2 -0
  126. data/sig/errors.rbs +0 -8
  127. data/sig/method_types.rbs +1 -1
  128. data/sig/parser.rbs +17 -13
  129. data/sig/prototype/helpers.rbs +2 -0
  130. data/sig/types.rbs +10 -11
  131. data/sig/unit_test/spy.rbs +0 -8
  132. data/sig/unit_test/type_assertions.rbs +11 -0
  133. data/src/ast.c +339 -161
  134. data/src/lexstate.c +1 -1
  135. data/src/location.c +7 -47
  136. data/src/parser.c +674 -480
  137. data/src/util/rbs_constant_pool.c +0 -4
  138. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  139. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  140. data/stdlib/coverage/0/coverage.rbs +4 -3
  141. data/stdlib/date/0/date.rbs +33 -28
  142. data/stdlib/date/0/date_time.rbs +24 -23
  143. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  144. data/stdlib/erb/0/erb.rbs +64 -53
  145. data/stdlib/etc/0/etc.rbs +55 -50
  146. data/stdlib/fileutils/0/fileutils.rbs +138 -125
  147. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  148. data/stdlib/io-console/0/io-console.rbs +2 -2
  149. data/stdlib/json/0/json.rbs +135 -108
  150. data/stdlib/monitor/0/monitor.rbs +3 -3
  151. data/stdlib/net-http/0/net-http.rbs +159 -134
  152. data/stdlib/objspace/0/objspace.rbs +8 -7
  153. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  154. data/stdlib/open3/0/open3.rbs +36 -35
  155. data/stdlib/openssl/0/openssl.rbs +144 -129
  156. data/stdlib/optparse/0/optparse.rbs +18 -14
  157. data/stdlib/pathname/0/pathname.rbs +2 -2
  158. data/stdlib/pp/0/pp.rbs +9 -8
  159. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  160. data/stdlib/pstore/0/pstore.rbs +35 -30
  161. data/stdlib/psych/0/psych.rbs +61 -8
  162. data/stdlib/psych/0/store.rbs +2 -4
  163. data/stdlib/pty/0/pty.rbs +9 -6
  164. data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
  165. data/stdlib/ripper/0/ripper.rbs +20 -17
  166. data/stdlib/securerandom/0/securerandom.rbs +1 -1
  167. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  168. data/stdlib/socket/0/addrinfo.rbs +7 -7
  169. data/stdlib/socket/0/basic_socket.rbs +3 -3
  170. data/stdlib/socket/0/ip_socket.rbs +10 -8
  171. data/stdlib/socket/0/socket.rbs +10 -9
  172. data/stdlib/socket/0/tcp_server.rbs +1 -1
  173. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  174. data/stdlib/socket/0/udp_socket.rbs +1 -1
  175. data/stdlib/socket/0/unix_server.rbs +1 -1
  176. data/stdlib/stringio/0/stringio.rbs +55 -54
  177. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  178. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  179. data/stdlib/time/0/time.rbs +7 -5
  180. data/stdlib/tsort/0/tsort.rbs +7 -6
  181. data/stdlib/uri/0/common.rbs +26 -18
  182. data/stdlib/uri/0/file.rbs +2 -2
  183. data/stdlib/uri/0/generic.rbs +2 -2
  184. data/stdlib/uri/0/http.rbs +2 -2
  185. data/stdlib/uri/0/ldap.rbs +2 -2
  186. data/stdlib/uri/0/mailto.rbs +3 -3
  187. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  188. data/stdlib/zlib/0/deflate.rbs +4 -3
  189. data/stdlib/zlib/0/gzip_reader.rbs +4 -4
  190. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  191. data/stdlib/zlib/0/inflate.rbs +1 -1
  192. data/stdlib/zlib/0/need_dict.rbs +1 -1
  193. metadata +23 -5
  194. data/.github/workflows/valgrind.yml +0 -42
data/core/io/wait.rbs CHANGED
@@ -8,17 +8,17 @@ class IO
8
8
  # Waits until the IO becomes ready for the specified events and returns the
9
9
  # subset of events that become ready, or a falsy value when times out.
10
10
  #
11
- # The events can be a bit mask of `IO::READABLE`, `IO::WRITABLE` or
12
- # `IO::PRIORITY`.
11
+ # The events can be a bit mask of <code>IO::READABLE</code>,
12
+ # <code>IO::WRITABLE</code> or <code>IO::PRIORITY</code>.
13
13
  #
14
14
  # Returns an event mask (truthy value) immediately when buffered data is
15
15
  # available.
16
16
  #
17
- # The second form: if one or more event symbols (`:read`, `:write`, or
18
- # `:read_write`) are passed, the event mask is the bit OR of the bitmask
19
- # corresponding to those symbols. In this form, `timeout` is optional, the
20
- # order of the arguments is arbitrary, and returns `io` if any of the events is
21
- # ready.
17
+ # The second form: if one or more event symbols (<code>:read</code>,
18
+ # <code>:write</code>, or <code>:read_write</code>) are passed, the event mask
19
+ # is the bit OR of the bitmask corresponding to those symbols. In this form,
20
+ # `timeout` is optional, the order of the arguments is arbitrary, and returns
21
+ # `io` if any of the events is ready.
22
22
  #
23
23
  def wait: (Integer events, ?Time::_Timeout timeout) -> (Integer | false | nil)
24
24
  | (?Time::_Timeout? timeout, *wait_mode mode) -> (self | true | false)
data/core/io.rbs CHANGED
@@ -7,9 +7,9 @@
7
7
  # classes in the Ruby standard library are also subclasses of IO; these include
8
8
  # TCPSocket and UDPSocket.
9
9
  #
10
- # The global constant ARGF (also accessible as `$<`) provides an IO-like stream
11
- # that allows access to all file paths found in ARGV (or found in STDIN if ARGV
12
- # is empty). ARGF is not itself a subclass of IO.
10
+ # The global constant ARGF (also accessible as <code>$<</code>) provides an
11
+ # IO-like stream that allows access to all file paths found in ARGV (or found in
12
+ # STDIN if ARGV is empty). ARGF is not itself a subclass of IO.
13
13
  #
14
14
  # Class StringIO provides an IO-like stream that handles a String. StringIO is
15
15
  # not itself a subclass of IO.
@@ -46,10 +46,10 @@
46
46
  # from the position mentioned above); see [Line
47
47
  # Number](rdoc-ref:IO@Line+Number).
48
48
  #
49
- # ## Extension `io/console`
49
+ # ## Extension <code>io/console</code>
50
50
  #
51
- # Extension `io/console` provides numerous methods for interacting with the
52
- # console; requiring it adds numerous methods to class IO.
51
+ # Extension <code>io/console</code> provides numerous methods for interacting
52
+ # with the console; requiring it adds numerous methods to class IO.
53
53
  #
54
54
  # ## Example Files
55
55
  #
@@ -86,23 +86,23 @@
86
86
  # A number of IO methods accept optional keyword arguments that determine how a
87
87
  # new stream is to be opened:
88
88
  #
89
- # * `:mode`: Stream mode.
90
- # * `:flags`: Integer file open flags; If `mode` is also given, the two are
91
- # bitwise-ORed.
92
- # * `:external_encoding`: External encoding for the stream.
93
- # * `:internal_encoding`: Internal encoding for the stream. `'-'` is a synonym
94
- # for the default internal encoding. If the value is `nil` no conversion
95
- # occurs.
96
- # * `:encoding`: Specifies external and internal encodings as
97
- # `'extern:intern'`.
98
- # * `:textmode`: If a truthy value, specifies the mode as text-only, binary
99
- # otherwise.
100
- # * `:binmode`: If a truthy value, specifies the mode as binary, text-only
101
- # otherwise.
102
- # * `:autoclose`: If a truthy value, specifies that the `fd` will close when
103
- # the stream closes; otherwise it remains open.
104
- # * `:path:` If a string value is provided, it is used in #inspect and is
105
- # available as #path method.
89
+ # * <code>:mode</code>: Stream mode.
90
+ # * <code>:flags</code>: Integer file open flags; If `mode` is also given, the
91
+ # two are bitwise-ORed.
92
+ # * <code>:external_encoding</code>: External encoding for the stream.
93
+ # * <code>:internal_encoding</code>: Internal encoding for the stream.
94
+ # <code>'-'</code> is a synonym for the default internal encoding. If the
95
+ # value is `nil` no conversion occurs.
96
+ # * <code>:encoding</code>: Specifies external and internal encodings as
97
+ # <code>'extern:intern'</code>.
98
+ # * <code>:textmode</code>: If a truthy value, specifies the mode as
99
+ # text-only, binary otherwise.
100
+ # * <code>:binmode</code>: If a truthy value, specifies the mode as binary,
101
+ # text-only otherwise.
102
+ # * <code>:autoclose</code>: If a truthy value, specifies that the `fd` will
103
+ # close when the stream closes; otherwise it remains open.
104
+ # * <code>:path:</code> If a string value is provided, it is used in #inspect
105
+ # and is available as #path method.
106
106
  #
107
107
  # Also available are the options offered in String#encode, which may control
108
108
  # conversion between external and internal encoding.
@@ -129,8 +129,8 @@
129
129
  #
130
130
  # The relevant methods:
131
131
  #
132
- # * IO#tell (aliased as `#pos`): Returns the current position (in bytes) in
133
- # the stream.
132
+ # * IO#tell (aliased as <code>#pos</code>): Returns the current position (in
133
+ # bytes) in the stream.
134
134
  # * IO#pos=: Sets the position of the stream to a given integer `new_position`
135
135
  # (in bytes).
136
136
  # * IO#seek: Sets the position of the stream to a given integer `offset` (in
@@ -158,8 +158,8 @@
158
158
  #
159
159
  # You can query whether a stream is positioned at its end:
160
160
  #
161
- # * IO#eof? (also aliased as `#eof`): Returns whether the stream is at
162
- # end-of-stream.
161
+ # * IO#eof? (also aliased as <code>#eof</code>): Returns whether the stream is
162
+ # at end-of-stream.
163
163
  #
164
164
  # You can reposition to end-of-stream by using method IO#seek:
165
165
  #
@@ -225,8 +225,8 @@
225
225
  # separator*: the string that determines what is considered a line; it is
226
226
  # sometimes called the *input record separator*.
227
227
  #
228
- # The default line separator is taken from global variable `$/`, whose initial
229
- # value is `"\n"`.
228
+ # The default line separator is taken from global variable <code>$/</code>,
229
+ # whose initial value is <code>"\n"</code>.
230
230
  #
231
231
  # Generally, the line to be read next is all data from the current
232
232
  # [position](rdoc-ref:IO@Position) to the next line separator (but see [Special
@@ -250,7 +250,7 @@
250
250
  # f.gets # => "e\n"
251
251
  # f.close
252
252
  #
253
- # Or by setting global variable `$/`:
253
+ # Or by setting global variable <code>$/</code>:
254
254
  #
255
255
  # f = File.new('t.txt')
256
256
  # $/ = 'l'
@@ -270,8 +270,8 @@
270
270
  # f.gets(nil) # => "First line\nSecond line\n\nFourth line\nFifth line\n"
271
271
  # f.close
272
272
  #
273
- # * `''` (the empty string): The next "paragraph" is to be read (paragraphs
274
- # being separated by two consecutive line separators):
273
+ # * <code>''</code> (the empty string): The next "paragraph" is to be read
274
+ # (paragraphs being separated by two consecutive line separators):
275
275
  #
276
276
  # f = File.new('t.txt')
277
277
  # f.gets('') # => "First line\nSecond line\n\n"
@@ -285,8 +285,8 @@
285
285
  # multi-byte character will not be split, and so a returned line may be slightly
286
286
  # longer than the limit).
287
287
  #
288
- # The default limit value is `-1`; any negative limit value means that there is
289
- # no limit.
288
+ # The default limit value is <code>-1</code>; any negative limit value means
289
+ # that there is no limit.
290
290
  #
291
291
  # If there is no limit, the line is determined only by `sep`.
292
292
  #
@@ -385,10 +385,10 @@
385
385
  # f.lineno # => 1001
386
386
  # f.close
387
387
  #
388
- # Associated with the line number is the global variable `$.`:
388
+ # Associated with the line number is the global variable <code>$.</code>:
389
389
  #
390
- # * When a stream is opened, `$.` is not set; its value is left over from
391
- # previous activity in the process:
390
+ # * When a stream is opened, <code>$.</code> is not set; its value is left
391
+ # over from previous activity in the process:
392
392
  #
393
393
  # $. = 41
394
394
  # f = File.new('t.txt')
@@ -396,7 +396,8 @@
396
396
  # # => 41
397
397
  # f.close
398
398
  #
399
- # * When a stream is read, `$.` is set to the line number for that stream:
399
+ # * When a stream is read, <code>$.</code> is set to the line number for that
400
+ # stream:
400
401
  #
401
402
  # f0 = File.new('t.txt')
402
403
  # f1 = File.new('t.dat')
@@ -407,7 +408,7 @@
407
408
  # f0.close
408
409
  # f1.close
409
410
  #
410
- # * Methods IO#rewind and IO#seek do not affect `$.`:
411
+ # * Methods IO#rewind and IO#seek do not affect <code>$.</code>:
411
412
  #
412
413
  # f = File.new('t.txt')
413
414
  # f.readlines # => ["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
@@ -652,15 +653,17 @@ class IO < Object
652
653
  #
653
654
  # Argument `advice` is one of the following symbols:
654
655
  #
655
- # * `:normal`: The application has no advice to give about its access pattern
656
- # for the specified data. If no advice is given for an open file, this is
657
- # the default assumption.
658
- # * `:sequential`: The application expects to access the specified data
659
- # sequentially (with lower offsets read before higher ones).
660
- # * `:random`: The specified data will be accessed in random order.
661
- # * `:noreuse`: The specified data will be accessed only once.
662
- # * `:willneed`: The specified data will be accessed in the near future.
663
- # * `:dontneed`: The specified data will not be accessed in the near future.
656
+ # * <code>:normal</code>: The application has no advice to give about its
657
+ # access pattern for the specified data. If no advice is given for an open
658
+ # file, this is the default assumption.
659
+ # * <code>:sequential</code>: The application expects to access the specified
660
+ # data sequentially (with lower offsets read before higher ones).
661
+ # * <code>:random</code>: The specified data will be accessed in random order.
662
+ # * <code>:noreuse</code>: The specified data will be accessed only once.
663
+ # * <code>:willneed</code>: The specified data will be accessed in the near
664
+ # future.
665
+ # * <code>:dontneed</code>: The specified data will not be accessed in the
666
+ # near future.
664
667
  #
665
668
  # Not implemented on all platforms.
666
669
  #
@@ -724,8 +727,8 @@ class IO < Object
724
727
  # If the stream is open for writing, flushes any buffered writes to the
725
728
  # operating system before closing.
726
729
  #
727
- # If the stream was opened by IO.popen, sets global variable `$?` (child exit
728
- # status).
730
+ # If the stream was opened by IO.popen, sets global variable <code>$?</code>
731
+ # (child exit status).
729
732
  #
730
733
  # It is not an error to close an IO object that has already been closed. It just
731
734
  # returns nil.
@@ -790,7 +793,7 @@ class IO < Object
790
793
  # and Closed Streams](rdoc-ref:IO@Open+and+Closed+Streams).
791
794
  #
792
795
  # If the stream was opened by IO.popen and is also closed for writing, sets
793
- # global variable `$?` (child exit status).
796
+ # global variable <code>$?</code> (child exit status).
794
797
  #
795
798
  # Example:
796
799
  #
@@ -824,7 +827,7 @@ class IO < Object
824
827
  # Flushes any buffered writes to the operating system before closing.
825
828
  #
826
829
  # If the stream was opened by IO.popen and is also closed for reading, sets
827
- # global variable `$?` (child exit status).
830
+ # global variable <code>$?</code> (child exit status).
828
831
  #
829
832
  # IO.popen('ruby', 'r+') do |pipe|
830
833
  # puts pipe.closed?
@@ -990,8 +993,8 @@ class IO < Object
990
993
  # - fdatasync -> 0
991
994
  # -->
992
995
  # Immediately writes to disk all data buffered in the stream, via the operating
993
- # system's: `fdatasync(2)`, if supported, otherwise via `fsync(2)`, if
994
- # supported; otherwise raises an exception.
996
+ # system's: <code>fdatasync(2)</code>, if supported, otherwise via
997
+ # <code>fsync(2)</code>, if supported; otherwise raises an exception.
995
998
  #
996
999
  def fdatasync: () -> Integer?
997
1000
 
@@ -1026,7 +1029,7 @@ class IO < Object
1026
1029
  # - fsync -> 0
1027
1030
  # -->
1028
1031
  # Immediately writes to disk all data buffered in the stream, via the operating
1029
- # system's `fsync(2)`.
1032
+ # system's <code>fsync(2)</code>.
1030
1033
  #
1031
1034
  # Note this difference:
1032
1035
  #
@@ -1036,7 +1039,8 @@ class IO < Object
1036
1039
  # * IO#fsync: Ensures both that data is flushed from internal buffers, and
1037
1040
  # that data is written to disk.
1038
1041
  #
1039
- # Raises an exception if the operating system does not support `fsync(2)`.
1042
+ # Raises an exception if the operating system does not support
1043
+ # <code>fsync(2)</code>.
1040
1044
  #
1041
1045
  def fsync: () -> Integer?
1042
1046
 
@@ -1082,11 +1086,11 @@ class IO < Object
1082
1086
  # - gets(limit, chomp: false) -> string or nil
1083
1087
  # - gets(sep, limit, chomp: false) -> string or nil
1084
1088
  # -->
1085
- # Reads and returns a line from the stream; assigns the return value to `$_`.
1086
- # See [Line IO](rdoc-ref:IO@Line+IO).
1089
+ # Reads and returns a line from the stream; assigns the return value to
1090
+ # <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
1087
1091
  #
1088
1092
  # With no arguments given, returns the next line as determined by line separator
1089
- # `$/`, or `nil` if none:
1093
+ # <code>$/</code>, or `nil` if none:
1090
1094
  #
1091
1095
  # f = File.open('t.txt')
1092
1096
  # f.gets # => "First line\n"
@@ -1316,15 +1320,15 @@ class IO < Object
1316
1320
  # - print(*objects) -> nil
1317
1321
  # -->
1318
1322
  # Writes the given objects to the stream; returns `nil`. Appends the output
1319
- # record separator `$OUTPUT_RECORD_SEPARATOR` (`$\`), if it is not `nil`. See
1320
- # [Line IO](rdoc-ref:IO@Line+IO).
1323
+ # record separator <code>$OUTPUT_RECORD_SEPARATOR</code> (<code>$\</code>), if
1324
+ # it is not `nil`. See [Line IO](rdoc-ref:IO@Line+IO).
1321
1325
  #
1322
1326
  # With argument `objects` given, for each object:
1323
1327
  #
1324
1328
  # * Converts via its method `to_s` if not a string.
1325
1329
  # * Writes to the stream.
1326
1330
  # * If not the last object, writes the output field separator
1327
- # `$OUTPUT_FIELD_SEPARATOR` (`$,`) if it is not `nil`.
1331
+ # <code>$OUTPUT_FIELD_SEPARATOR</code> (<code>$,</code>) if it is not `nil`.
1328
1332
  #
1329
1333
  # With default separators:
1330
1334
  #
@@ -1356,8 +1360,8 @@ class IO < Object
1356
1360
  #
1357
1361
  # "0,0.0,0/1,0+0i,zero,zero\n"
1358
1362
  #
1359
- # With no argument given, writes the content of `$_` (which is usually the most
1360
- # recent user input):
1363
+ # With no argument given, writes the content of <code>$_</code> (which is
1364
+ # usually the most recent user input):
1361
1365
  #
1362
1366
  # f = File.open('t.tmp', 'w+')
1363
1367
  # gets # Sets $_ to the most recent user input.
@@ -1406,13 +1410,13 @@ class IO < Object
1406
1410
  # newline sequence. If called without arguments, writes a newline. See [Line
1407
1411
  # IO](rdoc-ref:IO@Line+IO).
1408
1412
  #
1409
- # Note that each added newline is the character `"\n"<//tt>, not the output
1410
- # record separator (<tt>$\`).
1413
+ # Note that each added newline is the character <code>"\n"<//tt>, not the output
1414
+ # record separator (<tt>$\</code>).
1411
1415
  #
1412
1416
  # Treatment for each object:
1413
1417
  #
1414
1418
  # * String: writes the string.
1415
- # * Neither string nor array: writes `object.to_s`.
1419
+ # * Neither string nor array: writes <code>object.to_s</code>.
1416
1420
  # * Array: writes each element of the array; arrays may be nested.
1417
1421
  #
1418
1422
  # To keep these examples brief, we define this helper method:
@@ -1519,7 +1523,7 @@ class IO < Object
1519
1523
  # * `out_string` given: encoding of `out_string` not modified.
1520
1524
  # * `out_string` not given: ASCII-8BIT is used.
1521
1525
  #
1522
- # **Without Argument `out_string`**
1526
+ # <strong>Without Argument `out_string`</strong>
1523
1527
  #
1524
1528
  # When argument `out_string` is omitted, the returned value is a new string:
1525
1529
  #
@@ -1534,7 +1538,7 @@ class IO < Object
1534
1538
  #
1535
1539
  # If `maxlen` is zero, returns an empty string.
1536
1540
  #
1537
- # ** With Argument `out_string`**
1541
+ # <strong> With Argument `out_string`</strong>
1538
1542
  #
1539
1543
  # When argument `out_string` is given, the returned value is `out_string`, whose
1540
1544
  # content is replaced:
@@ -1620,8 +1624,8 @@ class IO < Object
1620
1624
  #
1621
1625
  # By specifying a keyword argument *exception* to `false`, you can indicate that
1622
1626
  # read_nonblock should not raise an IO::WaitReadable exception, but return the
1623
- # symbol `:wait_readable` instead. At EOF, it will return nil instead of raising
1624
- # EOFError.
1627
+ # symbol <code>:wait_readable</code> instead. At EOF, it will return nil instead
1628
+ # of raising EOFError.
1625
1629
  #
1626
1630
  def read_nonblock: (int len, ?string buf, ?exception: true) -> String
1627
1631
  | (int len, ?string buf, exception: false) -> (String | :wait_readable | nil)
@@ -1681,11 +1685,11 @@ class IO < Object
1681
1685
  # - readlines(limit, chomp: false) -> array
1682
1686
  # - readlines(sep, limit, chomp: false) -> array
1683
1687
  # -->
1684
- # Reads and returns all remaining line from the stream; does not modify `$_`.
1685
- # See [Line IO](rdoc-ref:IO@Line+IO).
1688
+ # Reads and returns all remaining line from the stream; does not modify
1689
+ # <code>$_</code>. See [Line IO](rdoc-ref:IO@Line+IO).
1686
1690
  #
1687
- # With no arguments given, returns lines as determined by line separator `$/`,
1688
- # or `nil` if none:
1691
+ # With no arguments given, returns lines as determined by line separator
1692
+ # <code>$/</code>, or `nil` if none:
1689
1693
  #
1690
1694
  # f = File.new('t.txt')
1691
1695
  # f.readlines
@@ -1891,8 +1895,8 @@ class IO < Object
1891
1895
  # Seeks to the position given by integer `offset` (see
1892
1896
  # [Position](rdoc-ref:IO@Position)) and constant `whence`, which is one of:
1893
1897
  #
1894
- # * `:CUR` or `IO::SEEK_CUR`: Repositions the stream to its current position
1895
- # plus the given `offset`:
1898
+ # * <code>:CUR</code> or <code>IO::SEEK_CUR</code>: Repositions the stream to
1899
+ # its current position plus the given `offset`:
1896
1900
  #
1897
1901
  # f = File.open('t.txt')
1898
1902
  # f.tell # => 0
@@ -1902,8 +1906,8 @@ class IO < Object
1902
1906
  # f.tell # => 10
1903
1907
  # f.close
1904
1908
  #
1905
- # * `:END` or `IO::SEEK_END`: Repositions the stream to its end plus the given
1906
- # `offset`:
1909
+ # * <code>:END</code> or <code>IO::SEEK_END</code>: Repositions the stream to
1910
+ # its end plus the given `offset`:
1907
1911
  #
1908
1912
  # f = File.open('t.txt')
1909
1913
  # f.tell # => 0
@@ -1915,7 +1919,8 @@ class IO < Object
1915
1919
  # f.tell # => 12
1916
1920
  # f.close
1917
1921
  #
1918
- # * `:SET` or `IO:SEEK_SET`: Repositions the stream to the given `offset`:
1922
+ # * <code>:SET</code> or <code>IO:SEEK_SET</code>: Repositions the stream to
1923
+ # the given `offset`:
1919
1924
  #
1920
1925
  # f = File.open('t.txt')
1921
1926
  # f.tell # => 0
@@ -1943,7 +1948,7 @@ class IO < Object
1943
1948
  # Argument `int_enc`, if given, must be an Encoding object or a String with the
1944
1949
  # encoding name; it is assigned as the encoding for the internal string.
1945
1950
  #
1946
- # Argument `'ext_enc:int_enc'`, if given, is a string containing two
1951
+ # Argument <code>'ext_enc:int_enc'</code>, if given, is a string containing two
1947
1952
  # colon-separated encoding names; corresponding Encoding objects are assigned as
1948
1953
  # the external and internal encodings for the stream.
1949
1954
  #
@@ -2313,11 +2318,11 @@ class IO < Object
2313
2318
  #
2314
2319
  # On some platforms such as Windows, write_nonblock is not supported according
2315
2320
  # to the kind of the IO object. In such cases, write_nonblock raises
2316
- # `Errno::EBADF`.
2321
+ # <code>Errno::EBADF</code>.
2317
2322
  #
2318
2323
  # By specifying a keyword argument *exception* to `false`, you can indicate that
2319
2324
  # write_nonblock should not raise an IO::WaitWritable exception, but return the
2320
- # symbol `:wait_writable` instead.
2325
+ # symbol <code>:wait_writable</code> instead.
2321
2326
  #
2322
2327
  def write_nonblock: (_ToS s, ?exception: true) -> Integer
2323
2328
  | (_ToS s, exception: false) -> (Integer | :wait_writable | nil)
@@ -2329,10 +2334,6 @@ class IO < Object
2329
2334
  # Behaves like IO.read, except that the stream is opened in binary mode with
2330
2335
  # ASCII-8BIT encoding.
2331
2336
  #
2332
- # When called from class IO (but not subclasses of IO), this method has
2333
- # potential security vulnerabilities if called with untrusted input; see
2334
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2335
- #
2336
2337
  def self.binread: (path name, ?Integer? length, ?Integer offset) -> String
2337
2338
 
2338
2339
  # <!--
@@ -2342,10 +2343,6 @@ class IO < Object
2342
2343
  # Behaves like IO.write, except that the stream is opened in binary mode with
2343
2344
  # ASCII-8BIT encoding.
2344
2345
  #
2345
- # When called from class IO (but not subclasses of IO), this method has
2346
- # potential security vulnerabilities if called with untrusted input; see
2347
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2348
- #
2349
2346
  def self.binwrite: (path name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
2350
2347
 
2351
2348
  # <!--
@@ -2359,15 +2356,15 @@ class IO < Object
2359
2356
  #
2360
2357
  # * The path to a readable file, from which source data is to be read.
2361
2358
  # * An IO-like object, opened for reading and capable of responding to
2362
- # method `:readpartial` or method `:read`.
2359
+ # method <code>:readpartial</code> or method <code>:read</code>.
2363
2360
  #
2364
2361
  # * The given `dst` must be one of the following:
2365
2362
  #
2366
2363
  # * The path to a writable file, to which data is to be written.
2367
2364
  # * An IO-like object, opened for writing and capable of responding to
2368
- # method `:write`.
2365
+ # method <code>:write</code>.
2369
2366
  #
2370
- # The examples here use file `t.txt` as source:
2367
+ # The examples here use file <code>t.txt</code> as source:
2371
2368
  #
2372
2369
  # File.read('t.txt')
2373
2370
  # # => "First line\nSecond line\n\nThird line\nFourth line\n"
@@ -2417,8 +2414,8 @@ class IO < Object
2417
2414
  #
2418
2415
  # If a block is given, the stream is passed to the block (again, open for
2419
2416
  # reading, writing, or both); when the block exits, the stream is closed, the
2420
- # block's value is returned, and the global variable `$?` is set to the child's
2421
- # exit status.
2417
+ # block's value is returned, and the global variable <code>$?</code> is set to
2418
+ # the child's exit status.
2422
2419
  #
2423
2420
  # Optional argument `mode` may be any valid IO mode. See [Access
2424
2421
  # Modes](rdoc-ref:File@Access+Modes).
@@ -2449,8 +2446,8 @@ class IO < Object
2449
2446
  #
2450
2447
  # **Forked Process**
2451
2448
  #
2452
- # When argument `cmd` is the 1-character string `'-'`, causes the process to
2453
- # fork:
2449
+ # When argument `cmd` is the 1-character string <code>'-'</code>, causes the
2450
+ # process to fork:
2454
2451
  # IO.popen('-') do |pipe|
2455
2452
  # if pipe
2456
2453
  # $stderr.puts "In parent, child pid is #{pipe.pid}\n"
@@ -2468,8 +2465,8 @@ class IO < Object
2468
2465
  #
2469
2466
  # **Shell Subprocess**
2470
2467
  #
2471
- # When argument `cmd` is a single string (but not `'-'`), the program named
2472
- # `cmd` is run as a shell command:
2468
+ # When argument `cmd` is a single string (but not <code>'-'</code>), the program
2469
+ # named `cmd` is run as a shell command:
2473
2470
  #
2474
2471
  # IO.popen('uname') do |pipe|
2475
2472
  # pipe.readlines
@@ -2493,8 +2490,8 @@ class IO < Object
2493
2490
  #
2494
2491
  # **Program Subprocess**
2495
2492
  #
2496
- # When argument `cmd` is an array of strings, the program named `cmd[0]` is run
2497
- # with all elements of `cmd` as its arguments:
2493
+ # When argument `cmd` is an array of strings, the program named
2494
+ # <code>cmd[0]</code> is run with all elements of `cmd` as its arguments:
2498
2495
  #
2499
2496
  # IO.popen(['du', '..', '.']) do |pipe|
2500
2497
  # $stderr.puts pipe.readlines.size
@@ -2504,18 +2501,19 @@ class IO < Object
2504
2501
  #
2505
2502
  # 1111
2506
2503
  #
2507
- # **Program Subprocess with `argv0`**
2504
+ # <strong>Program Subprocess with `argv0`</strong>
2508
2505
  #
2509
2506
  # When argument `cmd` is an array whose first element is a 2-element string
2510
2507
  # array and whose remaining elements (if any) are strings:
2511
2508
  #
2512
- # * `cmd[0][0]` (the first string in the nested array) is the name of a
2513
- # program that is run.
2514
- # * `cmd[0][1]` (the second string in the nested array) is set as the
2515
- # program's `argv[0]`.
2516
- # * `cmd[1..-1]` (the strings in the outer array) are the program's arguments.
2509
+ # * <code>cmd[0][0]</code> (the first string in the nested array) is the name
2510
+ # of a program that is run.
2511
+ # * <code>cmd[0][1]</code> (the second string in the nested array) is set as
2512
+ # the program's <code>argv[0]</code>.
2513
+ # * <code>cmd[1..-1]</code> (the strings in the outer array) are the program's
2514
+ # arguments.
2517
2515
  #
2518
- # Example (sets `$0` to 'foo'):
2516
+ # Example (sets <code>$0</code> to 'foo'):
2519
2517
  #
2520
2518
  # IO.popen([['/bin/sh', 'foo'], '-c', 'echo $0']).read # => "foo\n"
2521
2519
  #
@@ -2582,10 +2580,6 @@ class IO < Object
2582
2580
  # -->
2583
2581
  # Calls the block with each successive line read from the stream.
2584
2582
  #
2585
- # When called from class IO (but not subclasses of IO), this method has
2586
- # potential security vulnerabilities if called with untrusted input; see
2587
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2588
- #
2589
2583
  # The first argument must be a string that is the path to a file.
2590
2584
  #
2591
2585
  # With only argument `path` given, parses lines from the file at the given
@@ -2707,8 +2701,8 @@ class IO < Object
2707
2701
  # In the example below, the two processes close the ends of the pipe that they
2708
2702
  # are not using. This is not just a cosmetic nicety. The read end of a pipe will
2709
2703
  # not generate an end of file condition if there are any writers with the pipe
2710
- # still open. In the case of the parent process, the `rd.read` will never return
2711
- # if it does not first issue a `wr.close`:
2704
+ # still open. In the case of the parent process, the <code>rd.read</code> will
2705
+ # never return if it does not first issue a <code>wr.close</code>:
2712
2706
  #
2713
2707
  # rd, wr = IO.pipe
2714
2708
  #
@@ -2724,7 +2718,7 @@ class IO < Object
2724
2718
  # wr.close
2725
2719
  # end
2726
2720
  #
2727
- # *produces:*
2721
+ # <em>produces:</em>
2728
2722
  #
2729
2723
  # Sending message to parent
2730
2724
  # Parent got: <Hi Dad>
@@ -2739,10 +2733,6 @@ class IO < Object
2739
2733
  # Opens the stream, reads and returns some or all of its content, and closes the
2740
2734
  # stream; returns `nil` if no bytes were read.
2741
2735
  #
2742
- # When called from class IO (but not subclasses of IO), this method has
2743
- # potential security vulnerabilities if called with untrusted input; see
2744
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2745
- #
2746
2736
  # The first argument must be a string that is the path to a file.
2747
2737
  #
2748
2738
  # With only argument `path` given, reads in text mode and returns the entire
@@ -2782,10 +2772,6 @@ class IO < Object
2782
2772
  # -->
2783
2773
  # Returns an array of all lines read from the stream.
2784
2774
  #
2785
- # When called from class IO (but not subclasses of IO), this method has
2786
- # potential security vulnerabilities if called with untrusted input; see
2787
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
2788
- #
2789
2775
  # The first argument must be a string that is the path to a file.
2790
2776
  #
2791
2777
  # With only argument `path` given, parses lines from the file at the given
@@ -2841,8 +2827,9 @@ class IO < Object
2841
2827
  # IO objects.
2842
2828
  #
2843
2829
  # Argument `timeout` is a numeric value (such as integer or float) timeout
2844
- # interval in seconds. `timeout` can also be `nil` or `Float::INFINITY`. `nil`
2845
- # and `Float::INFINITY` means no timeout.
2830
+ # interval in seconds. `timeout` can also be `nil` or
2831
+ # <code>Float::INFINITY</code>. `nil` and <code>Float::INFINITY</code> means no
2832
+ # timeout.
2846
2833
  #
2847
2834
  # The method monitors the IO objects given in all three arrays, waiting for some
2848
2835
  # to be ready; returns a 3-element array whose elements are:
@@ -2917,8 +2904,8 @@ class IO < Object
2917
2904
  #
2918
2905
  # The writability notified by select(2) doesn't show how many bytes are
2919
2906
  # writable. IO#write method blocks until given whole string is written. So,
2920
- # `IO#write(two or more bytes)` can block after writability is notified by
2921
- # IO.select. IO#write_nonblock is required to avoid the blocking.
2907
+ # <code>IO#write(two or more bytes)</code> can block after writability is
2908
+ # notified by IO.select. IO#write_nonblock is required to avoid the blocking.
2922
2909
  #
2923
2910
  # Blocking write (#write) can be emulated using #write_nonblock and IO.select as
2924
2911
  # follows: IO::WaitReadable should also be rescued for SSL renegotiation in
@@ -3007,10 +2994,6 @@ class IO < Object
3007
2994
  # Opens the stream, writes the given `data` to it, and closes the stream;
3008
2995
  # returns the number of bytes written.
3009
2996
  #
3010
- # When called from class IO (but not subclasses of IO), this method has
3011
- # potential security vulnerabilities if called with untrusted input; see
3012
- # [Command Injection](rdoc-ref:security/command_injection.rdoc).
3013
- #
3014
2997
  # The first argument must be a string that is the path to a file.
3015
2998
  #
3016
2999
  # With only argument `path` given, writes the given `data` to the file at that
@@ -3033,7 +3016,7 @@ class IO < Object
3033
3016
  # File.read('t.tmp') # => "ab012f"
3034
3017
  #
3035
3018
  # If `offset` is outside the file content, the file is padded with null
3036
- # characters `"\u0000"`:
3019
+ # characters <code>"\u0000"</code>:
3037
3020
  #
3038
3021
  # IO.write('t.tmp', 'xyz', 10) # => 3
3039
3022
  # File.read('t.tmp') # => "ab012f\u0000\u0000\u0000\u0000xyz"
@@ -3072,7 +3055,8 @@ class IO < Object
3072
3055
  # Calls the block with each remaining line read from the stream; returns `self`.
3073
3056
  # Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
3074
3057
  #
3075
- # With no arguments given, reads lines as determined by line separator `$/`:
3058
+ # With no arguments given, reads lines as determined by line separator
3059
+ # <code>$/</code>:
3076
3060
  #
3077
3061
  # f = File.new('t.txt')
3078
3062
  # f.each_line {|line| p line }
@@ -3174,7 +3158,8 @@ class IO < Object
3174
3158
  # Calls the block with each remaining line read from the stream; returns `self`.
3175
3159
  # Does nothing if already at end-of-stream; See [Line IO](rdoc-ref:IO@Line+IO).
3176
3160
  #
3177
- # With no arguments given, reads lines as determined by line separator `$/`:
3161
+ # With no arguments given, reads lines as determined by line separator
3162
+ # <code>$/</code>:
3178
3163
  #
3179
3164
  # f = File.new('t.txt')
3180
3165
  # f.each_line {|line| p line }