rbs 3.10.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 (267) 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 +7 -5
  5. data/.github/workflows/comments.yml +2 -2
  6. data/.github/workflows/dependabot.yml +2 -2
  7. data/.github/workflows/ruby.yml +16 -26
  8. data/.github/workflows/rust.yml +95 -0
  9. data/.github/workflows/typecheck.yml +1 -1
  10. data/.github/workflows/windows.yml +2 -2
  11. data/.rubocop.yml +2 -2
  12. data/.vscode/extensions.json +5 -0
  13. data/.vscode/settings.json +19 -0
  14. data/CHANGELOG.md +202 -2
  15. data/Rakefile +9 -23
  16. data/Steepfile +2 -0
  17. data/config.yml +457 -13
  18. data/core/array.rbs +218 -188
  19. data/core/basic_object.rbs +9 -8
  20. data/core/binding.rbs +0 -2
  21. data/core/builtin.rbs +2 -2
  22. data/core/class.rbs +6 -5
  23. data/core/comparable.rbs +45 -31
  24. data/core/complex.rbs +66 -55
  25. data/core/dir.rbs +57 -45
  26. data/core/encoding.rbs +6 -6
  27. data/core/enumerable.rbs +105 -91
  28. data/core/enumerator/arithmetic_sequence.rbs +70 -0
  29. data/core/enumerator.rbs +24 -3
  30. data/core/errno.rbs +3 -2
  31. data/core/errors.rbs +31 -29
  32. data/core/exception.rbs +12 -12
  33. data/core/fiber.rbs +47 -36
  34. data/core/file.rbs +242 -169
  35. data/core/file_test.rbs +2 -2
  36. data/core/float.rbs +42 -68
  37. data/core/gc.rbs +78 -70
  38. data/core/hash.rbs +70 -60
  39. data/core/integer.rbs +32 -75
  40. data/core/io/buffer.rbs +36 -36
  41. data/core/io/wait.rbs +7 -7
  42. data/core/io.rbs +192 -146
  43. data/core/kernel.rbs +198 -147
  44. data/core/marshal.rbs +3 -3
  45. data/core/match_data.rbs +14 -12
  46. data/core/math.rbs +69 -67
  47. data/core/method.rbs +6 -8
  48. data/core/module.rbs +148 -88
  49. data/core/nil_class.rbs +4 -3
  50. data/core/numeric.rbs +53 -50
  51. data/core/object.rbs +6 -8
  52. data/core/object_space.rbs +11 -10
  53. data/core/pathname.rbs +131 -81
  54. data/core/proc.rbs +65 -34
  55. data/core/process.rbs +221 -201
  56. data/core/ractor.rbs +15 -11
  57. data/core/random.rbs +21 -3
  58. data/core/range.rbs +152 -49
  59. data/core/rational.rbs +5 -56
  60. data/core/rbs/unnamed/argf.rbs +58 -51
  61. data/core/rbs/unnamed/env_class.rbs +18 -13
  62. data/core/rbs/unnamed/main_class.rbs +123 -0
  63. data/core/rbs/unnamed/random.rbs +7 -116
  64. data/core/regexp.rbs +236 -197
  65. data/core/ruby.rbs +1 -1
  66. data/core/ruby_vm.rbs +32 -30
  67. data/core/rubygems/config_file.rbs +5 -5
  68. data/core/rubygems/errors.rbs +1 -1
  69. data/core/rubygems/requirement.rbs +5 -5
  70. data/core/rubygems/rubygems.rbs +5 -3
  71. data/core/set.rbs +17 -16
  72. data/core/signal.rbs +2 -2
  73. data/core/string.rbs +318 -298
  74. data/core/struct.rbs +26 -25
  75. data/core/symbol.rbs +25 -24
  76. data/core/thread.rbs +40 -41
  77. data/core/time.rbs +47 -42
  78. data/core/trace_point.rbs +34 -31
  79. data/core/true_class.rbs +2 -2
  80. data/core/unbound_method.rbs +10 -10
  81. data/core/warning.rbs +7 -7
  82. data/docs/collection.md +1 -1
  83. data/docs/config.md +171 -0
  84. data/docs/inline.md +576 -0
  85. data/docs/syntax.md +46 -16
  86. data/docs/type_fingerprint.md +21 -0
  87. data/exe/rbs +1 -1
  88. data/ext/rbs_extension/ast_translation.c +595 -98
  89. data/ext/rbs_extension/class_constants.c +30 -0
  90. data/ext/rbs_extension/class_constants.h +15 -0
  91. data/ext/rbs_extension/legacy_location.c +30 -53
  92. data/ext/rbs_extension/legacy_location.h +37 -0
  93. data/ext/rbs_extension/main.c +125 -24
  94. data/include/rbs/ast.h +485 -150
  95. data/include/rbs/lexer.h +11 -4
  96. data/include/rbs/location.h +25 -44
  97. data/include/rbs/parser.h +20 -2
  98. data/include/rbs/util/rbs_constant_pool.h +0 -3
  99. data/include/rbs.h +8 -0
  100. data/lib/rbs/ast/annotation.rb +1 -1
  101. data/lib/rbs/ast/comment.rb +1 -1
  102. data/lib/rbs/ast/declarations.rb +10 -10
  103. data/lib/rbs/ast/members.rb +14 -14
  104. data/lib/rbs/ast/ruby/annotations.rb +409 -0
  105. data/lib/rbs/ast/ruby/comment_block.rb +245 -0
  106. data/lib/rbs/ast/ruby/declarations.rb +281 -0
  107. data/lib/rbs/ast/ruby/helpers/constant_helper.rb +28 -0
  108. data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
  109. data/lib/rbs/ast/ruby/members.rb +723 -0
  110. data/lib/rbs/ast/type_param.rb +24 -4
  111. data/lib/rbs/buffer.rb +105 -20
  112. data/lib/rbs/cli/diff.rb +16 -15
  113. data/lib/rbs/cli/validate.rb +62 -125
  114. data/lib/rbs/cli.rb +55 -23
  115. data/lib/rbs/collection/config/lockfile_generator.rb +8 -4
  116. data/lib/rbs/collection/sources/git.rb +1 -0
  117. data/lib/rbs/collection.rb +0 -1
  118. data/lib/rbs/definition.rb +6 -1
  119. data/lib/rbs/definition_builder/ancestor_builder.rb +119 -63
  120. data/lib/rbs/definition_builder/method_builder.rb +65 -30
  121. data/lib/rbs/definition_builder.rb +177 -20
  122. data/lib/rbs/diff.rb +7 -1
  123. data/lib/rbs/environment/class_entry.rb +69 -0
  124. data/lib/rbs/environment/module_entry.rb +66 -0
  125. data/lib/rbs/environment.rb +338 -155
  126. data/lib/rbs/environment_loader.rb +2 -2
  127. data/lib/rbs/errors.rb +30 -20
  128. data/lib/rbs/inline_parser/comment_association.rb +117 -0
  129. data/lib/rbs/inline_parser.rb +542 -0
  130. data/lib/rbs/location_aux.rb +36 -4
  131. data/lib/rbs/locator.rb +5 -1
  132. data/lib/rbs/method_type.rb +5 -3
  133. data/lib/rbs/namespace.rb +0 -7
  134. data/lib/rbs/parser_aux.rb +31 -8
  135. data/lib/rbs/prototype/helpers.rb +57 -0
  136. data/lib/rbs/prototype/rb.rb +3 -28
  137. data/lib/rbs/prototype/rbi.rb +3 -20
  138. data/lib/rbs/prototype/runtime.rb +10 -2
  139. data/lib/rbs/resolver/type_name_resolver.rb +0 -8
  140. data/lib/rbs/source.rb +99 -0
  141. data/lib/rbs/subtractor.rb +4 -3
  142. data/lib/rbs/test/type_check.rb +5 -2
  143. data/lib/rbs/type_name.rb +1 -8
  144. data/lib/rbs/types.rb +88 -78
  145. data/lib/rbs/unit_test/convertibles.rb +1 -0
  146. data/lib/rbs/unit_test/type_assertions.rb +35 -8
  147. data/lib/rbs/validator.rb +2 -2
  148. data/lib/rbs/version.rb +1 -1
  149. data/lib/rbs.rb +12 -1
  150. data/rbs.gemspec +3 -2
  151. data/rust/.gitignore +1 -0
  152. data/rust/Cargo.lock +378 -0
  153. data/rust/Cargo.toml +7 -0
  154. data/rust/ruby-rbs/Cargo.toml +22 -0
  155. data/rust/ruby-rbs/build.rs +764 -0
  156. data/rust/ruby-rbs/examples/locations.rs +60 -0
  157. data/rust/ruby-rbs/src/lib.rs +1 -0
  158. data/rust/ruby-rbs/src/node/mod.rs +742 -0
  159. data/rust/ruby-rbs/tests/sanity.rs +47 -0
  160. data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
  161. data/rust/ruby-rbs-sys/Cargo.toml +23 -0
  162. data/rust/ruby-rbs-sys/build.rs +204 -0
  163. data/rust/ruby-rbs-sys/src/lib.rs +50 -0
  164. data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
  165. data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
  166. data/rust/ruby-rbs-sys/wrapper.h +1 -0
  167. data/schema/typeParam.json +17 -1
  168. data/sig/ancestor_builder.rbs +1 -1
  169. data/sig/ast/ruby/annotations.rbs +421 -0
  170. data/sig/ast/ruby/comment_block.rbs +127 -0
  171. data/sig/ast/ruby/declarations.rbs +158 -0
  172. data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
  173. data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
  174. data/sig/ast/ruby/members.rbs +178 -0
  175. data/sig/buffer.rbs +63 -5
  176. data/sig/cli/diff.rbs +5 -11
  177. data/sig/cli/validate.rbs +12 -8
  178. data/sig/cli.rbs +18 -18
  179. data/sig/definition.rbs +6 -0
  180. data/sig/definition_builder.rbs +3 -1
  181. data/sig/environment/class_entry.rbs +50 -0
  182. data/sig/environment/module_entry.rbs +50 -0
  183. data/sig/environment.rbs +37 -81
  184. data/sig/errors.rbs +26 -20
  185. data/sig/inline_parser/comment_association.rbs +71 -0
  186. data/sig/inline_parser.rbs +124 -0
  187. data/sig/location.rbs +32 -7
  188. data/sig/locator.rbs +0 -2
  189. data/sig/method_builder.rbs +9 -4
  190. data/sig/namespace.rbs +0 -5
  191. data/sig/parser.rbs +47 -13
  192. data/sig/prototype/helpers.rbs +2 -0
  193. data/sig/resolver/type_name_resolver.rbs +0 -3
  194. data/sig/source.rbs +48 -0
  195. data/sig/type_param.rbs +13 -8
  196. data/sig/typename.rbs +0 -5
  197. data/sig/types.rbs +6 -7
  198. data/sig/unit_test/spy.rbs +0 -8
  199. data/sig/unit_test/type_assertions.rbs +11 -0
  200. data/src/ast.c +491 -143
  201. data/src/lexer.c +1552 -1314
  202. data/src/lexer.re +7 -0
  203. data/src/lexstate.c +8 -1
  204. data/src/location.c +8 -48
  205. data/src/parser.c +1107 -409
  206. data/src/util/rbs_constant_pool.c +0 -4
  207. data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
  208. data/stdlib/cgi-escape/0/escape.rbs +4 -4
  209. data/stdlib/coverage/0/coverage.rbs +4 -3
  210. data/stdlib/date/0/date.rbs +33 -28
  211. data/stdlib/date/0/date_time.rbs +24 -23
  212. data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
  213. data/stdlib/digest/0/digest.rbs +110 -0
  214. data/stdlib/erb/0/erb.rbs +64 -53
  215. data/stdlib/etc/0/etc.rbs +55 -50
  216. data/stdlib/fileutils/0/fileutils.rbs +140 -126
  217. data/stdlib/forwardable/0/forwardable.rbs +10 -10
  218. data/stdlib/io-console/0/io-console.rbs +2 -2
  219. data/stdlib/json/0/json.rbs +158 -131
  220. data/stdlib/monitor/0/monitor.rbs +3 -3
  221. data/stdlib/net-http/0/net-http.rbs +159 -134
  222. data/stdlib/objspace/0/objspace.rbs +8 -30
  223. data/stdlib/open-uri/0/open-uri.rbs +8 -8
  224. data/stdlib/open3/0/open3.rbs +469 -10
  225. data/stdlib/openssl/0/openssl.rbs +144 -129
  226. data/stdlib/optparse/0/optparse.rbs +23 -14
  227. data/stdlib/pathname/0/pathname.rbs +2 -2
  228. data/stdlib/pp/0/pp.rbs +9 -8
  229. data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
  230. data/stdlib/pstore/0/pstore.rbs +35 -30
  231. data/stdlib/psych/0/psych.rbs +62 -9
  232. data/stdlib/psych/0/store.rbs +2 -4
  233. data/stdlib/pty/0/pty.rbs +9 -6
  234. data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
  235. data/stdlib/rdoc/0/code_object.rbs +2 -1
  236. data/stdlib/rdoc/0/parser.rbs +1 -1
  237. data/stdlib/rdoc/0/store.rbs +1 -1
  238. data/stdlib/ripper/0/ripper.rbs +20 -17
  239. data/stdlib/securerandom/0/manifest.yaml +2 -0
  240. data/stdlib/securerandom/0/securerandom.rbs +7 -20
  241. data/stdlib/shellwords/0/shellwords.rbs +2 -2
  242. data/stdlib/socket/0/addrinfo.rbs +9 -9
  243. data/stdlib/socket/0/basic_socket.rbs +3 -3
  244. data/stdlib/socket/0/ip_socket.rbs +10 -8
  245. data/stdlib/socket/0/socket.rbs +10 -9
  246. data/stdlib/socket/0/tcp_server.rbs +1 -1
  247. data/stdlib/socket/0/tcp_socket.rbs +1 -1
  248. data/stdlib/socket/0/udp_socket.rbs +1 -1
  249. data/stdlib/socket/0/unix_server.rbs +1 -1
  250. data/stdlib/stringio/0/stringio.rbs +55 -54
  251. data/stdlib/strscan/0/string_scanner.rbs +46 -44
  252. data/stdlib/tempfile/0/tempfile.rbs +24 -20
  253. data/stdlib/time/0/time.rbs +7 -5
  254. data/stdlib/tsort/0/tsort.rbs +7 -6
  255. data/stdlib/uri/0/common.rbs +31 -18
  256. data/stdlib/uri/0/file.rbs +2 -2
  257. data/stdlib/uri/0/generic.rbs +9 -2
  258. data/stdlib/uri/0/http.rbs +2 -2
  259. data/stdlib/uri/0/ldap.rbs +2 -2
  260. data/stdlib/uri/0/mailto.rbs +3 -3
  261. data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
  262. data/stdlib/zlib/0/deflate.rbs +4 -3
  263. data/stdlib/zlib/0/gzip_reader.rbs +6 -6
  264. data/stdlib/zlib/0/gzip_writer.rbs +14 -12
  265. data/stdlib/zlib/0/inflate.rbs +1 -1
  266. data/stdlib/zlib/0/need_dict.rbs +1 -1
  267. metadata +66 -3
