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/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: (path | 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,8 +880,8 @@ 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
  #
@@ -943,8 +967,8 @@ 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
  #
@@ -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
  #
@@ -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,7 +1131,7 @@ 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
1136
  def self.expand_path: (path file_name, ?path dir_string) -> String
1113
1137
 
@@ -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
@@ -1310,7 +1334,7 @@ class File < IO
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
  #
@@ -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: (path | int file_name, ?string | int mode, ?int perm) -> instance
1411
- | [T] (path | 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
@@ -1444,8 +1514,8 @@ 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
1520
  def self.path: (path path) -> String
1451
1521
 
@@ -1681,9 +1751,9 @@ 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
  #
@@ -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
  #
@@ -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
  #
@@ -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"
data/core/file_test.rbs CHANGED
@@ -269,7 +269,7 @@ module FileTest
269
269
  # -->
270
270
  # If *file_name* is readable by others, returns an integer representing the file
271
271
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
272
- # bits is platform dependent; on Unix systems, see `stat(2)`.
272
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
273
273
  #
274
274
  # *file_name* can be an IO object.
275
275
  #
@@ -285,7 +285,7 @@ module FileTest
285
285
  # -->
286
286
  # If *file_name* is writable by others, returns an integer representing the file
287
287
  # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
288
- # bits is platform dependent; on Unix systems, see `stat(2)`.
288
+ # bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
289
289
  #
290
290
  # *file_name* can be an IO object.
291
291
  #