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/string.rbs CHANGED
@@ -16,8 +16,8 @@
16
16
  # * Method #String.
17
17
  #
18
18
  # Some `String` methods modify `self`. Typically, a method whose name ends with
19
- # `!` modifies `self` and returns `self`; often, a similarly named method
20
- # (without the `!`) returns a new string.
19
+ # <code>!</code> modifies `self` and returns `self`; often, a similarly named
20
+ # method (without the <code>!</code>) returns a new string.
21
21
  #
22
22
  # In general, if both bang and non-bang versions of a method exist, the bang
23
23
  # method mutates and the non-bang method does not. However, a method without a
@@ -48,7 +48,7 @@
48
48
  # The examples in this section mostly use the String#sub and String#gsub
49
49
  # methods; the principles illustrated apply to all four substitution methods.
50
50
  #
51
- # **Argument `pattern`**
51
+ # <strong>Argument `pattern`</strong>
52
52
  #
53
53
  # Argument `pattern` is commonly a regular expression:
54
54
  #
@@ -65,7 +65,7 @@
65
65
  #
66
66
  # 'THX1138'.gsub('\d+', '00') # => "THX1138"
67
67
  #
68
- # **`String` `replacement`**
68
+ # <strong>`String` `replacement`</strong>
69
69
  #
70
70
  # If `replacement` is a string, that string determines the replacing string that
71
71
  # is substituted for the matched text.
@@ -74,41 +74,48 @@
74
74
  #
75
75
  # `String` `replacement` may contain back-references to the pattern's captures:
76
76
  #
77
- # * `\n` (*n* is a non-negative integer) refers to `$n`.
78
- # * `\k<name>` refers to the named capture `name`.
77
+ # * <code>\n</code> (*n* is a non-negative integer) refers to <code>$n</code>.
78
+ # * <code>\k<name></code> refers to the named capture `name`.
79
79
  #
80
80
  # See Regexp for details.
81
81
  #
82
82
  # Note that within the string `replacement`, a character combination such as
83
- # `$&` is treated as ordinary text, not as a special match variable. However,
84
- # you may refer to some special match variables using these combinations:
85
- #
86
- # * `\&` and `\0` correspond to `$&`, which contains the complete matched
87
- # text.
88
- # * `\'` corresponds to `$'`, which contains the string after the match.
89
- # * `\`` corresponds to `$``, which contains the string before the match.
90
- # * `\+` corresponds to `$+`, which contains the last capture group.
83
+ # <code>$&</code> is treated as ordinary text, not as a special match variable.
84
+ # However, you may refer to some special match variables using these
85
+ # combinations:
86
+ #
87
+ # * <code>\&</code> and <code>\0</code> correspond to <code>$&</code>, which
88
+ # contains the complete matched text.
89
+ # * <code>\'</code> corresponds to <code>$'</code>, which contains the string
90
+ # after the match.
91
+ # * <code>`</code> corresponds to <code>$`</code>, which contains the string
92
+ # before the match.
93
+ # * <code>\+</code> corresponds to <code>$+</code>, which contains the last
94
+ # capture group.
91
95
  #
92
96
  # See Regexp for details.
93
97
  #
94
- # Note that `\\\` is interpreted as an escape, i.e., a single backslash.
98
+ # Note that <code>\\</code> is interpreted as an escape, i.e., a single
99
+ # backslash.
95
100
  #
96
101
  # Note also that a string literal consumes backslashes. See [String
97
102
  # Literals](rdoc-ref:syntax/literals.rdoc@String+Literals) for details about
98
103
  # string literals.
99
104
  #
100
105
  # A back-reference is typically preceded by an additional backslash. For
101
- # example, if you want to write a back-reference `\&` in `replacement` with a
102
- # double-quoted string literal, you need to write `"..\\\\&.."`.
106
+ # example, if you want to write a back-reference <code>\&</code> in
107
+ # `replacement` with a double-quoted string literal, you need to write
108
+ # <code>"..\\&.."</code>.
103
109
  #
104
- # If you want to write a non-back-reference string `\&` in `replacement`, you
105
- # need to first escape the backslash to prevent this method from interpreting it
106
- # as a back-reference, and then you need to escape the backslashes again to
107
- # prevent a string literal from consuming them: `"..\\\\\\\\&.."`.
110
+ # If you want to write a non-back-reference string <code>\&</code> in
111
+ # `replacement`, you need to first escape the backslash to prevent this method
112
+ # from interpreting it as a back-reference, and then you need to escape the
113
+ # backslashes again to prevent a string literal from consuming them:
114
+ # <code>"..\\\\&.."</code>.
108
115
  #
109
116
  # You may want to use the block form to avoid excessive backslashes.
110
117
  #
111
- # **\Hash `replacement`**
118
+ # <strong>Hash `replacement`</strong>
112
119
  #
113
120
  # If the argument `replacement` is a hash, and `pattern` matches one of its
114
121
  # keys, the replacing string is the value for that key:
@@ -129,21 +136,21 @@
129
136
  # s = '@'
130
137
  # '1234'.gsub(/\d/) { |match| s.succ! } # => "ABCD"
131
138
  #
132
- # Special match variables such as `$1`, `$2`, `$``, `$&`, and `$'` are set
133
- # appropriately.
139
+ # Special match variables such as <code>$1</code>, <code>$2</code>,
140
+ # <code>$`</code>, <code>$&</code>, and <code>$'</code> are set appropriately.
134
141
  #
135
142
  # ## Whitespace in Strings
136
143
  #
137
144
  # In the class `String`, *whitespace* is defined as a contiguous sequence of
138
145
  # characters consisting of any mixture of the following:
139
146
  #
140
- # * NL (null): `"\x00"`, `"\u0000"`.
141
- # * HT (horizontal tab): `"\x09"`, `"\t"`.
142
- # * LF (line feed): `"\x0a"`, `"\n"`.
143
- # * VT (vertical tab): `"\x0b"`, `"\v"`.
144
- # * FF (form feed): `"\x0c"`, `"\f"`.
145
- # * CR (carriage return): `"\x0d"`, `"\r"`.
146
- # * SP (space): `"\x20"`, `" "`.
147
+ # * NL (null): <code>"\x00"</code>, <code>"\u0000"</code>.
148
+ # * HT (horizontal tab): <code>"\x09"</code>, <code>"\t"</code>.
149
+ # * LF (line feed): <code>"\x0a"</code>, <code>"\n"</code>.
150
+ # * VT (vertical tab): <code>"\x0b"</code>, <code>"\v"</code>.
151
+ # * FF (form feed): <code>"\x0c"</code>, <code>"\f"</code>.
152
+ # * CR (carriage return): <code>"\x0d"</code>, <code>"\r"</code>.
153
+ # * SP (space): <code>"\x20"</code>, <code>" "</code>.
147
154
  #
148
155
  # Whitespace is relevant for the following methods:
149
156
  #
@@ -160,15 +167,14 @@
160
167
  #
161
168
  # Here, class `String` provides methods that are useful for:
162
169
  #
163
- # * [Creating a \String](rdoc-ref:String@Creating+a+String).
164
- # * [Freezing/Unfreezing a \String](rdoc-ref:String@Freezing-2FUnfreezing).
165
- # * [Querying a \String](rdoc-ref:String@Querying).
170
+ # * [Creating a String](rdoc-ref:String@Creating+a+String).
171
+ # * [Freezing/Unfreezing a String](rdoc-ref:String@Freezing-2FUnfreezing).
172
+ # * [Querying a String](rdoc-ref:String@Querying).
166
173
  # * [Comparing Strings](rdoc-ref:String@Comparing).
167
- # * [Modifying a \String](rdoc-ref:String@Modifying).
168
- # * [Converting to a new \String](rdoc-ref:String@Converting+to+New+String).
169
- # * [Converting to a
170
- # non-\String](rdoc-ref:String@Converting+to+Non--5CString).
171
- # * [Iterating over a \String](rdoc-ref:String@Iterating).
174
+ # * [Modifying a String](rdoc-ref:String@Modifying).
175
+ # * [Converting to a new String](rdoc-ref:String@Converting+to+New+String).
176
+ # * [Converting to a non-String](rdoc-ref:String@Converting+to+Non--5CString).
177
+ # * [Iterating over a String](rdoc-ref:String@Iterating).
172
178
  #
173
179
  # ### Creating a String
174
180
  #
@@ -177,10 +183,10 @@
177
183
  #
178
184
  # ### Freezing/Unfreezing
179
185
  #
180
- # * #+@: Returns a string that is not frozen: `self` if not frozen; `self.dup`
181
- # otherwise.
186
+ # * #+@: Returns a string that is not frozen: `self` if not frozen;
187
+ # <code>self.dup</code> otherwise.
182
188
  # * #-@ (aliased as #dedup): Returns a string that is frozen: `self` if
183
- # already frozen; `self.freeze` otherwise.
189
+ # already frozen; <code>self.freeze</code> otherwise.
184
190
  # * #freeze: Freezes `self` if not already frozen; returns `self`.
185
191
  #
186
192
  # ### Querying
@@ -406,7 +412,7 @@
406
412
  #
407
413
  # Each of these methods converts the contents of `self` to a non-`String`.
408
414
  #
409
- # *Characters, Bytes, and Clusters*
415
+ # <em>Characters, Bytes, and Clusters</em>
410
416
  #
411
417
  # * #bytes: Returns an array of the bytes in `self`.
412
418
  # * #chars: Returns an array of the characters in `self`.
@@ -489,8 +495,8 @@
489
495
  # * Method #String.
490
496
  #
491
497
  # Some `String` methods modify `self`. Typically, a method whose name ends with