data/core/file.rbs CHANGED
@@ -2,7 +2,7 @@
2
2
  # A File object is a representation of a file in the underlying platform.
3
3
  #
4
4
  # Class File extends module FileTest, supporting such singleton methods as
5
- # `File.exist?`.
5
+ # <code>File.exist?</code>.
6
6
  #
7
7
  # ## About the Examples
8
8
  #
@@ -93,8 +93,8 @@
93
93
  # | 'a+' | Anywhere | 0 | End only | End |
94
94
  # |------|----------|----------|----------|-----------|
95
95
  #
96
- # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
97
- # (exception raised).
96
+ # Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
97
+ # non-existent file (exception raised).
98
98
  #
99
99
  # In the tables:
100
100
  #
@@ -108,7 +108,7 @@
108
108
  #
109
109
  # ##### Read/Write Modes for Existing File
110
110
  #
111
- # * `'r'`:
111
+ # * <code>'r'</code>:
112
112
  #
113
113
  # * File is not initially truncated:
114
114
  #
@@ -137,7 +137,7 @@
137
137
  #
138
138
  # f.write('foo') # Raises IOError.
139
139
  #
140
- # * `'w'`:
140
+ # * <code>'w'</code>:
141
141
  #
142
142
  # * File is initially truncated:
143
143
  #
@@ -191,7 +191,7 @@
191
191
  #
192
192
  # f.read # Raises IOError.
193
193
  #
194
- # * `'a'`:
194
+ # * <code>'a'</code>:
195
195
  #
196
196
  # * File is not initially truncated:
197
197
  #
@@ -223,7 +223,7 @@
223
223
  #
