Skip to content

Commit 036a580

Browse files
committed
Update docs
1 parent 86efc3a commit 036a580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2039
-681
lines changed

core/array.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ class Array[unchecked out Elem] < Object
12131213
# Returns the element from `self` found by a binary search, or `nil` if the
12141214
# search found no suitable element.
12151215
#
1216-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
1216+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
12171217
#
12181218
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
12191219
#
@@ -1229,7 +1229,7 @@ class Array[unchecked out Elem] < Object
12291229
# Returns the integer index of the element from `self` found by a binary search,
12301230
# or `nil` if the search found no suitable element.
12311231
#
1232-
# See [Binary Searching](rdoc-ref:bsearch.rdoc).
1232+
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
12331233
#
12341234
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
12351235
#
@@ -2618,7 +2618,7 @@ class Array[unchecked out Elem] < Object
26182618
# - pack(template, buffer: nil) -> string
26192619
# -->
26202620
# Formats each element in `self` into a binary string; returns that string. See
2621-
# [Packed Data](rdoc-ref:packed_data.rdoc).
2621+
# [Packed Data](rdoc-ref:language/packed_data.rdoc).
26222622
#
26232623
def pack: (string fmt, ?buffer: String?) -> String
26242624

core/complex.rbs

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,24 @@ class Complex < Numeric
184184

185185
# <!--
186186
# rdoc-file=complex.c
187-
# - complex * numeric -> new_complex
187+
# - self * other -> numeric
188188
# -->
189-
# Returns the product of `self` and `numeric`:
189+
# Returns the numeric product of `self` and `other`:
190190
#
191+
# Complex.rect(9, 8) * 4 # => (36+32i)
192+
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
191193
# Complex.rect(2, 3) * Complex.rect(2, 3) # => (-5+12i)
192194
# Complex.rect(900) * Complex.rect(1) # => (900+0i)
193195
# Complex.rect(-2, 9) * Complex.rect(-9, 2) # => (0-85i)
194-
# Complex.rect(9, 8) * 4 # => (36+32i)
195-
# Complex.rect(20, 9) * 9.8 # => (196.0+88.2i)
196+
# Complex.rect(9, 8) * Rational(2, 3) # => ((6/1)+(16/3)*i)
196197
#
197198
def *: (Numeric) -> Complex
198199

199200
# <!--
200201
# rdoc-file=complex.c
201-
# - complex ** numeric -> new_complex
202+
# - self ** exponent -> complex
202203
# -->
203-
# Returns `self` raised to power `numeric`:
204+
# Returns `self` raised to the power `exponent`:
204205
#
205206
# Complex.rect(0, 1) ** 2 # => (-1+0i)
206207
# Complex.rect(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
@@ -209,23 +210,33 @@ class Complex < Numeric
209210

210211
# <!--
211212
# rdoc-file=complex.c
212-
# - complex + numeric -> new_complex
213+
# - self + other -> numeric
213214
# -->
214-
# Returns the sum of `self` and `numeric`:
215+
# Returns the sum of `self` and `other`:
216+
#
217+
# Complex(1, 2) + 0 # => (1+2i)
218+
# Complex(1, 2) + 1 # => (2+2i)
219+
# Complex(1, 2) + -1 # => (0+2i)
220+
#
221+
# Complex(1, 2) + 1.0 # => (2.0+2i)
222+
#
223+
# Complex(1, 2) + Complex(2, 1) # => (3+3i)
224+
# Complex(1, 2) + Complex(2.0, 1.0) # => (3.0+3.0i)
225+
#
226+
# Complex(1, 2) + Rational(1, 1) # => ((2/1)+2i)
227+
# Complex(1, 2) + Rational(1, 2) # => ((3/2)+2i)
228+
#
229+
# For a computation involving Floats, the result may be inexact (see Float#+):
215230
#
216-
# Complex.rect(2, 3) + Complex.rect(2, 3) # => (4+6i)
217-
# Complex.rect(900) + Complex.rect(1) # => (901+0i)
218-
# Complex.rect(-2, 9) + Complex.rect(-9, 2) # => (-11+11i)
219-
# Complex.rect(9, 8) + 4 # => (13+8i)
220-
# Complex.rect(20, 9) + 9.8 # => (29.8+9i)
231+
# Complex(1, 2) + 3.14 # => (4.140000000000001+2i)
221232
#
222233
def +: (Numeric) -> Complex
223234

224235
# <!--
225236
# rdoc-file=complex.c
226-
# - complex - numeric -> new_complex
237+
# - self - other -> complex
227238
# -->
228-
# Returns the difference of `self` and `numeric`:
239+
# Returns the difference of `self` and `other`:
229240
#
230241
# Complex.rect(2, 3) - Complex.rect(2, 3) # => (0+0i)
231242
# Complex.rect(900) - Complex.rect(1) # => (899+0i)
@@ -237,9 +248,9 @@ class Complex < Numeric
237248