492
- # `!` modifies `self` and returns `self`; often, a similarly named method
493
- # (without the `!`) returns a new string.
498
+ # <code>!</code> modifies `self` and returns `self`; often, a similarly named
499
+ # method (without the <code>!</code>) returns a new string.
494
500
  #
495
501
  # In general, if both bang and non-bang versions of a method exist, the bang
496
502
  # method mutates and the non-bang method does not. However, a method without a
@@ -521,7 +527,7 @@
521
527
  # The examples in this section mostly use the String#sub and String#gsub
522
528
  # methods; the principles illustrated apply to all four substitution methods.
523
529
  #
524
- # **Argument `pattern`**
530
+ # <strong>Argument `pattern`</strong>
525
531
  #
526
532
  # Argument `pattern` is commonly a regular expression:
527
533
  #
@@ -538,7 +544,7 @@
538
544
  #
539
545
  # 'THX1138'.gsub('\d+', '00') # => "THX1138"
540
546
  #
541
- # **`String` `replacement`**
547
+ # <strong>`String` `replacement`</strong>
542
548
  #
543
549
  # If `replacement` is a string, that string determines the replacing string that
544
550
  # is substituted for the matched text.
@@ -547,41 +553,48 @@
547
553
  #
548
554
  # `String` `replacement` may contain back-references to the pattern's captures:
549
555
  #
550
- # * `\n` (*n* is a non-negative integer) refers to `$n`.
551
- # * `\k<name>` refers to the named capture `name`.
556
+ # * <code>\n</code> (*n* is a non-negative integer) refers to <code>$n</code>.
557
+ # * <code>\k<name></code> refers to the named capture `name`.
552
558
  #
553
559
  # See Regexp for details.
554
560
  #
555
561
  # Note that within the string `replacement`, a character combination such as
556
- # `$&` is treated as ordinary text, not as a special match variable. However,
557
- # you may refer to some special match variables using these combinations:
558
- #
559
- # * `\&` and `\0` correspond to `$&`, which contains the complete matched
560
- # text.
561
- # * `\'` corresponds to `$'`, which contains the string after the match.
562
- # * `\`` corresponds to `$``, which contains the string before the match.
563
- # * `\+` corresponds to `$+`, which contains the last capture group.
562
+ # <code>$&</code> is treated as ordinary text, not as a special match variable.
563
+ # However, you may refer to some special match variables using these
564
+ # combinations:
565
+ #
566
+ # * <code>\&</code> and <code>\0</code> correspond to <code>$&</code>, which
567
+ # contains the complete matched text.
568
+ # * <code>\'</code> corresponds to <code>$'</code>, which contains the string
569
+ # after the match.
570
+ # * <code>`</code> corresponds to <code>$`</code>, which contains the string
571
+ # before the match.
572
+ # * <code>\+</code> corresponds to <code>$+</code>, which contains the last
573
+ # capture group.
564
574
  #
565
575
  # See Regexp for details.
566
576
  #
567
- # Note that `\\\` is interpreted as an escape, i.e., a single backslash.
577
+ # Note that <code>\\</code> is interpreted as an escape, i.e., a single
578
+ # backslash.
568
579
  #
569
580
  # Note also that a string literal consumes backslashes. See [String
570
581
  # Literals](rdoc-ref:syntax/literals.rdoc@String+Literals) for details about
571
582
  # string literals.
572
583
  #
573
584
  # A back-reference is typically preceded by an additional backslash. For
574
- # example, if you want to write a back-reference `\&` in `replacement` with a
575
- # double-quoted string literal, you need to write `"..\\\\&.."`.
585
+ # example, if you want to write a back-reference <code>\&</code> in
586
+ # `replacement` with a double-quoted string literal, you need to write
587
+ # <code>"..\\&.."</code>.
576
588
  #
577
- # If you want to write a non-back-reference string `\&` in `replacement`, you
578
- # need to first escape the backslash to prevent this method from interpreting it
579
- # as a back-reference, and then you need to escape the backslashes again to
580
- # prevent a string literal from consuming them: `"..\\\\\\\\&.."`.
589
+ # If you want to write a non-back-reference string <code>\&</code> in
590
+ # `replacement`, you need to first escape the backslash to prevent this method
591
+ # from interpreting it as a back-reference, and then you need to escape the
592
+ # backslashes again to prevent a string literal from consuming them:
593
+ # <code>"..\\\\&.."</code>.
581
594
  #
582
595
  # You may want to use the block form to avoid excessive backslashes.
583
596
  #
584
- # **\Hash `replacement`**
597
+ # <strong>Hash `replacement`</strong>
585
598
  #
586
599
  # If the argument `replacement` is a hash, and `pattern` matches one of its
587
600
  # keys, the replacing string is the value for that key:
@@ -602,21 +615,21 @@
602
615
  # s = '@'
603
616
  # '1234'.gsub(/\d/) { |match| s.succ! } # => "ABCD"
604
617
  #
605
- # Special match variables such as `$1`, `$2`, `$``, `$&`, and `$'` are set
606
- # appropriately.
618
+ # Special match variables such as <code>$1</code>, <code>$2</code>,
619
+ # <code>$`</code>, <code>$&</code>, and <code>$'</code> are set appropriately.
607
620
  #
608
621
  # ## Whitespace in Strings
609
622
  #
610
623
  # In the class `String`, *whitespace* is defined as a contiguous sequence of
611
624
  # characters consisting of any mixture of the following:
612
625
  #
613
- # * NL (null): `"\x00"`, `"\u0000"`.
614
- # * HT (horizontal tab): `"\x09"`, `"\t"`.
615
- # * LF (line feed): `"\x0a"`, `"\n"`.
616
- # * VT (vertical tab): `"\x0b"`, `"\v"`.
617
- # * FF (form feed): `"\x0c"`, `"\f"`.
618
- # * CR (carriage return): `"\x0d"`, `"\r"`.
619
- # * SP (space): `"\x20"`, `" "`.
626
+ # * NL (null): <code>"\x00"</code>, <code>"\u0000"</code>.
627
+ # * HT (horizontal tab): <code>"\x09"</code>, <code>"\t"</code>.
628
+ # * LF (line feed): <code>"\x0a"</code>, <code>"\n"</code>.
629
+ # * VT (vertical tab): <code>"\x0b"</code>, <code>"\v"</code>.
630
+ # * FF (form feed): <code>"\x0c"</code>, <code>"\f"</code>.
631
+ # * CR (carriage return): <code>"\x0d"</code>, <code>"\r"</code>.
632
+ # * SP (space): <code>"\x20"</code>, <code>" "</code>.
620
633
  #
621
634
  # Whitespace is relevant for the following methods:
622
635
  #
@@ -633,15 +646,14 @@
633
646
  #
634
647
  # Here, class `String` provides methods that are useful for:
635
648
  #
636
- # * [Creating a \String](rdoc-ref:String@Creating+a+String).
637
- # * [Freezing/Unfreezing a \String](rdoc-ref:String@Freezing-2FUnfreezing).
638
- # * [Querying a \String](rdoc-ref:String@Querying).
649
+ # * [Creating a String](rdoc-ref:String@Creating+a+String).
650
+ # * [Freezing/Unfreezing a String](rdoc-ref:String@Freezing-2FUnfreezing).
651
+ # * [Querying a String](rdoc-ref:String@Querying).
639
652
  # * [Comparing Strings](rdoc-ref:String@Comparing).
640
- # * [Modifying a \String](rdoc-ref:String@Modifying).
641
- # * [Converting to a new \String](rdoc-ref:String@Converting+to+New+String).
642
- # * [Converting to a
643
- # non-\String](rdoc-ref:String@Converting+to+Non--5CString).
644
- # * [Iterating over a \String](rdoc-ref:String@Iterating).
653
+ # * [Modifying a String](rdoc-ref:String@Modifying).
654
+ # * [Converting to a new String](rdoc-ref:String@Converting+to+New+String).
655
+ # * [Converting to a non-String](rdoc-ref:String@Converting+to+Non--5CString).
656
+ # * [Iterating over a String](rdoc-ref:String@Iterating).
645
657
  #
646
658
  # ### Creating a String
647
659
  #
@@ -650,10 +662,10 @@
650
662
  #
651
663
  # ### Freezing/Unfreezing
652
664
  #
653
- # * #+@: Returns a string that is not frozen: `self` if not frozen; `self.dup`
654
- # otherwise.
665
+ # * #+@: Returns a string that is not frozen: `self` if not frozen;
666
+ # <code>self.dup</code> otherwise.
655
667
  # * #-@ (aliased as #dedup): Returns a string that is frozen: `self` if
656
- # already frozen; `self.freeze` otherwise.
668
+ # already frozen; <code>self.freeze</code> otherwise.
657
669
  # * #freeze: Freezes `self` if not already frozen; returns `self`.
658
670
  #
659
671
  # ### Querying
@@ -879,7 +891,7 @@
879
891
  #
880
892
  # Each of these methods converts the contents of `self` to a non-`String`.
881
893
  #
882
- # *Characters, Bytes, and Clusters*
894
+ # <em>Characters, Bytes, and Clusters</em>
883
895
  #
884
896
  # * #bytes: Returns an array of the bytes in `self`.
885
897
  # * #chars: Returns an array of the characters in `self`.
@@ -958,12 +970,12 @@ class String
958
970
  #
959
971
  # If `object` is already a string, returns `object`, unmodified.
960
972
  #
961
- # Otherwise if `object` responds to `:to_str`, calls `object.to_str` and returns
962
- # the result.
973
+ # Otherwise if `object` responds to <code>:to_str</code>, calls
974
+ # <code>object.to_str</code> and returns the result.
963
975
  #
964
- # Returns `nil` if `object` does not respond to `:to_str`.
976
+ # Returns `nil` if `object` does not respond to <code>:to_str</code>.
965
977
  #