224
224
  # f.read # Raises IOError.
225
225
  #
226
- # * `'r+'`:
226
+ # * <code>'r+'</code>:
227
227
  #
228
228
  # * File is not initially truncated:
229
229
  #
@@ -278,7 +278,7 @@
278
278
  # File.read(path)
279
279
  # # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
280
280
  #
281
- # * `'a+'`:
281
+ # * <code>'a+'</code>:
282
282
  #
283
283
  # * File is not initially truncated:
284
284
  #
@@ -319,10 +319,10 @@
319
319
  #
320
320
  # ##### Read/Write Modes for File To Be Created
321
321
  #
322
- # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
323
- # (exception raised).
322
+ # Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
323
+ # non-existent file (exception raised).
324
324
  #
325
- # * `'w'`:
325
+ # * <code>'w'</code>:
326
326
  #
327
327
  # * File's initial write position is 0:
328
328
  #
@@ -372,7 +372,7 @@
372
372
  #
373
373
  # f.read # Raises IOError.
374
374
  #
375
- # * `'a'`:
375
+ # * <code>'a'</code>:
376
376
  #
377
377
  # * File's initial write position is 0:
378
378
  #
@@ -399,7 +399,7 @@
399
399
  #
400
400
  # f.read # Raises IOError.
401
401
  #
402
- # * `'w+'`:
402
+ # * <code>'w+'</code>:
403
403
  #
404
404
  # * File's initial position is 0:
405
405
  #
@@ -463,7 +463,7 @@
463
463
  # f.read
464
464
  # # => "bah"
465
465
  #
466
- # * `'a+'`:
466
+ # * <code>'a+'</code>:
467
467
  #
468
468
  # * File's initial write position is 0:
469
469
  #
@@ -506,12 +506,13 @@
506
506
  # To specify whether data is to be treated as text or as binary data, either of
507
507
  # the following may be suffixed to any of the string read/write modes above:
508
508
  #
509
- # * `'t'`: Text data; sets the default external encoding to `Encoding::UTF_8`;
510
- # on Windows, enables conversion between EOL and CRLF and enables
511
- # interpreting `0x1A` as an end-of-file marker.
512
- # * `'b'`: Binary data; sets the default external encoding to
513
- # `Encoding::ASCII_8BIT`; on Windows, suppresses conversion between EOL and
514
- # CRLF and disables interpreting `0x1A` as an end-of-file marker.
509
+ # * <code>'t'</code>: Text data; sets the default external encoding to
510
+ # <code>Encoding::UTF_8</code>; on Windows, enables conversion between EOL
511
+ # and CRLF and enables interpreting `0x1A` as an end-of-file marker.
512
+ # * <code>'b'</code>: Binary data; sets the default external encoding to
513
+ # <code>Encoding::ASCII_8BIT</code>; on Windows, suppresses conversion
514
+ # between EOL and CRLF and disables interpreting `0x1A` as an end-of-file
515
+ # marker.
515
516
  #
516
517
  # If neither is given, the stream defaults to text data.
517
518
  #
@@ -530,8 +531,8 @@
530
531
  #
531
532
  # The following may be suffixed to any writable string mode above:
532
533
  #
533
- # * `'x'`: Creates the file if it does not exist; raises an exception if the
534
- # file exists.
534
+ # * <code>'x'</code>: Creates the file if it does not exist; raises an
535
+ # exception if the file exists.
535
536
  #
536
537
  # Example:
537
538
  #
@@ -546,12 +547,12 @@
546
547
  # ### Integer Access Modes
547
548
  #
548
549
  # When mode is an integer it must be one or more of the following constants,
549
- # which may be combined by the bitwise OR operator `|`:
550
+ # which may be combined by the bitwise OR operator <code>|</code>:
550
551
  #
551
- # * `File::RDONLY`: Open for reading only.
552
- # * `File::WRONLY`: Open for writing only.
553
- # * `File::RDWR`: Open for reading and writing.
554
- # * `File::APPEND`: Open for appending only.
552
+ # * <code>File::RDONLY</code>: Open for reading only.
553
+ # * <code>File::WRONLY</code>: Open for writing only.
554
+ # * <code>File::RDWR</code>: Open for reading and writing.
555
+ # * <code>File::APPEND</code>: Open for appending only.
555
556
  #
556
557
  # Examples:
557
558
  #
@@ -565,19 +566,19 @@
565
566
  #
566
567
  # These constants may also be ORed into the integer mode:
567
568
  #
568
- # * `File::CREAT`: Create file if it does not exist.
569
- # * `File::EXCL`: Raise an exception if `File::CREAT` is given and the file
570
- # exists.
569
+ # * <code>File::CREAT</code>: Create file if it does not exist.
570
+ # * <code>File::EXCL</code>: Raise an exception if <code>File::CREAT</code> is
571
+ # given and the file exists.
571
572
  #
572
573
  # ### Data Mode Specified as an Integer
573
574
  #
574
575
  # Data mode cannot be specified as an integer. When the stream access mode is
575
576
  # given as an integer, the data mode is always text, never binary.
576
577
  #
577
- # Note that although there is a constant `File::BINARY`, setting its value in an
578
- # integer stream mode has no effect; this is because, as documented in
579
- # File::Constants, the `File::BINARY` value disables line code conversion, but
580
- # does not change the external encoding.
578
+ # Note that although there is a constant <code>File::BINARY</code>, setting its
579
+ # value in an integer stream mode has no effect; this is because, as documented
580
+ # in File::Constants, the <code>File::BINARY</code> value disables line code
581
+ # conversion, but does not change the external encoding.
581
582
  #
582
583
  # ### Encodings
583
584
  #
@@ -608,14 +609,14 @@
608
609
  # internal to external encoding. For further details about transcoding input and
609
610
  # output, see [Encodings](rdoc-ref:encodings.rdoc@Encodings).
610
611
  #
611
- # If the external encoding is `'BOM|UTF-8'`, `'BOM|UTF-16LE'` or
612
- # `'BOM|UTF16-BE'`, Ruby checks for a Unicode BOM in the input document to help
613
- # determine the encoding. For UTF-16 encodings the file open mode must be
614
- # binary. If the BOM is found, it is stripped and the external encoding from the
615
- # BOM is used.
612
+ # If the external encoding is <code>'BOM|UTF-8'</code>,
613
+ # <code>'BOM|UTF-16LE'</code> or <code>'BOM|UTF16-BE'</code>, Ruby checks for a
614
+ # Unicode BOM in the input document to help determine the encoding. For UTF-16
615
+ # encodings the file open mode must be binary. If the BOM is found, it is
616
+ # stripped and the external encoding from the BOM is used.
616
617
  #
617
- # Note that the BOM-style encoding option is case insensitive, so `'bom|utf-8'`
618
- # is also valid.
618
+ # Note that the BOM-style encoding option is case insensitive, so
619
+ # <code>'bom|utf-8'</code> is also valid.
619
620
  #
620
621
  # ## File Permissions
621
622
  #
@@ -669,7 +670,7 @@
669
670
  #
670
671
  # Various constants for use in File and IO methods may be found in module
671
672
  # File::Constants; an array of their names is returned by
672
- # `File::Constants.constants`.
673
+ # <code>File::Constants.constants</code>.
673
674
  #
674
675
  # ## What's Here
675
676
  #
@@ -705,7 +706,7 @@
705
706
  # * ::basename: Returns the last component of the given file path.
706
707
  # * ::dirname: Returns all but the last component of the given file path.
707
708
  # * ::expand_path: Returns the absolute file path for the given path,
708
- # expanding `~` for a home directory.
709
+ # expanding <code>~</code> for a home directory.
709
710
  # * ::extname: Returns the file extension for the given file path.
710
711
  # * ::fnmatch? (aliased as ::fnmatch): Returns whether the given file path
711
712
  # matches the given pattern.
@@ -847,7 +848,30 @@ class File < IO
847
848
  # * [Open Options](rdoc-ref:IO@Open+Options).
848
849
  # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
849
850
  #
850
- def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> void
851
+ def initialize: (
852
+ path | int file_name,
853
+ ?string | int mode,
854
+ ?int perm,
855
+ # open options
856
+ ?mode: Integer | String,
857
+ ?flags: Integer,
858
+ ?external_encoding: encoding,
859
+ ?internal_encoding: encoding,
860
+ ?encoding: encoding,
861
+ ?textmode: boolish,
862
+ ?binmode: boolish,
863
+ ?autoclose: boolish,
864
+ ?path: path,
865
+ # encoding options
866
+ ?invalid: :replace | nil,
867
+ ?undef: :replace | nil,
868
+ ?replace: String | nil,
869
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
870
+ ?xml: :text | :attr | nil,
871
+ ?cr_newline: bool,
872
+ ?crlf_newline: bool,
873
+ ?universal_newline: bool
874
+ ) -> void
851
875
 