238249
# <!--
239250
# rdoc-file=complex.c
240-
# - -complex -> new_complex
251+
# - -self -> complex
241252
# -->
242-
# Returns the negation of `self`, which is the negation of each of its parts:
253+
# Returns `self`, negated, which is the negation of each of its parts:
243254
#
244255
# -Complex.rect(1, 2) # => (-1-2i)
245256
# -Complex.rect(-1, -2) # => (1+2i)
@@ -248,9 +259,9 @@ class Complex < Numeric
248259

249260
# <!--
250261
# rdoc-file=complex.c
251-
# - complex / numeric -> new_complex
262+
# - self / other -> complex
252263
# -->
253-
# Returns the quotient of `self` and `numeric`:
264+
# Returns the quotient of `self` and `other`:
254265
#
255266
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
256267
# Complex.rect(900) / Complex.rect(1) # => (900+0i)
@@ -597,9 +608,9 @@ class Complex < Numeric
597608

598609
# <!--
599610
# rdoc-file=complex.c
600-
# - complex / numeric -> new_complex
611+
# - self / other -> complex
601612
# -->
602-
# Returns the quotient of `self` and `numeric`:
613+
# Returns the quotient of `self` and `other`:
603614
#
604615
# Complex.rect(2, 3) / Complex.rect(2, 3) # => (1+0i)
605616
# Complex.rect(900) / Complex.rect(1) # => (900+0i)

core/encoding.rbs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class Encoding
281281
def inspect: () -> String
282282

283283
# <!-- rdoc-file=encoding.c -->
284-
# Returns the name of the encoding.
284+
# The name of the encoding.
285285
#
286286
# Encoding::UTF_8.name #=> "UTF-8"
287287
#
@@ -297,12 +297,8 @@ class Encoding
297297
#
298298
def names: () -> Array[String]
299299

300-
# <!--
301-
# rdoc-file=encoding.c
302-
# - enc.name -> string
303-
# - enc.to_s -> string
304-
# -->
305-
# Returns the name of the encoding.
300+
# <!-- rdoc-file=encoding.c -->
301+
# The name of the encoding.
306302
#
307303
# Encoding::UTF_8.name #=> "UTF-8"
308304
#

core/enumerable.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
21362136
# ["F", 6860]
21372137
#
21382138
# You can use the special symbol `:_alone` to force an element into its own
2139-
# separate chuck:
2139+
# separate chunk:
21402140
#
21412141
# a = [0, 0, 1, 1]
21422142
# e = a.chunk{|i| i.even? ? :_alone : true }

core/enumerator.rbs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
137137

138138
# <!--
139139
# rdoc-file=enumerator.c
140-
# - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
140+
# - Enumerator.produce(initial = nil, size: nil) { |prev| block } -> enumerator
141141
# -->
142142
# Creates an infinite enumerator from any block, just called over and over. The
143143
# result of the previous iteration is passed to the next one. If `initial` is
@@ -169,6 +169,23 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
169169
# Enumerator.produce { scanner.scan(PATTERN) }.slice_after { scanner.eos? }.first
170170
# # => ["7", "+", "38", "/", "6"]
171171
#
172+
# The optional `size` keyword argument specifies the size of the enumerator,
173+
# which can be retrieved by Enumerator#size. It can be an integer,
174+
# `Float::INFINITY`, a callable object (such as a lambda), or `nil` to indicate
175+
# unknown size. When not specified, the size defaults to `Float::INFINITY`.
176+
#
177+
# # Infinite enumerator
178+
# enum = Enumerator.produce(1, size: Float::INFINITY, &:succ)
179+
# enum.size # => Float::INFINITY
180+
#
181+
# # Finite enumerator with known/computable size
182+
# abs_dir = File.expand_path("./baz") # => "/foo/bar/baz"
183+
# traverser = Enumerator.produce(abs_dir, size: -> { abs_dir.count("/") + 1 }) {
184+
# raise StopIteration if it == "/"
185+
# File.dirname(it)
186+
# }
187+
# traverser.size # => 4
188+
#
172189
def self.produce: [T] () { (T? prev) -> T } -> Enumerator[T, bot]
173190
| [T] (T initial) { (T prev) -> T } -> Enumerator[T, bot]
174191

core/fiber.rbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class Fiber < Object
8282
# -->
8383
# Returns the value of the fiber storage variable identified by `key`.
8484
#
85-
# The `key` must be a symbol, and the value is set by Fiber#[]= or Fiber#store.
85+
# The `key` must be a symbol, and the value is set by Fiber#[]= or
86+
# Fiber#storage.
8687
#
8788
# See also Fiber::[]=.
8889
#

core/file.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ class File < IO
14141414
# rdoc-file=file.c
14151415
# - File.owned?(file_name) -> true or false
14161416
# -->
1417-
# Returns `true` if the named file exists and the effective used id of the
1417+
# Returns `true` if the named file exists and the effective user id of the
14181418
# calling process is the owner of the file.
14191419
#
14201420
# *file_name* can be an IO object.

core/file_test.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ module FileTest
145145
# rdoc-file=file.c
146146
# - File.owned?(file_name) -> true or false
147147
# -->
148-
# Returns `true` if the named file exists and the effective used id of the
148+
# Returns `true` if the named file exists and the effective user id of the
149149
# calling process is the owner of the file.
150150
#
151151
# *file_name* can be an IO object.

0 commit comments

Comments
 (0)