966
- # Raises an exception unless `object.to_str` returns a string.
978
+ # Raises an exception unless <code>object.to_str</code> returns a string.
967
979
  #
968
980
  def self.try_convert: (String object) -> String # technically will return `object` unchanged.
969
981
  | (_ToStr object) -> String
@@ -978,7 +990,7 @@ class String
978
990
  # The `options` are optional keyword options (see below).
979
991
  #
980
992
  # With no argument given and keyword `encoding` also not given, returns an empty
981
- # string with the Encoding `ASCII-8BIT`:
993
+ # string with the Encoding <code>ASCII-8BIT</code>:
982
994
  #
983
995
  # s = String.new # => ""
984
996
  # s.encoding # => #<Encoding:ASCII-8BIT>
@@ -991,9 +1003,10 @@ class String
991
1003
  # s1.encoding # => #<Encoding:UTF-16 (dummy)>
992
1004
  #
993
1005
  # (Unlike String.new, a [string
994
- # literal](rdoc-ref:syntax/literals.rdoc@String+Literals) like `''` or a [here
995
- # document literal](rdoc-ref:syntax/literals.rdoc@Here+Document+Literals) always
996
- # has [script encoding](rdoc-ref:encodings.rdoc@Script+Encoding).)
1006
+ # literal](rdoc-ref:syntax/literals.rdoc@String+Literals) like <code>''</code>
1007
+ # or a [here document
1008
+ # literal](rdoc-ref:syntax/literals.rdoc@Here+Document+Literals) always has
1009
+ # [script encoding](rdoc-ref:encodings.rdoc@Script+Encoding).)
997
1010
  #
998
1011
  # With keyword option `encoding` given, returns a string with the specified
999
1012
  # encoding; the `encoding` may be an Encoding object, an encoding name, or an
@@ -1094,7 +1107,7 @@ class String
1094
1107
  # Returns `self` if `self` is not frozen and can be mutated without warning
1095
1108
  # issuance.
1096
1109
  #
1097
- # Otherwise returns `self.dup`, which is not frozen.
1110
+ # Otherwise returns <code>self.dup</code>, which is not frozen.
1098
1111
  #
1099
1112
  # Related: see [Freezing/Unfreezing](rdoc-ref:String@Freezing-2FUnfreezing).
1100
1113
  #
@@ -1154,8 +1167,9 @@ class String
1154
1167
  # s = 'foo'
1155
1168
  # s << 33 # => "foo!"
1156
1169
  #
1157
- # Additionally, if the codepoint is in range `0..0xff` and the encoding of
1158
- # `self` is Encoding::US_ASCII, changes the encoding to Encoding::ASCII_8BIT:
1170
+ # Additionally, if the codepoint is in range <code>0..0xff</code> and the
1171
+ # encoding of `self` is Encoding::US_ASCII, changes the encoding to
1172
+ # Encoding::ASCII_8BIT:
1159
1173
  #
1160
1174
  # s = 'foo'.encode(Encoding::US_ASCII)
1161
1175
  # s.encoding # => #<Encoding:US-ASCII>
@@ -1183,7 +1197,7 @@ class String
1183
1197
  #
1184
1198
  # Returns:
1185
1199
  #
1186
- # * `-1`, if `self` is smaller.
1200
+ # * <code>-1</code>, if `self` is smaller.
1187
1201
  # * `0`, if the two are equal.
1188
1202
  # * `1`, if `self` is larger.
1189
1203
  # * `nil`, if the two are incomparable.
@@ -1225,8 +1239,8 @@ class String
1225
1239
  #
1226
1240
  # When `object` is not a string:
1227
1241
  #
1228
- # * If `object` responds to method `to_str`, `object == self` is called and
1229
- # its return value is returned.
1242
+ # * If `object` responds to method `to_str`, <code>object == self</code> is
1243
+ # called and its return value is returned.
1230
1244
  # * If `object` does not respond to `to_str`, `false` is returned.
1231
1245
  #
1232
1246
  # Related: [Comparing](rdoc-ref:String@Comparing).
@@ -1250,8 +1264,8 @@ class String
1250
1264
  #
1251
1265
  # When `object` is not a string:
1252
1266
  #
1253
- # * If `object` responds to method `to_str`, `object == self` is called and
1254
- # its return value is returned.
1267
+ # * If `object` responds to method `to_str`, <code>object == self</code> is
1268
+ # called and its return value is returned.
1255
1269
  # * If `object` does not respond to `to_str`, `false` is returned.
1256
1270
  #
1257
1271
  # Related: [Comparing](rdoc-ref:String@Comparing).
@@ -1273,8 +1287,8 @@ class String
1273
1287
  # 'foo' =~ /x/ # => nil
1274
1288
  # $~ # => nil
1275
1289
  #
1276
- # Note that `string =~ regexp` is different from `regexp =~ string` (see
1277
- # Regexp#=~):
1290
+ # Note that <code>string =~ regexp</code> is different from <code>regexp =~
1291
+ # string</code> (see Regexp#=~):
1278
1292
  #
1279
1293
  # number = nil
1280
1294
  # 'no. 9' =~ /(?<number>\d+)/ # => 4
@@ -1282,7 +1296,8 @@ class String
1282
1296
  # /(?<number>\d+)/ =~ 'no. 9' # => 4
1283
1297
  # number # => "9" # Assigned.
1284
1298
  #
1285
- # If `object` is not a Regexp, returns the value returned by `object =~ self`.
1299
+ # If `object` is not a Regexp, returns the value returned by <code>object =~
1300
+ # self</code>.
1286
1301
  #
1287
1302
  # Related: see [Querying](rdoc-ref:String@Querying).
1288
1303
  #
@@ -1303,7 +1318,7 @@ class String
1303
1318
  # -->
1304
1319
  # Returns the substring of `self` specified by the arguments.
1305
1320
  #
1306
- # **Form `self[index]`**
1321
+ # <strong>Form <code>self[index]</code></strong>
1307
1322
  #
1308
1323
  # With non-negative integer argument `index` given, returns the 1-character
1309
1324
  # substring found in self at character offset index:
@@ -1321,7 +1336,7 @@ class String
1321
1336
  # 'hello'[-5] # => "h"
1322
1337
  # 'hello'[-6] # => nil
1323
1338
  #
1324
- # **Form `self[start, length]`**
1339
+ # <strong>Form <code>self[start, length]</code></strong>
1325
1340
  #
1326
1341
  # With integer arguments `start` and `length` given, returns a substring of size
1327
1342
  # `length` characters (as available) beginning at character offset specified by
@@ -1348,10 +1363,10 @@ class String
1348
1363
  #
1349
1364
  # 'hello'[5, 3] # => ""
1350
1365
  #
1351
- # **Form `self[range]`**
1366
+ # <strong>Form <code>self[range]</code></strong>
1352
1367
  #
1353
- # With Range argument `range` given, forms substring `self[range.start,
1354
- # range.size]`:
1368
+ # With Range argument `range` given, forms substring <code>self[range.start,
1369
+ # range.size]</code>:
1355
1370
  #
1356
1371
  # 'hello'[0..2] # => "hel"
1357
1372
  # 'hello'[0, 3] # => "hel"
@@ -1362,7 +1377,7 @@ class String
1362
1377
  # 'hello'[0, 0] # => ""
1363
1378
  # 'hello'[0...0] # => ""
1364
1379
  #
1365
- # **Form `self[regexp, capture = 0]`**
1380
+ # <strong>Form <code>self[regexp, capture = 0]</code></strong>
1366
1381
  #
1367
1382
  # With Regexp argument `regexp` given and `capture` as zero, searches for a
1368
1383
  # matching substring in `self`; updates [Regexp-related global
@@ -1384,7 +1399,7 @@ class String
1384
1399
  # 'hello'[/(h)(e)(l+)(o)/, 4] # => "o"
1385
1400
  # 'hello'[/(h)(e)(l+)(o)/, 5] # => nil
1386
1401
  #
1387
- # **Form `self[substring]`**
1402
+ # <strong>Form <code>self[substring]</code></strong>
1388
1403
  #
1389
1404
  # With string argument `substring` given, returns the matching substring of
1390
1405
  # `self`, if found:
@@ -1414,7 +1429,7 @@ class String
1414
1429
  # Returns `self` with all, a substring, or none of its contents replaced;
1415
1430
  # returns the argument `other_string`.
1416
1431
  #
1417
- # **Form `self[index] = other_string`**
1432
+ # <strong>Form <code>self[index] = other_string</code></strong>
1418
1433
  #
1419
1434
  # With non-negative integer argument `index` given, searches for the 1-character
1420
1435
  # substring found in self at character offset index:
@@ -1448,7 +1463,7 @@ class String
1448
1463
  # s = 'hello'
1449
1464
  # s[-6] = 'foo' # Raises IndexError: index -6 out of string.
1450
1465
  #
1451
- # **Form `self[start, length] = other_string`**
1466
+ # <strong>Form <code>self[start, length] = other_string</code></strong>
1452
1467
  #
1453
1468
  # With integer arguments `start` and `length` given, searches for a substring of
1454
1469
  # size `length` characters (as available) beginning at character offset
@@ -1503,10 +1518,10 @@ class String
1503
1518
  # s[5, 3] = 'foo' # => "foo"
1504
1519
  # s # => "hellofoo"
1505
1520
  #
1506
- # **Form `self[range] = other_string`**
1521
+ # <strong>Form <code>self[range] = other_string</code></strong>
1507
1522
  #
1508
- # With Range argument `range` given, equivalent to `self[range.start,
1509
- # range.size] = other_string`:
1523
+ # With Range argument `range` given, equivalent to <code>self[range.start,
1524
+ # range.size] = other_string</code>:
1510
1525
  #
1511
1526
  # s0 = 'hello'
1512
1527
  # s1 = 'hello'