852
876
  # <!--
853
877
  # rdoc-file=file.c
@@ -856,12 +880,12 @@ class File < IO
856
880
  # Converts a pathname to an absolute pathname. Relative paths are referenced
857
881
  # from the current working directory of the process unless *dir_string* is
858
882
  # given, in which case it will be used as the starting point. If the given
859
- # pathname starts with a ```~`'' it is NOT expanded, it is treated as a normal
860
- # directory name.
883
+ # pathname starts with a ``<code>~</code>'' it is NOT expanded, it is treated as
884
+ # a normal directory name.
861
885
  #
862
886
  # File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
863
887
  #
864
- def self.absolute_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
888
+ def self.absolute_path: (path file_name, ?path dir_string) -> String
865
889
 
866
890
  # <!--
867
891
  # rdoc-file=file.c
@@ -871,7 +895,7 @@ class File < IO
871
895
  #
872
896
  # File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
873
897
  #
874
- def self.absolute_path?: (string | _ToPath file_name) -> bool
898
+ def self.absolute_path?: (path file_name) -> bool
875
899
 
876
900
  # <!--
877
901
  # rdoc-file=file.c
@@ -883,7 +907,7 @@ class File < IO
883
907
  #
884
908
  # File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
885
909
  #
886
- def self.atime: (string | _ToPath | IO file_name) -> Time
910
+ def self.atime: (path | IO file_name) -> Time
887
911
 
888
912
  # <!--
889
913
  # rdoc-file=file.c
@@ -899,7 +923,7 @@ class File < IO
899
923
  # File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
900
924
  # File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
901
925
  #
902
- def self.basename: (string | _ToPath file_name, ?string suffix) -> String
926
+ def self.basename: (path file_name, ?string suffix) -> String
903
927
 
904
928
  # <!--
905
929
  # rdoc-file=file.c
@@ -913,7 +937,7 @@ class File < IO
913
937
  #
914
938
  # If the platform doesn't have birthtime, raises NotImplementedError.
915
939
  #
916
- def self.birthtime: (string | _ToPath | IO file_name) -> Time
940
+ def self.birthtime: (path | IO file_name) -> Time
917
941
 
918
942
  # <!--
919
943
  # rdoc-file=file.c
@@ -924,7 +948,7 @@ class File < IO
924
948
  # File.blockdev?('/dev/sda1') # => true
925
949
  # File.blockdev?(File.new('t.tmp')) # => false
926
950
  #
927
- def self.blockdev?: (string | _ToPath | IO file_name) -> bool
951
+ def self.blockdev?: (path | IO file_name) -> bool
928
952
 
929
953
  # <!--
930
954
  # rdoc-file=file.c
@@ -935,7 +959,7 @@ class File < IO
935
959
  # File.chardev?($stdin) # => true
936
960
  # File.chardev?('t.txt') # => false
937
961
  #
938
- def self.chardev?: (string | _ToPath | IO file_name) -> bool
962
+ def self.chardev?: (path | IO file_name) -> bool
939
963
 
940
964
  # <!--
941
965
  # rdoc-file=file.c
@@ -943,12 +967,12 @@ class File < IO
943
967
  # -->
944
968
  # Changes permission bits on the named file(s) to the bit pattern represented by
945
969
  # *mode_int*. Actual effects are operating system dependent (see the beginning
946
- # of this section). On Unix systems, see `chmod(2)` for details. Returns the
947
- # number of files processed.
970
+ # of this section). On Unix systems, see <code>chmod(2)</code> for details.
971
+ # Returns the number of files processed.
948
972
  #
949
973
  # File.chmod(0644, "testfile", "out") #=> 2
950
974
  #
951
- def self.chmod: (int mode, *string | _ToPath file_name) -> Integer
975
+ def self.chmod: (int mode, *path file_name) -> Integer
952
976
 
953
977
  # <!--
954
978
  # rdoc-file=file.c
@@ -962,7 +986,7 @@ class File < IO
962
986
  #
963
987
  # File.chown(nil, 100, "testfile")
964
988
  #
965
- def self.chown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
989
+ def self.chown: (int? owner, int? group, *path file_name) -> Integer
966
990
 
967
991
  # <!--
968
992
  # rdoc-file=file.c
@@ -977,7 +1001,7 @@ class File < IO
977
1001
  #
978
1002
  # File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
979
1003
  #
980
- def self.ctime: (string | _ToPath | IO file_name) -> Time
1004
+ def self.ctime: (path | IO file_name) -> Time
981
1005
 
982
1006
  # <!--
983
1007
  # rdoc-file=file.c
@@ -986,9 +1010,9 @@ class File < IO
986
1010
  # -->
987
1011
  # Deletes the named files, returning the number of names passed as arguments.
988
1012
  # Raises an exception on any error. Since the underlying implementation relies
989
- # on the `unlink(2)` system call, the type of exception raised depends on its
990
- # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
991
- # Errno::ENOENT.
1013
+ # on the <code>unlink(2)</code> system call, the type of exception raised
1014
+ # depends on its error type (see https://linux.die.net/man/2/unlink) and has the
1015
+ # form of e.g. Errno::ENOENT.
992
1016
  #
993
1017
  # See also Dir::rmdir.
994
1018
  #
@@ -1010,7 +1034,7 @@ class File < IO
1010
1034
  #
1011
1035
  # Argument `path` can be an IO object.
1012
1036
  #
1013
- def self.directory?: (string | _ToPath | IO path) -> bool
1037
+ def self.directory?: (path | IO path) -> bool
1014
1038
 
1015
1039
  # <!--
1016
1040
  # rdoc-file=file.c
@@ -1028,7 +1052,7 @@ class File < IO
1028
1052
  # File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
1029
1053
  # File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
1030
1054
  #
1031
- def self.dirname: (string | _ToPath file_name, ?Integer level) -> String
1055
+ def self.dirname: (path file_name, ?Integer level) -> String
1032
1056
 
1033
1057
  # <!--
1034
1058
  # rdoc-file=file.c
@@ -1054,7 +1078,7 @@ class File < IO
1054
1078
  # Note that some OS-level security features may cause this to return true even
1055
1079
  # though the file is not executable by the effective user/group.
1056
1080
  #
1057
- def self.executable?: (string | _ToPath file_name) -> bool
1081
+ def self.executable?: (path file_name) -> bool
1058
1082
 
1059
1083
  # <!--
1060
1084
  # rdoc-file=file.c
@@ -1070,7 +1094,7 @@ class File < IO
1070
1094
  # Note that some OS-level security features may cause this to return true even
1071
1095
  # though the file is not executable by the real user/group.
1072
1096
  #
1073
- def self.executable_real?: (string | _ToPath file_name) -> bool
1097
+ def self.executable_real?: (path file_name) -> bool
1074
1098
 
1075
1099
  # <!--
1076
1100
  # rdoc-file=file.c
@@ -1082,7 +1106,7 @@ class File < IO
1082
1106
  #
1083
1107
  # "file exists" means that stat() or fstat() system call is successful.
1084
1108
  #
1085
- def self.exist?: (string | _ToPath | IO file_name) -> bool
1109
+ def self.exist?: (path | IO file_name) -> bool
1086
1110
 
1087
1111
  # <!--
1088
1112
  # rdoc-file=file.c
@@ -1091,9 +1115,9 @@ class File < IO
1091
1115
  # Converts a pathname to an absolute pathname. Relative paths are referenced
1092
1116
  # from the current working directory of the process unless `dir_string` is
1093
1117
  # given, in which case it will be used as the starting point. The given pathname
1094
- # may start with a ```~`'', which expands to the process owner's home directory
1095
- # (the environment variable `HOME` must be set correctly). ```~`*user*'' expands
1096
- # to the named user's home directory.
1118
+ # may start with a ``<code>~</code>'', which expands to the process owner's home
1119
+ # directory (the environment variable `HOME` must be set correctly).
1120
+ # ``<code>~</code>*user*'' expands to the named user's home directory.
1097
1121
  #
1098
1122
  # File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
1099
1123
  #
@@ -1107,9 +1131,9 @@ class File < IO
1107
1131
  # #=> ".../path/to/project/lib/mygem.rb"
1108
1132
  #
1109
1133
  # So first it resolves the parent of __FILE__, that is bin/, then go to the
1110
- # parent, the root of the project and appends `lib/mygem.rb`.
1134
+ # parent, the root of the project and appends <code>lib/mygem.rb</code>.
1111
1135
  #
1112
- def self.expand_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
1136
+ def self.expand_path: (path file_name, ?path dir_string) -> String
1113
1137
 
1114
1138
  # <!--
1115
1139
  # rdoc-file=file.c
@@ -1135,7 +1159,7 @@ class File < IO
1135
1159
  # File.extname(".profile") #=> ""
1136
1160
  # File.extname(".profile.sh") #=> ".sh"
1137
1161
  #
1138
- def self.extname: (string | _ToPath path) -> String
1162
+ def self.extname: (path path) -> String
1139
1163
 
1140
1164
  # <!--
1141
1165
  # rdoc-file=file.c
@@ -1148,7 +1172,7 @@ class File < IO
1148
1172
  # If the `file` argument is a symbolic link, it will resolve the symbolic link
1149
1173
  # and use the file referenced by the link.
1150
1174
  #
1151
- def self.file?: (string | _ToPath | IO file) -> bool
1175
+ def self.file?: (path | IO file) -> bool
1152
1176
 
1153
1177
  # <!--
1154
1178
  # rdoc-file=dir.rb
@@ -1159,48 +1183,48 @@ class File < IO
1159
1183
  # regular expression; instead it follows rules similar to shell filename
1160
1184
  # globbing. It may contain the following metacharacters:
1161
1185
  #
1162
- # `*`
1186
+ # <code>*</code>
1163
1187
  # : Matches any file. Can be restricted by other values in the glob.
1164
- # Equivalent to `/.*/x` in regexp.
1188
+ # Equivalent to <code>/.*/x</code> in regexp.
1165
1189
  #
1166
- # `*`
1190
+ # <code>*</code>
1167
1191
  # : Matches all regular files
1168
1192
  #
1169
- # `c*`
1193
+ # <code>c*</code>
1170
1194
  # : Matches all files beginning with `c`
1171
1195
  #
1172
- # `*c`
1196
+ # <code>*c</code>
1173
1197
  # : Matches all files ending with `c`
1174
1198
  #
1175
- # `*c*`
1199
+ # <code>*c*</code>
1176
1200
  # : Matches all files that have `c` in them (including at the beginning or
1177
1201
  # end).
1178
1202
  #
1179
1203
  #
1180
- # To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH
1181
- # flag.
1204
+ # To match hidden files (that start with a <code>.</code>) set the
1205
+ # File::FNM_DOTMATCH flag.
1182
1206
  #
1183
1207
  #
1184
- # `**`
1208
+ # <code>**</code>
1185
1209
  # : Matches directories recursively or files expansively.
1186
1210
  #
1187
1211
  #
1188
- # `?`
1189
- # : Matches any one character. Equivalent to `/.{1}/` in regexp.
1212
+ # <code>?</code>
1213
+ # : Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
1190
1214
  #
1191
1215
  #
1192
- # `[set]`
1216
+ # <code>[set]</code>
1193
1217
  # : Matches any one character in `set`. Behaves exactly like character sets
1194
- # in Regexp, including set negation (`[^a-z]`).
1218
+ # in Regexp, including set negation (<code>[^a-z]</code>).
1195
1219
  #
1196
1220
  #
1197
- # `\`
1221
+ # <code>\</code>
1198
1222
  # : Escapes the next metacharacter.
1199
1223
  #
1200
1224
  #
1201
- # `{a,b}`
1225
+ # <code>{a,b}</code>
1202
1226
  # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
1203
- # Behaves like a Regexp union (`(?:a|b)`).
1227
+ # Behaves like a Regexp union (<code>(?:a|b)</code>).
1204
1228
  #
1205
1229
  #
1206
1230
  # `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
@@ -1252,7 +1276,7 @@ class File < IO
1252
1276
  # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
1253
1277
  # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
1254
1278
  #
1255
- def self.fnmatch: (string pattern, string | _ToPath path, ?int flags) -> bool
1279
+ def self.fnmatch: (string pattern, path path, ?int flags) -> bool
1256
1280
 
1257
1281
  # <!--
1258
1282
  # rdoc-file=dir.rb
@@ -1273,7 +1297,7 @@ class File < IO
1273
1297
  # File.ftype("/dev/tty") #=> "characterSpecial"
1274
1298
  # File.ftype("/tmp/.X11-unix/X0") #=> "socket"
1275
1299
  #
1276
- def self.ftype: (string | _ToPath file_name) -> String
1300
+ def self.ftype: (path file_name) -> String
1277
1301
 
1278
1302
  # <!--
1279
1303
  # rdoc-file=file.c
@@ -1284,7 +1308,7 @@ class File < IO
1284
1308
  #
1285
1309
  # *file_name* can be an IO object.
1286
1310
  #
1287
- def self.grpowned?: (string | _ToPath | IO file_name) -> bool
1311
+ def self.grpowned?: (path | IO file_name) -> bool
1288
1312
 
1289
1313
  # <!--
1290
1314
  # rdoc-file=file.c
@@ -1304,13 +1328,13 @@ class File < IO
1304
1328
  # open("d", "w") {}
1305
1329
  # p File.identical?("a", "d") #=> false
1306
1330
  #
1307
- def self.identical?: (string | _ToPath | IO file_1, string | _ToPath | IO file_2) -> bool
1331
+ def self.identical?: (path | IO file_1, path | IO file_2) -> bool
1308
1332
 
1309
1333
  # <!--
1310
1334
  # rdoc-file=file.c
1311
1335
  # - File.join(string, ...) -> string
1312
1336
  # -->
1313
- # Returns a new string formed by joining the strings using `"/"`.
1337
+ # Returns a new string formed by joining the strings using <code>"/"</code>.
1314
1338
  #
1315
1339
  # File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
1316
1340
  #
@@ -1324,7 +1348,7 @@ class File < IO
1324
1348
  # change the permissions associated with the link, not the file referenced by
1325
1349
  # the link). Often not available.
1326
1350
  #
1327
- def self.lchmod: (int mode, *string | _ToPath file_name) -> Integer
1351
+ def self.lchmod: (int mode, *path file_name) -> Integer
1328
1352
 
1329
1353
  # <!--
1330
1354
  # rdoc-file=file.c
@@ -1334,7 +1358,7 @@ class File < IO
1334
1358
  # change the owner associated with the link, not the file referenced by the
1335
1359
  # link). Often not available. Returns number of files in the argument list.
1336
1360
  #
1337
- def self.lchown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
1361
+ def self.lchown: (int? owner, int? group, *path file_name) -> Integer
1338
1362
 
1339
1363
  # <!--
1340
1364
  # rdoc-file=file.c
@@ -1347,7 +1371,7 @@ class File < IO
1347
1371
  # File.link("testfile", ".testfile") #=> 0
1348
1372
  # IO.readlines(".testfile")[0] #=> "This is line one\n"
1349
1373
  #
1350
- def self.link: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1374
+ def self.link: (path old_name, path new_name) -> 0
1351
1375
 
1352
1376
  # <!--
1353
1377
  # rdoc-file=file.c
@@ -1360,7 +1384,7 @@ class File < IO
1360
1384
  # File.stat('symlink').size # => 47
1361
1385
  # File.lstat('symlink').size # => 5
1362
1386
  #
1363
- def self.lstat: (string | _ToPath file_name) -> File::Stat
1387
+ def self.lstat: (path file_name) -> File::Stat
1364
1388
 
1365
1389
  # <!--
1366
1390
  # rdoc-file=file.c
@@ -1371,7 +1395,7 @@ class File < IO
1371
1395
  # opposed to its referent; for the inverse behavior, see File.utime. Returns the
1372
1396
  # number of file names in the argument list.
1373
1397
  #
1374
- def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
1398
+ def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
1375
1399
 
1376
1400
  # <!--
1377
1401
  # rdoc-file=file.c
@@ -1381,7 +1405,7 @@ class File < IO
1381
1405
  # FIFO's permissions. It is modified by the process's umask in the usual way:
1382
1406
  # the permissions of the created file are (mode & ~umask).
1383
1407
  #
1384
- def self.mkfifo: (string | _ToPath file_name, ?int mode) -> 0
1408
+ def self.mkfifo: (path file_name, ?int mode) -> 0
1385
1409
 
1386
1410
  # <!--
1387
1411
  # rdoc-file=file.c