@@ -1526,7 +1541,7 @@ class String
1526
1541
  # s = 'hello'
1527
1542
  # s[9..10] = 'foo' # Raises RangeError: 9..10 out of range
1528
1543
  #
1529
- # **Form `self[regexp, capture = 0] = other_string`**
1544
+ # <strong>Form <code>self[regexp, capture = 0] = other_string</code></strong>
1530
1545
  #
1531
1546
  # With Regexp argument `regexp` given and `capture` as zero, searches for a
1532
1547
  # matching substring in `self`; updates [Regexp-related global
@@ -1569,7 +1584,7 @@ class String
1569
1584
  # s = 'hello'
1570
1585
  # s[/nosuch/] = 'foo' # Raises IndexError: regexp not matched.
1571
1586
  #
1572
- # **Form `self[substring] = other_string`**
1587
+ # <strong>Form <code>self[substring] = other_string</code></strong>
1573
1588
  #
1574
1589
  # With string argument `substring` given:
1575
1590
  #
@@ -1623,7 +1638,7 @@ class String
1623
1638
  #
1624
1639
  # Related: see [Modifying](rdoc-ref:String@Modifying).
1625
1640
  #
1626
- def append_as_bytes: (String) -> String
1641
+ def append_as_bytes: (*String | Integer) -> String
1627
1642
 
1628
1643
  # <!--
1629
1644
  # rdoc-file=string.c
@@ -1884,8 +1899,8 @@ class String
1884
1899
  # s.byteslice(-4) # => "6"
1885
1900
  # s.byteslice(-4, 3) # => "678"
1886
1901
  #
1887
- # With Range argument `range` given, returns `byteslice(range.begin,
1888
- # range.size)`:
1902
+ # With Range argument `range` given, returns <code>byteslice(range.begin,
1903
+ # range.size)</code>:
1889
1904
  #
1890
1905
  # s = '0123456789' # => "0123456789"
1891
1906
  # s.byteslice(4..6) # => "456"
@@ -2019,8 +2034,9 @@ class String
2019
2034
  # s = 'こんにちは'
2020
2035
  # s.capitalize == s # => true
2021
2036
  #
2022
- # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
2023
- # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
2037
+ # The casing is affected by the given `mapping`, which may be
2038
+ # <code>:ascii</code>, <code>:fold</code>, or <code>:turkic</code>; see [Case
2039
+ # Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
2024
2040
  #
2025
2041
  # Related: see [Converting to New
2026
2042
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -2052,9 +2068,11 @@ class String
2052
2068
  # -->
2053
2069
  # Ignoring case, compares `self` and `other_string`; returns:
2054
2070
  #
2055
- # * -1 if `self.downcase` is smaller than `other_string.downcase`.
2071
+ # * -1 if <code>self.downcase</code> is smaller than
2072
+ # <code>other_string.downcase</code>.
2056
2073
  # * 0 if the two are equal.
2057
- # * 1 if `self.downcase` is larger than `other_string.downcase`.
2074
+ # * 1 if <code>self.downcase</code> is larger than
2075
+ # <code>other_string.downcase</code>.
2058
2076
  # * `nil` if the two are incomparable.
2059
2077
  #
2060
2078
  # See [Case Mapping](rdoc-ref:case_mapping.rdoc).
@@ -2151,8 +2169,9 @@ class String
2151
2169
  # Returns a new string copied from `self`, with trailing characters possibly
2152
2170
  # removed:
2153
2171
  #
2154
- # When `line_sep` is `"\n"`, removes the last one or two characters if they are
2155
- # `"\r"`, `"\n"`, or `"\r\n"` (but not `"\n\r"`):
2172
+ # When `line_sep` is <code>"\n"</code>, removes the last one or two characters
2173
+ # if they are <code>"\r"</code>, <code>"\n"</code>, or <code>"\r\n"</code> (but
2174
+ # not <code>"\n\r"</code>):
2156
2175
  #
2157
2176
  # $/ # => "\n"
2158
2177
  # "abc\r".chomp # => "abc"
@@ -2162,8 +2181,9 @@ class String
2162
2181
  # "тест\r\n".chomp # => "тест"
2163
2182
  # "こんにちは\r\n".chomp # => "こんにちは"
2164
2183
  #
2165
- # When `line_sep` is `''` (an empty string), removes multiple trailing
2166
- # occurrences of `"\n"` or `"\r\n"` (but not `"\r"` or `"\n\r"`):
2184
+ # When `line_sep` is <code>''</code> (an empty string), removes multiple
2185
+ # trailing occurrences of <code>"\n"</code> or <code>"\r\n"</code> (but not
2186
+ # <code>"\r"</code> or <code>"\n\r"</code>):
2167
2187
  #
2168
2188
  # "abc\n\n\n".chomp('') # => "abc"
2169
2189
  # "abc\r\n\r\n\r\n".chomp('') # => "abc"
@@ -2171,8 +2191,8 @@ class String
2171
2191
  # "abc\n\r\n\r\n\r".chomp('') # => "abc\n\r\n\r\n\r"
2172
2192
  # "abc\r\r\r".chomp('') # => "abc\r\r\r"
2173
2193
  #
2174
- # When `line_sep` is neither `"\n"` nor `''`, removes a single trailing line
2175
- # separator if there is one:
2194
+ # When `line_sep` is neither <code>"\n"</code> nor <code>''</code>, removes a
2195
+ # single trailing line separator if there is one:
2176
2196
  #
2177
2197
  # 'abcd'.chomp('cd') # => "ab"
2178
2198
  # 'abcdcd'.chomp('cd') # => "abcd"
@@ -2205,7 +2225,7 @@ class String
2205
2225
  # Returns a new string copied from `self`, with trailing characters possibly
2206
2226
  # removed.
2207
2227
  #
2208
- # Removes `"\r\n"` if those are the last two characters.
2228
+ # Removes <code>"\r\n"</code> if those are the last two characters.
2209
2229
  #
2210
2230
  # "abc\r\n".chop # => "abc"
2211
2231
  # "тест\r\n".chop # => "тест"
@@ -2356,20 +2376,20 @@ class String
2356
2376
  #
2357
2377
  # In a character selector, three characters get special treatment:
2358
2378
  #
2359
- # * A caret (`'^'`) functions as a *negation* operator for the immediately
2360
- # following characters:
2379
+ # * A caret (<code>'^'</code>) functions as a *negation* operator for the
2380
+ # immediately following characters:
2361
2381
  #
2362
2382
  # s = 'abracadabra'
2363
2383
  # s.count('^bc') # => 8 # Count of all except 'b' and 'c'.
2364
2384
  #
2365
- # * A hyphen (`'-'`) between two other characters defines a *range* of
2366
- # characters:
2385
+ # * A hyphen (<code>'-'</code>) between two other characters defines a *range*
2386
+ # of characters:
2367
2387
  #
2368
2388
  # s = 'abracadabra'
2369
2389
  # s.count('a-c') # => 8 # Count of all 'a', 'b', and 'c'.
2370
2390
  #
2371
- # * A backslash (`'\'`) acts as an escape for a caret, a hyphen, or another
2372
- # backslash:
2391
+ # * A backslash (<code>'\'</code>) acts as an escape for a caret, a hyphen, or
2392
+ # another backslash:
2373
2393
  #
2374
2394
  # s = 'abracadabra'
2375
2395
  # s.count('\^bc') # => 3 # Count of '^', 'b', and 'c'.
@@ -2399,24 +2419,24 @@ class String
2399
2419
  # rdoc-file=string.c
2400
2420
  # - crypt(salt_str) -> new_string
2401
2421
  # -->
2402
- # Returns the string generated by calling `crypt(3)` standard library function
2403
- # with `str` and `salt_str`, in this order, as its arguments. Please do not use
2404
- # this method any longer. It is legacy; provided only for backward
2422
+ # Returns the string generated by calling <code>crypt(3)</code> standard library
2423
+ # function with `str` and `salt_str`, in this order, as its arguments. Please
2424
+ # do not use this method any longer. It is legacy; provided only for backward
2405
2425
  # compatibility with ruby scripts in earlier days. It is bad to use in
2406
2426
  # contemporary programs for several reasons:
2407
2427
  #
2408
- # * Behaviour of C's `crypt(3)` depends on the OS it is run. The generated
2409
- # string lacks data portability.
2428
+ # * Behaviour of C's <code>crypt(3)</code> depends on the OS it is run. The
2429
+ # generated string lacks data portability.
2410
2430
  #
2411
- # * On some OSes such as Mac OS, `crypt(3)` never fails (i.e. silently ends up
2412
- # in unexpected results).
2431
+ # * On some OSes such as Mac OS, <code>crypt(3)</code> never fails (i.e.
2432
+ # silently ends up in unexpected results).
2413
2433
  #
2414
- # * On some OSes such as Mac OS, `crypt(3)` is not thread safe.
2434
+ # * On some OSes such as Mac OS, <code>crypt(3)</code> is not thread safe.
2415
2435
  #
2416
- # * So-called "traditional" usage of `crypt(3)` is very very very weak.
2417
- # According to its manpage, Linux's traditional `crypt(3)` output has only
2418
- # 2**56 variations; too easy to brute force today. And this is the default
2419
- # behaviour.
2436
+ # * So-called "traditional" usage of <code>crypt(3)</code> is very very very
2437
+ # weak. According to its manpage, Linux's traditional <code>crypt(3)</code>
2438
+ # output has only 2**56 variations; too easy to brute force today. And this
2439
+ # is the default behaviour.
2420
2440
  #
2421
2441
  # * In order to make things robust some OSes implement so-called "modular"
2422
2442
  # usage. To go through, you have to do a complex build-up of the `salt_str`
@@ -2431,22 +2451,24 @@ class String
2431
2451
  # "foo".crypt("$5$round=1000$salt$") # Typo not detected
2432
2452
  #
2433
2453
  # * Even in the "modular" mode, some hash functions are considered archaic and
2434
- # no longer recommended at all; for instance module `$1$` is officially
2435
- # abandoned by its author: see http://phk.freebsd.dk/sagas/md5crypt_eol/ .
2436
- # For another instance module `$3$` is considered completely broken: see the
2437
- # manpage of FreeBSD.
2454
+ # no longer recommended at all; for instance module <code>$1$</code> is
2455
+ # officially abandoned by its author: see
2456
+ # http://phk.freebsd.dk/sagas/md5crypt_eol/ . For another instance module
2457
+ # <code>$3$</code> is considered completely broken: see the manpage of
2458
+ # FreeBSD.
2438
2459
  #
2439
2460
  # * On some OS such as Mac OS, there is no modular mode. Yet, as written
2440
- # above, `crypt(3)` on Mac OS never fails. This means even if you build up a
2441
- # proper salt string it generates a traditional DES hash anyways, and there
2442
- # is no way for you to be aware of.
2461
+ # above, <code>crypt(3)</code> on Mac OS never fails. This means even if you
2462
+ # build up a proper salt string it generates a traditional DES hash anyways,
2463
+ # and there is no way for you to be aware of.
2443
2464
  #
2444
2465
  # "foo".crypt("$5$rounds=1000$salt$") # => "$5fNPQMxC5j6."
2445
2466
  #
2446
2467
  # If for some reason you cannot migrate to other secure contemporary password
2447
- # hashing algorithms, install the string-crypt gem and `require 'string/crypt'`
2448
- # to continue using it.
2468
+ # hashing algorithms, install the string-crypt gem and <code>require
2469
+ # 'string/crypt'</code> to continue using it.
2449
2470
  #
2471
+ %a{deprecated}
2450
2472
  def crypt: (string salt_str) -> String
2451
2473
 
2452
2474
  # <!-- rdoc-file=string.c -->
@@ -2531,20 +2553,20 @@ class String
2531
2553
  #
2532
2554
  # In a character selector, three characters get special treatment:
2533
2555
  #
2534
- # * A caret (`'^'`) functions as a *negation* operator for the immediately
2535
- # following characters:
2556
+ # * A caret (<code>'^'</code>) functions as a *negation* operator for the
2557
+ # immediately following characters:
2536
2558
  #
2537
2559
  # s = 'abracadabra'
2538
2560
  # s.delete('^bc') # => "bcb" # Deletes all except 'b' and 'c'.
2539
2561
  #
2540
- # * A hyphen (`'-'`) between two other characters defines a *range* of
2541
- # characters:
2562
+ # * A hyphen (<code>'-'</code>) between two other characters defines a *range*
2563
+ # of characters:
2542
2564
  #
2543
2565
  # s = 'abracadabra'
2544
2566
  # s.delete('a-c') # => "rdr" # Deletes all 'a', 'b', and 'c'.
2545
2567
  #
2546
- # * A backslash (`'\'`) acts as an escape for a caret, a hyphen, or another
2547
- # backslash:
2568
+ # * A backslash (<code>'\'</code>) acts as an escape for a caret, a hyphen, or
2569
+ # another backslash:
2548
2570
  #
2549
2571
  # s = 'abracadabra'
2550
2572
  # s.delete('\^bc') # => "araadara" # Deletes all '^', 'b', and 'c'.
@@ -2660,8 +2682,9 @@ class String
2660
2682
  # s = 'こんにちは'
2661
2683
  # s.downcase == s # => true
2662
2684
  #
2663
- # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
2664
- # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
2685
+ # The casing is affected by the given `mapping`, which may be
2686
+ # <code>:ascii</code>, <code>:fold</code>, or <code>:turkic</code>; see [Case
2687
+ # Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
2665
2688
  #
2666
2689
  # Related: see [Converting to New
2667
2690
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -2722,7 +2745,7 @@ class String
2722
2745
  # print "Undumped: ", s.dump.undump, "\n"
2723
2746
  # end
2724
2747
  #
2725
- # So that for string `'hello'`, we'll see:
2748
+ # So that for string <code>'hello'</code>, we'll see:
2726
2749
  #
2727
2750
  # String: hello
2728
2751
  # Dumped: "hello"
@@ -2773,10 +2796,11 @@ class String
2773
2796
  # Undumped: こんにちは
2774
2797
  #
2775
2798
  # If the encoding of `self` is not ASCII-compatible (i.e., if
2776
- # `self.encoding.ascii_compatible?` returns `false`), each ASCII-compatible byte
2777
- # is dumped as an ASCII character, and all other bytes are dumped as
2778
- # hexadecimal; also appends `.dup.force_encoding(\"encoding\")`, where
2779
- # `<encoding>` is `self.encoding.name`:
2799
+ # <code>self.encoding.ascii_compatible?</code> returns `false`), each
2800
+ # ASCII-compatible byte is dumped as an ASCII character, and all other bytes are
2801
+ # dumped as hexadecimal; also appends
2802
+ # <code>.dup.force_encoding(\"encoding\")</code>, where <code><encoding></code>
2803
+ # is <code>self.encoding.name</code>:
2780
2804
  #
2781
2805
  # String: hello
2782
2806
  # Dumped: "\xFE\xFF\x00h\x00e\x00l\x00l\x00o".dup.force_encoding("UTF-16")
@@ -3016,8 +3040,8 @@ class String
3016
3040
  #
3017
3041
  # With no arguments:
3018
3042
  #
3019
- # * Uses the same encoding if `Encoding.default_internal` is `nil` (the
3020
- # default):
3043
+ # * Uses the same encoding if <code>Encoding.default_internal</code> is `nil`
3044
+ # (the default):
3021
3045
  #
3022
3046
  # Encoding.default_internal # => nil
3023
3047
  # s = "Ruby\x99".force_encoding('Windows-1252')
@@ -3027,7 +3051,7 @@ class String
3027
3051
  # t.encoding # => #<Encoding:Windows-1252>
3028
3052
  # t.bytes # => [82, 117, 98, 121, 226, 132, 162]
3029
3053
  #
3030
- # * Otherwise, uses the encoding `Encoding.default_internal`:
3054
+ # * Otherwise, uses the encoding <code>Encoding.default_internal</code>:
3031
3055
  #
3032
3056
  # Encoding.default_internal = 'UTF-8'
3033
3057
  # t = s.encode # => "Ruby™"
@@ -3050,11 +3074,11 @@ class String
3050
3074
  # Optional keyword arguments `enc_opts` specify encoding options; see [Encoding
3051
3075
  # Options](rdoc-ref:encodings.rdoc@Encoding+Options).
3052
3076
  #
3053
- # Please note that, unless `invalid: :replace` option is given, conversion from
3054
- # an encoding `enc` to the same encoding `enc` (independent of whether `enc` is
3055
- # given explicitly or implicitly) is a no-op, i.e. the string is simply copied
3056
- # without any changes, and no exceptions are raised, even if there are invalid
3057
- # bytes.
3077
+ # Please note that, unless <code>invalid: :replace</code> option is given,
3078
+ # conversion from an encoding `enc` to the same encoding `enc` (independent of
3079
+ # whether `enc` is given explicitly or implicitly) is a no-op, i.e. the string
3080
+ # is simply copied without any changes, and no exceptions are raised, even if
3081
+ # there are invalid bytes.
3058
3082
  #
3059
3083
  # Related: see [Converting to New
3060
3084
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -3350,9 +3374,9 @@ class String
3350
3374
  # The leading substring is interpreted as hexadecimal when it begins with:
3351
3375
  #
3352
3376
  # * One or more character representing hexadecimal digits (each in one of the
3353
- # ranges `'0'..'9'`, `'a'..'f'`, or `'A'..'F'`); the string to be
3354
- # interpreted ends at the first character that does not represent a
3355
- # hexadecimal digit:
3377
+ # ranges <code>'0'..'9'</code>, <code>'a'..'f'</code>, or
3378
+ # <code>'A'..'F'</code>); the string to be interpreted ends at the first
3379
+ # character that does not represent a hexadecimal digit:
3356
3380
  #
3357
3381
  # 'f'.hex # => 15
3358
3382
  # '11'.hex # => 17
@@ -3362,12 +3386,14 @@ class String
3362
3386
  # 'bar'.hex # => 186 # 'ba' hexadecimal, 'r' not.
3363
3387
  # 'deadbeef'.hex # => 3735928559
3364
3388
  #
3365
- # * `'0x'` or `'0X'`, followed by one or more hexadecimal digits:
3389
+ # * <code>'0x'</code> or <code>'0X'</code>, followed by one or more
3390
+ # hexadecimal digits:
3366
3391
  #
3367
3392
  # '0xfff'.hex # => 4095
3368
3393
  # '0xfffg'.hex # => 4095
3369
3394
  #
3370
- # Any of the above may prefixed with `'-'`, which negates the interpreted value:
3395
+ # Any of the above may prefixed with <code>'-'</code>, which negates the
3396
+ # interpreted value:
3371
3397
  #
3372
3398
  # '-fff'.hex # => -4095
3373
3399
  # '-0xFFF'.hex # => -4095
@@ -3495,15 +3521,15 @@ class String
3495
3521
  # 'тест'.inspect # => "\"тест\""
3496
3522
  # 'こんにちは'.inspect # => "\"こんにちは\""
3497
3523
  #
3498
- # But printable characters double-quote (`'"'`) and backslash and (`'\\'`) are
3499
- # escaped:
3524
+ # But printable characters double-quote (<code>'"'</code>) and backslash and
3525
+ # (<code>'\'</code>) are escaped:
3500
3526
  #
3501
3527
  # '"'.inspect # => "\"\\\"\""