@@ -1393,7 +1417,7 @@ class File < IO
1393
1417
  #
1394
1418
  # File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
1395
1419
  #
1396
- def self.mtime: (string | _ToPath | IO file_name) -> Time
1420
+ def self.mtime: (path | IO file_name) -> Time
1397
1421
 
1398
1422
  # <!--
1399
1423
  # rdoc-file=io.c
@@ -1407,8 +1431,54 @@ class File < IO
1407
1431
  # With a block given, calls the block with the File object and returns the
1408
1432
  # block's value.
1409
1433
  #
1410
- def self.open: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> instance
1411
- | [T] (string | _ToPath | int file_name, ?string | int mode, ?int perm) { (File) -> T } -> T
1434
+ def self.open: (
1435
+ path | int file_name,
1436
+ ?string | int mode,
1437
+ ?int perm,
1438
+ # open options
1439
+ ?mode: Integer | String,
1440
+ ?flags: Integer,
1441
+ ?external_encoding: encoding,
1442
+ ?internal_encoding: encoding,
1443
+ ?encoding: encoding,
1444
+ ?textmode: boolish,
1445
+ ?binmode: boolish,
1446
+ ?autoclose: boolish,
1447
+ ?path: path,
1448
+ # encoding options
1449
+ ?invalid: :replace | nil,
1450
+ ?undef: :replace | nil,
1451
+ ?replace: String | nil,
1452
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
1453
+ ?xml: :text | :attr | nil,
1454
+ ?cr_newline: bool,
1455
+ ?crlf_newline: bool,
1456
+ ?universal_newline: bool
1457
+ ) -> instance
1458
+ | [T] (
1459
+ path | int file_name,
1460
+ ?string | int mode,
1461
+ ?int perm,
1462
+ # open options
1463
+ ?mode: Integer | String,
1464
+ ?flags: Integer,
1465
+ ?external_encoding: encoding,
1466
+ ?internal_encoding: encoding,
1467
+ ?encoding: encoding,
1468
+ ?textmode: boolish,
1469
+ ?binmode: boolish,
1470
+ ?autoclose: boolish,
1471
+ ?path: path,
1472
+ # encoding options
1473
+ ?invalid: :replace | nil,
1474
+ ?undef: :replace | nil,
1475
+ ?replace: String | nil,
1476
+ ?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
1477
+ ?xml: :text | :attr | nil,
1478
+ ?cr_newline: bool,
1479
+ ?crlf_newline: bool,
1480
+ ?universal_newline: bool
1481
+ ) { (File) -> T } -> T
1412
1482
 
1413
1483
  # <!--
1414
1484
  # rdoc-file=file.c
@@ -1419,7 +1489,7 @@ class File < IO
1419
1489
  #
1420
1490
  # *file_name* can be an IO object.
1421
1491
  #
1422
- def self.owned?: (string | _ToPath | IO file_name) -> bool
1492
+ def self.owned?: (path | IO file_name) -> bool
1423
1493
 
1424
1494
  # <!--
1425
1495
  # rdoc-file=file.c
@@ -1444,10 +1514,10 @@ class File < IO
1444
1514
  # 1. It must be in an ASCII-compatible encoding; otherwise, an
1445
1515
  # Encoding::CompatibilityError is raised.
1446
1516
  #
1447
- # 2. It must not contain the NUL character (`\0`); otherwise, an ArgumentError
1448
- # is raised.
1517
+ # 2. It must not contain the NUL character (<code>\0</code>); otherwise, an
1518
+ # ArgumentError is raised.
1449
1519
  #
1450
- def self.path: (string | _ToPath path) -> String
1520
+ def self.path: (path path) -> String
1451
1521
 
1452
1522
  # <!--
1453
1523
  # rdoc-file=file.c
@@ -1459,7 +1529,7 @@ class File < IO
1459
1529
  # File.pipe?('tmp/fifo') # => true
1460
1530
  # File.pipe?('t.txt') # => false
1461
1531
  #
1462
- def self.pipe?: (string | _ToPath | IO file_name) -> bool
1532
+ def self.pipe?: (path | IO file_name) -> bool
1463
1533
 
1464
1534
  # <!--
1465
1535
  # rdoc-file=file.c
@@ -1471,7 +1541,7 @@ class File < IO
1471
1541
  # Note that some OS-level security features may cause this to return true even
1472
1542
  # though the file is not readable by the effective user/group.
1473
1543
  #
1474
- def self.readable?: (string | _ToPath file_name) -> bool
1544
+ def self.readable?: (path file_name) -> bool
1475
1545
 
1476
1546
  # <!--
1477
1547
  # rdoc-file=file.c
@@ -1483,7 +1553,7 @@ class File < IO
1483
1553
  # Note that some OS-level security features may cause this to return true even
1484
1554
  # though the file is not readable by the real user/group.
1485
1555
  #
1486
- def self.readable_real?: (string | _ToPath file_name) -> bool
1556
+ def self.readable_real?: (path file_name) -> bool
1487
1557
 
1488
1558
  # <!--
1489
1559
  # rdoc-file=file.c
@@ -1495,7 +1565,7 @@ class File < IO
1495
1565
  # File.symlink("testfile", "link2test") #=> 0
1496
1566
  # File.readlink("link2test") #=> "testfile"
1497
1567
  #
1498
- def self.readlink: (string | _ToPath link_name) -> String
1568
+ def self.readlink: (path link_name) -> String
1499
1569
 
1500
1570
  # <!--
1501
1571
  # rdoc-file=file.c
@@ -1509,7 +1579,7 @@ class File < IO
1509
1579
  #
1510
1580
  # The last component of the real pathname can be nonexistent.
1511
1581
  #
1512
- def self.realdirpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
1582
+ def self.realdirpath: (path pathname, ?path dir_string) -> String
1513
1583
 
1514
1584
  # <!--
1515
1585
  # rdoc-file=file.c
@@ -1523,7 +1593,7 @@ class File < IO
1523
1593
  #
1524
1594
  # All components of the pathname must exist when this method is called.
1525
1595
  #
1526
- def self.realpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
1596
+ def self.realpath: (path pathname, ?path dir_string) -> String
1527
1597
 
1528
1598
  # <!--
1529
1599
  # rdoc-file=file.c
@@ -1534,7 +1604,7 @@ class File < IO
1534
1604
  #
1535
1605
  # File.rename("afile", "afile.bak") #=> 0
1536
1606
  #
1537
- def self.rename: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1607
+ def self.rename: (path old_name, path new_name) -> 0
1538
1608
 
1539
1609
  # <!--
1540
1610
  # rdoc-file=file.c
@@ -1544,7 +1614,7 @@ class File < IO
1544
1614
  #
1545
1615
  # *file_name* can be an IO object.
1546
1616
  #
1547
- def self.setgid?: (string | _ToPath | IO file_name) -> bool
1617
+ def self.setgid?: (path | IO file_name) -> bool
1548
1618
 
1549
1619
  # <!--
1550
1620
  # rdoc-file=file.c
@@ -1554,7 +1624,7 @@ class File < IO
1554
1624
  #
1555
1625
  # *file_name* can be an IO object.
1556
1626
  #
1557
- def self.setuid?: (string | _ToPath | IO file_name) -> bool
1627
+ def self.setuid?: (path | IO file_name) -> bool
1558
1628
 
1559
1629
  # <!--
1560
1630
  # rdoc-file=file.c
@@ -1564,7 +1634,7 @@ class File < IO
1564
1634
  #
1565
1635
  # *file_name* can be an IO object.
1566
1636
  #
1567
- def self.size: (string | _ToPath | IO file_name) -> Integer
1637
+ def self.size: (path | IO file_name) -> Integer
1568
1638
 
1569
1639
  # <!--
1570
1640
  # rdoc-file=file.c
@@ -1575,7 +1645,7 @@ class File < IO
1575
1645
  #
1576
1646
  # *file_name* can be an IO object.
1577
1647
  #
1578
- def self.size?: (string | _ToPath | IO file_name) -> Integer?
1648
+ def self.size?: (path | IO file_name) -> Integer?
1579
1649
 
1580
1650
  # <!--
1581
1651
  # rdoc-file=file.c
@@ -1587,7 +1657,7 @@ class File < IO
1587
1657
  # File.socket?(Socket.new(:INET, :STREAM)) # => true
1588
1658
  # File.socket?(File.new('t.txt')) # => false
1589
1659
  #
1590
- def self.socket?: (string | _ToPath | IO file_name) -> bool
1660
+ def self.socket?: (path | IO file_name) -> bool
1591
1661
 