3502
3528
  # '\\'.inspect # => "\"\\\\\""
3503
3529
  #
3504
3530
  # Unprintable characters are the [ASCII
3505
3531
  # characters](https://en.wikipedia.org/wiki/ASCII) whose values are in range
3506
- # `0..31`, along with the character whose value is `127`.
3532
+ # <code>0..31</code>, along with the character whose value is `127`.
3507
3533
  #
3508
3534
  # Most of these characters are rendered thus:
3509
3535
  #
@@ -3630,7 +3656,7 @@ class String
3630
3656
  # 'тест'.ljust(10) # => "тест "
3631
3657
  # 'こんにちは'.ljust(10) # => "こんにちは "
3632
3658
  #
3633
- # If `width <= self.length`, returns a copy of `self`:
3659
+ # If <code>width <= self.length</code>, returns a copy of `self`:
3634
3660
  #
3635
3661
  # 'hello'.ljust(5) # => "hello"
3636
3662
  # 'hello'.ljust(1) # => "hello" # Does not truncate to width.
@@ -3669,7 +3695,7 @@ class String
3669
3695
  # Related: see [Converting to New
3670
3696
  # String](rdoc-ref:String@Converting+to+New+String).
3671
3697
  #
3672
- def lstrip: () -> String
3698
+ def lstrip: (*selector) -> String
3673
3699
 
3674
3700
  # <!--
3675
3701
  # rdoc-file=string.c
@@ -3682,7 +3708,7 @@ class String
3682
3708
  #
3683
3709
  # Related: see [Modifying](rdoc-ref:String@Modifying).
3684
3710
  #
3685
- def lstrip!: () -> self?
3711
+ def lstrip!: (*selector) -> self?
3686
3712
 
3687
3713
  # <!--
3688
3714
  # rdoc-file=string.c
@@ -3734,8 +3760,8 @@ class String
3734
3760
  #
3735
3761
  # regexp = Regexp.new(pattern)
3736
3762
  #
3737
- # Returns `true` if `self[offset..].match(regexp)` returns a MatchData object,
3738
- # `false` otherwise:
3763
+ # Returns `true` if <code>self[offset..].match(regexp)</code> returns a
3764
+ # MatchData object, `false` otherwise:
3739
3765
  #
3740
3766
  # 'foo'.match?(/o/) # => true
3741
3767
  # 'foo'.match?('o') # => true
@@ -3834,8 +3860,8 @@ class String
3834
3860
  # The leading substring is interpreted as octal when it begins with:
3835
3861
  #
3836
3862
  # * One or more character representing octal digits (each in the range
3837
- # `'0'..'7'`); the string to be interpreted ends at the first character that
3838
- # does not represent an octal digit:
3863
+ # <code>'0'..'7'</code>); the string to be interpreted ends at the first
3864
+ # character that does not represent an octal digit:
3839
3865
  #
3840
3866
  # '7'.oct @ => 7
3841
3867
  # '11'.oct # => 9
@@ -3844,39 +3870,41 @@ class String
3844
3870
  # '7778'.oct # => 511
3845
3871
  # '777x'.oct # => 511
3846
3872
  #
3847
- # * `'0o'`, followed by one or more octal digits:
3873
+ # * <code>'0o'</code>, followed by one or more octal digits:
3848
3874
  #
3849
3875
  # '0o777'.oct # => 511
3850
3876
  # '0o7778'.oct # => 511
3851
3877
  #
3852
3878
  # The leading substring is *not* interpreted as octal when it begins with:
3853
3879
  #
3854
- # * `'0b'`, followed by one or more characters representing binary digits
3855
- # (each in the range `'0'..'1'`); the string to be interpreted ends at the
3856
- # first character that does not represent a binary digit. the string is
3857
- # interpreted as binary digits (base 2):
3880
+ # * <code>'0b'</code>, followed by one or more characters representing binary
3881
+ # digits (each in the range <code>'0'..'1'</code>); the string to be
3882
+ # interpreted ends at the first character that does not represent a binary
3883
+ # digit. the string is interpreted as binary digits (base 2):
3858
3884
  #
3859
3885
  # '0b111'.oct # => 7
3860
3886
  # '0b1112'.oct # => 7
3861
3887
  #
3862
- # * `'0d'`, followed by one or more characters representing decimal digits
3863
- # (each in the range `'0'..'9'`); the string to be interpreted ends at the
3864
- # first character that does not represent a decimal digit. the string is
3865
- # interpreted as decimal digits (base 10):
3888
+ # * <code>'0d'</code>, followed by one or more characters representing decimal
3889
+ # digits (each in the range <code>'0'..'9'</code>); the string to be
3890
+ # interpreted ends at the first character that does not represent a decimal
3891
+ # digit. the string is interpreted as decimal digits (base 10):
3866
3892
  #
3867
3893
  # '0d999'.oct # => 999
3868
3894
  # '0d999x'.oct # => 999
3869
3895
  #
3870
- # * `'0x'`, followed by one or more characters representing hexadecimal digits
3871
- # (each in one of the ranges `'0'..'9'`, `'a'..'f'`, or `'A'..'F'`); the
3872
- # string to be interpreted ends at the first character that does not
3873
- # represent a hexadecimal digit. the string is interpreted as hexadecimal
3874
- # digits (base 16):
3896
+ # * <code>'0x'</code>, followed by one or more characters representing
3897
+ # hexadecimal digits (each in one of the ranges <code>'0'..'9'</code>,
3898
+ # <code>'a'..'f'</code>, or <code>'A'..'F'</code>); the string to be
3899
+ # interpreted ends at the first character that does not represent a
3900
+ # hexadecimal digit. the string is interpreted as hexadecimal digits (base
3901
+ # 16):
3875
3902
  #
3876
3903
  # '0xfff'.oct # => 4095
3877
3904
  # '0xfffg'.oct # => 4095
3878
3905
  #
3879
- # Any of the above may prefixed with `'-'`, which negates the interpreted value:
3906
+ # Any of the above may prefixed with <code>'-'</code>, which negates the
3907
+ # interpreted value:
3880
3908
  #
3881
3909
  # '-777'.oct # => -511
3882
3910
  # '-0777'.oct # => -511
@@ -3928,11 +3956,11 @@ class String
3928
3956
  #
3929
3957
  # [self.dup, "", ""]
3930
3958
  #
3931
- # Note that in the examples below, a returned string `'hello'` is a copy of
3932
- # `self`, not `self`.
3959
+ # Note that in the examples below, a returned string <code>'hello'</code> is a
3960
+ # copy of `self`, not `self`.
3933
3961
  #
3934
- # If `pattern` is a Regexp, performs the equivalent of `self.match(pattern)`
3935
- # (also setting [matched-data
3962
+ # If `pattern` is a Regexp, performs the equivalent of
3963
+ # <code>self.match(pattern)</code> (also setting [matched-data
3936
3964
  # variables](rdoc-ref:language/globals.md@Matched+Data)):
3937
3965
  #
3938
3966
  # 'hello'.partition(/h/) # => ["", "h", "ello"]
@@ -3945,8 +3973,8 @@ class String
3945
3973
  # 'hello'.partition(/x/) # => ["hello", "", ""]
3946
3974
  #
3947
3975
  # If `pattern` is not a Regexp, converts it to a string (if it is not already
3948
- # one), then performs the equivalent of `self.index(pattern)` (and does *not*
3949
- # set [matched-data global
3976
+ # one), then performs the equivalent of <code>self.index(pattern)</code> (and
3977
+ # does *not* set [matched-data global
3950
3978
  # variables](rdoc-ref:language/globals.md@Matched+Data)):
3951
3979
  #
3952
3980
  # 'hello'.partition('h') # => ["", "h", "ello"]
@@ -4097,7 +4125,7 @@ class String
4097
4125
  # 'тест'.rjust(10) # => " тест"
4098
4126
  # 'こんにちは'.rjust(10) # => " こんにちは"
4099
4127
  #
4100
- # If `width <= self.size`, returns a copy of `self`:
4128
+ # If <code>width <= self.size</code>, returns a copy of `self`:
4101
4129
  #
4102
4130
  # 'hello'.rjust(5, 'ab') # => "hello"
4103
4131
  # 'hello'.rjust(1, 'ab') # => "hello"
@@ -4131,10 +4159,10 @@ class String
4131
4159
  # The pattern used is:
4132
4160
  #
4133
4161
  # * `pattern` itself, if it is a Regexp.
4134
- # * `Regexp.quote(pattern)`, if `pattern` is a string.
4162
+ # * <code>Regexp.quote(pattern)</code>, if `pattern` is a string.
4135
4163
  #
4136
- # Note that in the examples below, a returned string `'hello'` is a copy of
4137
- # `self`, not `self`.
4164
+ # Note that in the examples below, a returned string <code>'hello'</code> is a
4165
+ # copy of `self`, not `self`.
4138
4166
  #
4139
4167
  # If `pattern` is a Regexp, searches for the last matching substring (also
4140
4168
  # setting [matched-data global
@@ -4194,7 +4222,7 @@ class String
4194
4222
  # Related: see [Converting to New
4195
4223
  # String](rdoc-ref:String@Converting+to+New+String).
4196
4224
  #
4197
- def rstrip: () -> String
4225
+ def rstrip: (*selector) -> String
4198
4226
 
4199
4227
  # <!--
4200
4228
  # rdoc-file=string.c
@@ -4207,7 +4235,7 @@ class String
4207
4235
  #
4208
4236
  # Related: see [Modifying](rdoc-ref:String@Modifying).
4209
4237
  #
4210
- def rstrip!: () -> self?
4238
+ def rstrip!: (*selector) -> self?
4211
4239
 
4212
4240
  # <!--
4213
4241
  # rdoc-file=string.c