1592
1662
  # <!--
1593
1663
  # rdoc-file=file.c
@@ -1598,7 +1668,7 @@ class File < IO
1598
1668
  #
1599
1669
  # File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
1600
1670
  #
1601
- def self.split: (string | _ToPath file_name) -> [ String, String ]
1671
+ def self.split: (path file_name) -> [ String, String ]
1602
1672
 
1603
1673
  # <!--
1604
1674
  # rdoc-file=file.c
@@ -1608,7 +1678,7 @@ class File < IO
1608
1678
  #
1609
1679
  # File.stat('t.txt').class # => File::Stat
1610
1680
  #
1611
- def self.stat: (string | _ToPath file_name) -> File::Stat
1681
+ def self.stat: (path file_name) -> File::Stat
1612
1682
 
1613
1683
  # <!--
1614
1684
  # rdoc-file=file.c
@@ -1618,7 +1688,7 @@ class File < IO
1618
1688
  #
1619
1689
  # *file_name* can be an IO object.
1620
1690
  #
1621
- def self.sticky?: (string | _ToPath | IO file_name) -> bool
1691
+ def self.sticky?: (path | IO file_name) -> bool
1622
1692
 
1623
1693
  # <!--
1624
1694
  # rdoc-file=file.c
@@ -1630,7 +1700,7 @@ class File < IO
1630
1700
  #
1631
1701
  # File.symlink("testfile", "link2test") #=> 0
1632
1702
  #
1633
- def self.symlink: (string | _ToPath old_name, string | _ToPath new_name) -> 0
1703
+ def self.symlink: (path old_name, path new_name) -> 0
1634
1704
 
1635
1705
  # <!--
1636
1706
  # rdoc-file=file.c
@@ -1642,7 +1712,7 @@ class File < IO
1642
1712
  # File.symlink?('symlink') # => true
1643
1713
  # File.symlink?('t.txt') # => false
1644
1714
  #
1645
- def self.symlink?: (string | _ToPath file_name) -> bool
1715
+ def self.symlink?: (path file_name) -> bool
1646
1716
 
1647
1717
  # <!--
1648
1718
  # rdoc-file=file.c
@@ -1657,7 +1727,7 @@ class File < IO
1657
1727
  # File.truncate("out", 5) #=> 0
1658
1728
  # File.size("out") #=> 5
1659
1729
  #
1660
- def self.truncate: (string | _ToPath file_name, int length) -> 0
1730
+ def self.truncate: (path file_name, int length) -> 0
1661
1731
 
1662
1732
  # <!--
1663
1733
  # rdoc-file=file.c
@@ -1681,13 +1751,13 @@ class File < IO
1681
1751
  # -->
1682
1752
  # Deletes the named files, returning the number of names passed as arguments.
1683
1753
  # Raises an exception on any error. Since the underlying implementation relies
1684
- # on the `unlink(2)` system call, the type of exception raised depends on its
1685
- # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
1686
- # Errno::ENOENT.
1754
+ # on the <code>unlink(2)</code> system call, the type of exception raised
1755
+ # depends on its error type (see https://linux.die.net/man/2/unlink) and has the
1756
+ # form of e.g. Errno::ENOENT.
1687
1757
  #
1688
1758
  # See also Dir::rmdir.
1689
1759
  #
1690
- def self.unlink: (*string | _ToPath file_name) -> Integer
1760
+ def self.unlink: (*path file_name) -> Integer
1691
1761
 
1692
1762
  # <!--
1693
1763
  # rdoc-file=file.c
@@ -1698,7 +1768,7 @@ class File < IO
1698
1768
  # than the link itself; for the inverse behavior see File.lutime. Returns the
1699
1769
  # number of file names in the argument list.
1700
1770
  #
1701
- def self.utime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
1771
+ def self.utime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
1702
1772
 
1703
1773
  # <!--
1704
1774
  # rdoc-file=file.c
@@ -1706,7 +1776,7 @@ class File < IO
1706
1776
  # -->
1707
1777
  # If *file_name* is readable by others, returns an integer representing the file
1708
1778
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
1709
- # bits is platform dependent; on Unix systems, see `stat(2)`.
1779
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
1710
1780
  #
1711
1781
  # *file_name* can be an IO object.
1712
1782
  #
@@ -1714,7 +1784,7 @@ class File < IO
1714
1784
  # m = File.world_readable?("/etc/passwd")
1715
1785
  # sprintf("%o", m) #=> "644"
1716
1786
  #
1717
- def self.world_readable?: (string | _ToPath | IO file_name) -> Integer?
1787
+ def self.world_readable?: (path | IO file_name) -> Integer?
1718
1788
 
1719
1789
  # <!--
1720
1790
  # rdoc-file=file.c
@@ -1722,7 +1792,7 @@ class File < IO
1722
1792
  # -->
1723
1793
  # If *file_name* is writable by others, returns an integer representing the file
1724
1794
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
1725
- # bits is platform dependent; on Unix systems, see `stat(2)`.
1795
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
1726
1796
  #
1727
1797
  # *file_name* can be an IO object.
1728
1798
  #
@@ -1730,7 +1800,7 @@ class File < IO
1730
1800
  # m = File.world_writable?("/tmp")
1731
1801
  # sprintf("%o", m) #=> "777"
1732
1802
  #
1733
- def self.world_writable?: (string | _ToPath | IO file_name) -> Integer?
1803
+ def self.world_writable?: (path | IO file_name) -> Integer?
1734
1804
 
1735
1805
  # <!--
1736
1806
  # rdoc-file=file.c
@@ -1742,7 +1812,7 @@ class File < IO
1742
1812
  # Note that some OS-level security features may cause this to return true even
1743
1813
  # though the file is not writable by the effective user/group.
1744
1814
  #
1745
- def self.writable?: (string | _ToPath file_name) -> bool
1815
+ def self.writable?: (path file_name) -> bool
1746
1816
 
1747
1817
  # <!--
1748
1818
  # rdoc-file=file.c
@@ -1754,7 +1824,7 @@ class File < IO
1754
1824
  # Note that some OS-level security features may cause this to return true even
1755
1825
  # though the file is not writable by the real user/group.
1756
1826
  #
1757
- def self.writable_real?: (string | _ToPath file_name) -> bool
1827
+ def self.writable_real?: (path file_name) -> bool
1758
1828
 
1759
1829
  # <!--
1760
1830
  # rdoc-file=file.c
@@ -1764,7 +1834,7 @@ class File < IO
1764
1834
  #
1765
1835
  # *file_name* can be an IO object.
1766
1836
  #
1767
- def self.zero?: (string | _ToPath | IO file_name) -> bool
1837
+ def self.zero?: (path | IO file_name) -> bool
1768
1838
 
1769
1839
  # <!--
1770
1840
  # rdoc-file=file.c
@@ -1795,7 +1865,8 @@ class File < IO
1795
1865
  # -->
1796
1866
  # Changes permission bits on *file* to the bit pattern represented by
1797
1867
  # *mode_int*. Actual effects are platform dependent; on Unix systems, see
1798
- # `chmod(2)` for details. Follows symbolic links. Also see File#lchmod.
1868
+ # <code>chmod(2)</code> for details. Follows symbolic links. Also see
1869
+ # File#lchmod.
1799
1870
  #
1800
1871
  # f = File.new("out", "w");
1801
1872
  # f.chmod(0644) #=> 0
@@ -1833,18 +1904,18 @@ class File < IO
1833
1904
  # rdoc-file=file.c
1834
1905
  # - flock(locking_constant) -> 0 or false
1835
1906
  # -->
1836
- # Locks or unlocks file `self` according to the given `locking_constant`,
1907
+ # Locks or unlocks file +self+ according to the given `locking_constant`,
1837
1908
  # a bitwise OR of the values in the table below.
1838
1909
  # Not available on all platforms.
1839
- # Returns `false` if `File::LOCK_NB` is specified and the operation would have
1840
- # blocked;
1910
+ # Returns `false` if <code>File::LOCK_NB</code> is specified and the operation
1911
+ # would have blocked;
1841
1912
  # otherwise returns `0`.