@@ -4217,7 +4245,8 @@ class String
4217
4245
  # Matches a pattern against `self`:
4218
4246
  #
4219
4247
  # * If `pattern` is a Regexp, the pattern used is `pattern` itself.
4220
- # * If `pattern` is a string, the pattern used is `Regexp.quote(pattern)`.
4248
+ # * If `pattern` is a string, the pattern used is
4249
+ # <code>Regexp.quote(pattern)</code>.
4221
4250
  #
4222
4251
  # Generates a collection of matching results and updates [regexp-related global
4223
4252
  # variables](rdoc-ref:Regexp@Global+Variables):
@@ -4266,8 +4295,8 @@ class String
4266
4295
  # `replacement_string`.
4267
4296
  #
4268
4297
  # With no block given, replaces each invalid sequence with the given
4269
- # `default_replacement_string` (by default, `"�"` for a Unicode encoding, `'?'`
4270
- # otherwise):
4298
+ # `default_replacement_string` (by default, <code>"�"</code> for a Unicode
4299
+ # encoding, <code>'?'</code> otherwise):
4271
4300
  #
4272
4301
  # "foo\x81\x81bar"scrub # => "foo��bar"
4273
4302
  # "foo\x81\x81bar".force_encoding('US-ASCII').scrub # => "foo??bar"
@@ -4339,7 +4368,7 @@ class String
4339
4368
  # <!-- rdoc-file=string.c -->
4340
4369
  # Returns the substring of `self` specified by the arguments.
4341
4370
  #
4342
- # **Form `self[index]`**
4371
+ # <strong>Form <code>self[index]</code></strong>
4343
4372
  #
4344
4373
  # With non-negative integer argument `index` given, returns the 1-character
4345
4374
  # substring found in self at character offset index:
@@ -4357,7 +4386,7 @@ class String
4357
4386
  # 'hello'[-5] # => "h"
4358
4387
  # 'hello'[-6] # => nil
4359
4388
  #
4360
- # **Form `self[start, length]`**
4389
+ # <strong>Form <code>self[start, length]</code></strong>
4361
4390
  #
4362
4391
  # With integer arguments `start` and `length` given, returns a substring of size
4363
4392
  # `length` characters (as available) beginning at character offset specified by
@@ -4384,10 +4413,10 @@ class String
4384
4413
  #
4385
4414
  # 'hello'[5, 3] # => ""
4386
4415
  #
4387
- # **Form `self[range]`**
4416
+ # <strong>Form <code>self[range]</code></strong>
4388
4417
  #
4389
- # With Range argument `range` given, forms substring `self[range.start,
4390
- # range.size]`:
4418
+ # With Range argument `range` given, forms substring <code>self[range.start,
4419
+ # range.size]</code>:
4391
4420
  #
4392
4421
  # 'hello'[0..2] # => "hel"
4393
4422
  # 'hello'[0, 3] # => "hel"
@@ -4398,7 +4427,7 @@ class String
4398
4427
  # 'hello'[0, 0] # => ""
4399
4428
  # 'hello'[0...0] # => ""
4400
4429
  #
4401
- # **Form `self[regexp, capture = 0]`**
4430
+ # <strong>Form <code>self[regexp, capture = 0]</code></strong>
4402
4431
  #
4403
4432
  # With Regexp argument `regexp` given and `capture` as zero, searches for a
4404
4433
  # matching substring in `self`; updates [Regexp-related global
@@ -4420,7 +4449,7 @@ class String
4420
4449
  # 'hello'[/(h)(e)(l+)(o)/, 4] # => "o"
4421
4450
  # 'hello'[/(h)(e)(l+)(o)/, 5] # => nil
4422
4451
  #
4423
- # **Form `self[substring]`**
4452
+ # <strong>Form <code>self[substring]</code></strong>
4424
4453
  #
4425
4454
  # With string argument `substring` given, returns the matching substring of
4426
4455
  # `self`, if found:
@@ -4473,15 +4502,15 @@ class String
4473
4502
  # Creates an array of substrings by splitting `self` at each occurrence of the
4474
4503
  # given field separator `field_sep`.
4475
4504
  #
4476
- # With no arguments given, splits using the field separator `$;`, whose default
4477
- # value is `nil`.
4505
+ # With no arguments given, splits using the field separator <code>$;</code>,
4506
+ # whose default value is `nil`.
4478
4507
  #
4479
4508
  # With no block given, returns the array of substrings:
4480
4509
  #
4481
4510
  # 'abracadabra'.split('a') # => ["", "br", "c", "d", "br"]
4482
4511
  #
4483
- # When `field_sep` is `nil` or `' '` (a single space), splits at each sequence
4484
- # of whitespace:
4512
+ # When `field_sep` is `nil` or <code>' '</code> (a single space), splits at each
4513
+ # sequence of whitespace:
4485
4514
  #
4486
4515
  # 'foo bar baz'.split(nil) # => ["foo", "bar", "baz"]
4487
4516
  # 'foo bar baz'.split(' ') # => ["foo", "bar", "baz"]
@@ -4496,8 +4525,8 @@ class String
4496
4525
  # 'тест'.split('') # => ["т", "е", "с", "т"]
4497
4526
  # 'こんにちは'.split('') # => ["こ", "ん", "に", "ち", "は"]
4498
4527
  #
4499
- # When `field_sep` is a non-empty string and different from `' '` (a single
4500
- # space), uses that string as the separator:
4528
+ # When `field_sep` is a non-empty string and different from <code>' '</code> (a
4529
+ # single space), uses that string as the separator:
4501
4530
  #
4502
4531
  # 'abracadabra'.split('a') # => ["", "br", "c", "d", "br"]
4503
4532
  # 'abracadabra'.split('ab') # => ["", "racad", "ra"]
@@ -4527,7 +4556,8 @@ class String
4527
4556
  # 'abracadabra'.split('a', 0) # => ["", "br", "c", "d", "br"] # Empty string after last 'a' omitted.
4528
4557
  #
4529
4558
  # When `limit` is a positive integer, there is a limit on the size of the array
4530
- # (no more than `n - 1` splits occur), and trailing empty strings are included:
4559
+ # (no more than <code>n - 1</code> splits occur), and trailing empty strings are
4560
+ # included:
4531
4561
  #
4532
4562
  # 'abracadabra'.split('', 3) # => ["a", "b", "racadabra"]
4533
4563
  # 'abracadabra'.split('a', 3) # => ["", "br", "cadabra"]
@@ -4636,7 +4666,7 @@ class String
4636
4666
  # For each argument, the pattern used is:
4637
4667
  #
4638
4668
  # * The pattern itself, if it is a Regexp.
4639
- # * `Regexp.quote(pattern)`, if it is a string.
4669
+ # * <code>Regexp.quote(pattern)</code>, if it is a string.
4640
4670
  #
4641
4671
  # Returns `true` if any pattern matches the beginning, `false` otherwise:
4642
4672
  #
@@ -4680,7 +4710,7 @@ class String
4680
4710
  # Related: see [Converting to New
4681
4711
  # String](rdoc-ref:String@Converting+to+New+String).
4682
4712
  #
4683
- def strip: () -> String
4713
+ def strip: (*selector) -> String
4684
4714
 
4685
4715
  # <!--
4686
4716
  # rdoc-file=string.c
@@ -4693,7 +4723,7 @@ class String
4693
4723
  #
4694
4724
  # Related: see [Modifying](rdoc-ref:String@Modifying).
4695
4725
  #
4696
- def strip!: () -> self?
4726
+ def strip!: (*selector) -> self?
4697
4727
 
4698
4728
  # <!--
4699
4729
  # rdoc-file=string.c
@@ -4829,7 +4859,7 @@ class String
4829
4859
  # -->
4830
4860
  # Returns a basic `n`-bit [checksum](https://en.wikipedia.org/wiki/Checksum) of
4831
4861
  # the characters in `self`; the checksum is the sum of the binary value of each
4832
- # byte in `self`, modulo `2**n - 1`:
4862
+ # byte in `self`, modulo <code>2**n - 1</code>:
4833
4863
  #
4834
4864
  # 'hello'.sum # => 532
4835
4865
  # 'hello'.sum(4) # => 4
@@ -4874,8 +4904,9 @@ class String
4874
4904
  # s = 'こんにちは'
4875
4905
  # s.swapcase == s # => true
4876
4906
  #
4877
- # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
4878
- # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
4907
+ # The casing is affected by the given `mapping`, which may be
4908
+ # <code>:ascii</code>, <code>:fold</code>, or <code>:turkic</code>; see [Case
4909
+ # Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
4879
4910
  #
4880
4911
  # Related: see [Converting to New
4881
4912
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -4912,8 +4943,9 @@ class String
4912
4943
  # (real and imaginary parts) or polar coordinates (magnitude and angle parts),
4913
4944
  # depending on an included or implied "separator" character:
4914
4945
  #
4915
- # * `'+'`, `'-'`, or no separator: rectangular coordinates.
4916
- # * `'@'`: polar coordinates.
4946
+ # * <code>'+'</code>, <code>'-'</code>, or no separator: rectangular
4947
+ # coordinates.
4948
+ # * <code>'@'</code>: polar coordinates.
4917
4949
  #
4918
4950
  # **In Brief**
4919
4951
  #
@@ -4993,8 +5025,8 @@ class String
4993
5025
  #
4994
5026
  # **Rectangular Coordinates**
4995
5027
  #
4996
- # With separator `'+'` or `'-'`, or with no separator, interprets the values as
4997
- # rectangular coordinates: real and imaginary.
5028
+ # With separator <code>'+'</code> or <code>'-'</code>, or with no separator,
5029
+ # interprets the values as rectangular coordinates: real and imaginary.
4998
5030
  #
4999
5031
  # With no separator, assigns a single value to either the real or the imaginary
5000
5032
  # part:
@@ -5004,7 +5036,7 @@ class String
5004
5036
  # '1i'.to_c # => (0+1i) # Imaginary (trailing 'i').
5005
5037
  # 'i'.to_c # => (0+1i) # Special case (imaginary 1).
5006
5038
  #
5007
- # With separator `'+'`, both parts positive (or zero):
5039
+ # With separator <code>'+'</code>, both parts positive (or zero):
5008
5040
  #
5009
5041
  # # Without trailing 'i'.
5010
5042
  # '+'.to_c # => (0+0i) # No values: defaults to zero.
@@ -5016,7 +5048,7 @@ class String
5016
5048
  # '2+i'.to_c # => (2+1i) # Value before '+': real and imaginary 1.
5017
5049
  # '2+1i'.to_c # => (2+1i) # Values before and after '+': real and imaginary.
5018
5050
  #
5019
- # With separator `'-'`, negative imaginary part:
5051
+ # With separator <code>'-'</code>, negative imaginary part:
5020
5052
  #
5021
5053
  # # Without trailing 'i'.
5022
5054
  # '-'.to_c # => (0+0i) # No values: defaults to zero.
@@ -5028,13 +5060,13 @@ class String
5028
5060
  # '2-i'.to_c # => (2-1i) # Value before '-': positive real, negative imaginary.
5029
5061
  # '2-1i'.to_c # => (2-1i) # Values before and after '-': positive real, negative imaginary.
5030
5062
  #
5031
- # Note that the suffixed character `'i'` may instead be one of `'I'`, `'j'`, or
5032
- # `'J'`, with the same effect.
5063
+ # Note that the suffixed character <code>'i'</code> may instead be one of
5064
+ # <code>'I'</code>, <code>'j'</code>, or <code>'J'</code>, with the same effect.
5033
5065
  #
5034
5066
  # **Polar Coordinates**
5035
5067
  #
5036
- # With separator `'@'`) interprets the values as polar coordinates: magnitude
5037
- # and angle.
5068
+ # With separator <code>'@'</code>) interprets the values as polar coordinates:
5069
+ # magnitude and angle.
5038
5070
  #
5039
5071
  # '2@'.to_c.polar # => [2, 0.0] # Value before '@': magnitude only.
5040
5072
  # # Values before and after '@': magnitude and angle.
@@ -5047,8 +5079,9 @@ class String
5047
5079
  #
5048
5080
  # '1.0@0'.to_c # => (1+0.0i)
5049
5081
  #
5050
- # Note that in all cases, the suffixed character `'i'` may instead be one of
5051
- # `'I'`, `'j'`, `'J'`, with the same effect.
5082
+ # Note that in all cases, the suffixed character <code>'i'</code> may instead be
5083
+ # one of <code>'I'</code>, <code>'j'</code>, <code>'J'</code>, with the same
5084
+ # effect.
5052
5085
  #
5053
5086
  # See [Converting to Non-String](rdoc-ref:String@Converting+to+Non--5CString).
5054
5087
  #
@@ -5080,7 +5113,8 @@ class String
5080
5113
  # - to_i(base = 10) -> integer
5081
5114
  # -->
5082
5115
  # Returns the result of interpreting leading characters in `self` as an integer
5083
- # in the given `base`; `base` must be either `0` or in range `(2..36)`:
5116
+ # in the given `base`; `base` must be either `0` or in range
5117
+ # <code>(2..36)</code>:
5084
5118
  #
5085
5119
  # '123456'.to_i # => 123456
5086
5120
  # '123def'.to_i(16) # => 1195503
@@ -5131,7 +5165,8 @@ class String
5131
5165
  #
5132
5166
  # 'BWV 1079'.to_r # => (0/1)
5133
5167
  #
5134
- # NOTE: `'0.3'.to_r` is equivalent to `3/10r`, but is different from `0.3.to_r`:
5168
+ # NOTE: <code>'0.3'.to_r</code> is equivalent to <code>3/10r</code>, but is
5169
+ # different from <code>0.3.to_r</code>:
5135
5170
  #
5136
5171
  # '0.3'.to_r # => (3/10)
5137
5172
  # 3/10r # => (3/10)
@@ -5213,7 +5248,7 @@ class String
5213
5248
  # Related: see [Converting to New
5214
5249
  # String](rdoc-ref:String@Converting+to+New+String).
5215
5250
  #
5216
- def tr: (selector source, string relpacement) -> String
5251
+ def tr: (selector source, string replacement) -> String
5217
5252
 
5218
5253
  # <!--
5219
5254
  # rdoc-file=string.c
@@ -5226,7 +5261,7 @@ class String
5226
5261
  #
5227
5262
  # Related: [Modifying](rdoc-ref:String@Modifying).
5228
5263
  #
5229
- def tr!: (selector source, string relpacement) -> self?
5264
+ def tr!: (selector source, string replacement) -> self?
5230
5265
 
5231
5266
  # <!--
5232
5267
  # rdoc-file=string.c
@@ -5284,21 +5319,23 @@ class String
5284
5319
  # Argument `form` must be one of the following symbols (see [Unicode
5285
5320
  # normalization forms](https://unicode.org/reports/tr15/#Norm_Forms)):
5286
5321
  #
5287
- # * `:nfc`: Canonical decomposition, followed by canonical composition.
5288
- # * `:nfd`: Canonical decomposition.
5289
- # * `:nfkc`: Compatibility decomposition, followed by canonical composition.
5290
- # * `:nfkd`: Compatibility decomposition.
5322
+ # * <code>:nfc</code>: Canonical decomposition, followed by canonical
5323
+ # composition.
5324
+ # * <code>:nfd</code>: Canonical decomposition.
5325
+ # * <code>:nfkc</code>: Compatibility decomposition, followed by canonical
5326
+ # composition.
5327
+ # * <code>:nfkd</code>: Compatibility decomposition.
5291
5328
  #
5292
5329
  # The encoding of `self` must be one of:
5293
5330
  #
5294
- # * `Encoding::UTF_8`.
5295
- # * `Encoding::UTF_16BE`.
5296
- # * `Encoding::UTF_16LE`.
5297
- # * `Encoding::UTF_32BE`.
5298
- # * `Encoding::UTF_32LE`.
5299
- # * `Encoding::GB18030`.
5300
- # * `Encoding::UCS_2BE`.
5301
- # * `Encoding::UCS_4BE`.
5331
+ # * <code>Encoding::UTF_8</code>.
5332
+ # * <code>Encoding::UTF_16BE</code>.
5333
+ # * <code>Encoding::UTF_16LE</code>.
5334
+ # * <code>Encoding::UTF_32BE</code>.
5335
+ # * <code>Encoding::UTF_32LE</code>.
5336
+ # * <code>Encoding::GB18030</code>.
5337
+ # * <code>Encoding::UCS_2BE</code>.
5338
+ # * <code>Encoding::UCS_4BE</code>.
5302
5339
  #
5303
5340
  # Examples:
5304
5341
  #
@@ -5328,7 +5365,8 @@ class String
5328
5365
  # Returns whether `self` is in the given `form` of Unicode normalization; see
5329
5366
  # String#unicode_normalize.
5330
5367
  #
5331
- # The `form` must be one of `:nfc`, `:nfd`, `:nfkc`, or `:nfkd`.
5368
+ # The `form` must be one of <code>:nfc</code>, <code>:nfd</code>,
5369
+ # <code>:nfkc</code>, or <code>:nfkd</code>.
5332
5370
  #
5333
5371
  # Examples:
5334
5372
  #
@@ -5402,8 +5440,9 @@ class String
5402
5440
  # s = 'こんにちは'
5403
5441
  # s.upcase == s # => true
5404
5442
  #
5405
- # The casing is affected by the given `mapping`, which may be `:ascii`, `:fold`,
5406
- # or `:turkic`; see [Case Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
5443
+ # The casing is affected by the given `mapping`, which may be
5444
+ # <code>:ascii</code>, <code>:fold</code>, or <code>:turkic</code>; see [Case
5445
+ # Mappings](rdoc-ref:case_mapping.rdoc@Case+Mappings).
5407
5446
  #
5408
5447
  # Related: see [Converting to New
5409
5448
  # String](rdoc-ref:String@Converting+to+New+String).
@@ -5436,8 +5475,8 @@ class String
5436
5475
  # -->
5437
5476
  # With a block given, calls the block with each `String` value returned by
5438
5477
  # successive calls to String#succ; the first value is `self`, the next is
5439
- # `self.succ`, and so on; the sequence terminates when value `other_string` is
5440
- # reached; returns `self`:
5478
+ # <code>self.succ</code>, and so on; the sequence terminates when value
5479
+ # `other_string` is reached; returns `self`:
5441
5480
  #
5442
5481
  # a = []
5443
5482
  # 'a'.upto('f') {|c| a.push(c) }
@@ -5491,22 +5530,3 @@ class String
5491
5530
  #
5492
5531
  def valid_encoding?: () -> bool
5493
5532
  end
5494
-
5495
- %a{deprecated}
5496
- interface _ArefFromStringToString
5497
- def []: (String) -> String
5498
- end
5499
-
5500
- %a{deprecated}
5501
- type String::encode_fallback = Hash[String, String] | Proc | Method | String::_ArefFromStringToString
5502
-
5503
- # Don't use this interface directly
5504
- #
5505
- # This is a copy of `::_ArefFromStringToString` but without deprecated attribute.
5506
- # This is a workaround to avoid deprecation warnings in `String::encode_fallback` type.
5507
- #
5508
- # This type will be deprecated soon once `::_ArefFromStringToString` and `String::encode_fallback` are removed.
5509
- #
5510
- interface String::_ArefFromStringToString
5511
- def []: (String) -> String
5512
- end