1842
- # Constant | Lock | Effect
1843
- # ---------------|------------|-------------------------------------------------------------------------------------------------------
1844
- # `File::LOCK_EX`| Exclusive | Only one process may hold an exclusive lock for `self` at a time.
1845
- # `File::LOCK_NB`|Non-blocking|No blocking; may be combined with `File::LOCK_SH` or `File::LOCK_EX` using the bitwise OR operator `|`.
1846
- # `File::LOCK_SH`| Shared | Multiple processes may each hold a shared lock for `self` at the same time.
1847
- # `File::LOCK_UN`| Unlock | Remove an existing lock held by this process.
1913
+ # Constant | Lock | Effect
1914
+ # ---------------|------------|------------------------------------------------------------------------------------------------------------------
1915
+ # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1916
+ # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <code>|</code>.
1917
+ # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1918
+ # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1848
1919
  # Example:
1849
1920
  # # Update a counter using an exclusive lock.
1850
1921
  # # Don't use File::WRONLY because it truncates the file.
@@ -1970,7 +2041,7 @@ File::SEPARATOR: String
1970
2041
  File::Separator: String
1971
2042
 
1972
2043
  # <!-- rdoc-file=file.c -->
1973
- # Module `File::Constants` defines file-related constants.
2044
+ # Module <code>File::Constants</code> defines file-related constants.
1974
2045
  #
1975
2046
  # There are two families of constants here:
1976
2047
  #
@@ -2234,14 +2305,14 @@ File::Separator: String
2234
2305
  #
2235
2306
  # #### File::FNM_DOTMATCH
2236
2307
  #
2237
- # Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with
2238
- # `'.'`.
2308
+ # Flag File::FNM_DOTMATCH makes the <code>'*'</code> pattern match a filename
2309
+ # starting with <code>'.'</code>.
2239
2310
  #
2240
2311
  # #### File::FNM_EXTGLOB
2241
2312
  #
2242
- # Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern
2243
- # '*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union)
2244
- # (e.g., `'(?:*a*|*b*)'`):
2313
+ # Flag File::FNM_EXTGLOB enables pattern <code>'{_a_,_b_}'</code>, which matches
2314
+ # pattern '*a*' and pattern '*b*'; behaves like a [regexp
2315
+ # union](rdoc-ref:Regexp.union) (e.g., <code>'(?:_a_|_b_)'</code>):
2245
2316
  #
2246
2317
  # pattern = '{LEGAL,BSDL}'
2247
2318
  # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
@@ -2250,12 +2321,13 @@ File::Separator: String
2250
2321
  #
2251
2322
  # #### File::FNM_NOESCAPE
2252
2323
  #
2253
- # Flag File::FNM_NOESCAPE disables `'\'` escaping.
2324
+ # Flag File::FNM_NOESCAPE disables <code>'\'</code> escaping.
2254
2325
  #
2255
2326
  # #### File::FNM_PATHNAME
2256
2327
  #
2257
- # Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
2258
- # the directory separator (the value of constant File::SEPARATOR).
2328
+ # Flag File::FNM_PATHNAME specifies that patterns <code>'*'</code> and
2329
+ # <code>'?'</code> do not match the directory separator (the value of constant
2330
+ # File::SEPARATOR).
2259
2331
  #
2260
2332
  # #### File::FNM_SHORTNAME
2261
2333
  #
@@ -2274,8 +2346,8 @@ File::Separator: String
2274
2346
  #
2275
2347
  # Flag File::NULL contains the string value of the null device:
2276
2348
  #
2277
- # * On a Unix-like OS, `'/dev/null'`.
2278
- # * On Windows, `'NUL'`.
2349
+ # * On a Unix-like OS, <code>'/dev/null'</code>.
2350
+ # * On Windows, <code>'NUL'</code>.
2279
2351
  #
2280
2352
  module File::Constants
2281
2353
  end
@@ -2458,13 +2530,13 @@ class File::Stat < Object
2458
2530
  # - self <=> other -> -1, 0, 1, or nil
2459
2531
  # -->
2460
2532
  # Compares `self` and `other`, by comparing their modification times; that is,
2461
- # by comparing `self.mtime` and `other.mtime`.
2533
+ # by comparing <code>self.mtime</code> and <code>other.mtime</code>.
2462
2534
  #
2463
2535
  # Returns:
2464
2536
  #
2465
- # * `-1`, if `self.mtime` is earlier.
2537
+ # * <code>-1</code>, if <code>self.mtime</code> is earlier.
2466
2538
  # * `0`, if the two values are equal.
2467
- # * `1`, if `self.mtime` is later.
2539
+ # * `1`, if <code>self.mtime</code> is later.
2468
2540
  # * `nil`, if `other` is not a File::Stat object.
2469
2541
  #
2470
2542
  # Examples:
@@ -2588,7 +2660,7 @@ class File::Stat < Object
2588
2660
  # rdoc-file=file.c
2589
2661
  # - stat.dev_major -> integer
2590
2662
  # -->
2591
- # Returns the major part of `File_Stat#dev` or `nil`.
2663
+ # Returns the major part of <code>File_Stat#dev</code> or `nil`.
2592
2664
  #
2593
2665
  # File.stat("/dev/fd1").dev_major #=> 2
2594
2666
  # File.stat("/dev/tty").dev_major #=> 5
@@ -2599,7 +2671,7 @@ class File::Stat < Object
2599
2671
  # rdoc-file=file.c
2600
2672
  # - stat.dev_minor -> integer
2601
2673
  # -->
2602
- # Returns the minor part of `File_Stat#dev` or `nil`.
2674
+ # Returns the minor part of <code>File_Stat#dev</code> or `nil`.
2603
2675
  #
2604
2676
  # File.stat("/dev/fd1").dev_minor #=> 1
2605
2677
  # File.stat("/dev/tty").dev_minor #=> 0
@@ -2633,7 +2705,8 @@ class File::Stat < Object
2633
2705
  # rdoc-file=file.c
2634
2706
  # - stat.executable_real? -> true or false
2635
2707
  # -->
2636
- # Same as `executable?`, but tests using the real owner of the process.
2708
+ # Same as <code>executable?</code>, but tests using the real owner of the
2709
+ # process.
2637
2710
  #
2638
2711
  def executable_real?: () -> bool
2639
2712
 
@@ -2713,7 +2786,7 @@ class File::Stat < Object
2713
2786
  # - stat.mode -> integer
2714
2787
  # -->
2715
2788
  # Returns an integer representing the permission bits of *stat*. The meaning of
2716
- # the bits is platform dependent; on Unix systems, see `stat(2)`.
2789
+ # the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
2717
2790
  #
2718
2791
  # File.chmod(0644, "testfile") #=> 1
2719
2792
  # s = File.stat("testfile")
@@ -2780,7 +2853,7 @@ class File::Stat < Object
2780
2853
  # rdoc-file=file.c
2781
2854
  # - stat.rdev_major -> integer
2782
2855
  # -->
2783
- # Returns the major part of `File_Stat#rdev` or `nil`.
2856
+ # Returns the major part of <code>File_Stat#rdev</code> or `nil`.
2784
2857
  #
2785
2858
  # File.stat("/dev/fd1").rdev_major #=> 2
2786
2859
  # File.stat("/dev/tty").rdev_major #=> 5
@@ -2791,7 +2864,7 @@ class File::Stat < Object
2791
2864
  # rdoc-file=file.c
2792
2865
  # - stat.rdev_minor -> integer
2793
2866
  # -->
2794
- # Returns the minor part of `File_Stat#rdev` or `nil`.
2867
+ # Returns the minor part of <code>File_Stat#rdev</code> or `nil`.
2795
2868
  #
2796
2869
  # File.stat("/dev/fd1").rdev_minor #=> 1
2797
2870
  # File.stat("/dev/tty").rdev_minor #=> 0
@@ -2914,7 +2987,7 @@ class File::Stat < Object
2914
2987
  # -->
2915
2988
  # If *stat* is readable by others, returns an integer representing the file
2916
2989
  # permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
2917
- # platform dependent; on Unix systems, see `stat(2)`.
2990
+ # platform dependent; on Unix systems, see <code>stat(2)</code>.
2918
2991
  #
2919
2992
  # m = File.stat("/etc/passwd").world_readable? #=> 420
2920
2993
  # sprintf("%o", m) #=> "644"
@@ -2927,7 +3000,7 @@ class File::Stat < Object
2927
3000
  # -->
2928
3001
  # If *stat* is writable by others, returns an integer representing the file
2929
3002
  # permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
2930
- # platform dependent; on Unix systems, see `stat(2)`.
3003
+ # platform dependent; on Unix systems, see <code>stat(2)</code>.
2931
3004
  #
2932
3005
  # m = File.stat("/tmp").world_writable? #=> 511
2933
3006
  # sprintf("%o", m) #=> "777"