Skip to content

Commit e4efe77

Browse files
authored
Merge pull request #1689 from ruby/docs-3.3-rc1
Update docs based on 3.3.0-rc1
2 parents 3a965cb + 70d4d3c commit e4efe77

19 files changed

Lines changed: 846 additions & 313 deletions

File tree

.github/workflows/comments.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
container:
1414
image: rubylang/ruby:3.2-dev-focal
1515
env:
16-
RUBY_COMMIT: v3_3_0_preview3
16+
RUBY_COMMIT: v3_3_0_rc1
1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Install dependencies

core/comparable.rbs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@
88
# implement the conventional comparison operators (`<`, `<=`, `==`, `>=`, and
99
# `>`) and the method `between?`.
1010
#
11-
# class SizeMatters
11+
# class StringSorter
1212
# include Comparable
13+
#
1314
# attr :str
1415
# def <=>(other)
1516
# str.size <=> other.str.size
1617
# end
18+
#
1719
# def initialize(str)
1820
# @str = str
1921
# end
22+
#
2023
# def inspect
2124
# @str
2225
# end
2326
# end
2427
#
25-
# s1 = SizeMatters.new("Z")
26-
# s2 = SizeMatters.new("YY")
27-
# s3 = SizeMatters.new("XXX")
28-
# s4 = SizeMatters.new("WWWW")
29-
# s5 = SizeMatters.new("VVVVV")
28+
# s1 = StringSorter.new("Z")
29+
# s2 = StringSorter.new("YY")
30+
# s3 = StringSorter.new("XXX")
31+
# s4 = StringSorter.new("WWWW")
32+
# s5 = StringSorter.new("VVVVV")
3033
#
3134
# s1 < s2 #=> true
3235
# s4.between?(s1, s3) #=> false

core/complex.rbs

Lines changed: 82 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,107 @@
11
# <!-- rdoc-file=complex.c -->
2-
# A complex number can be represented as a paired real number with imaginary
3-
# unit; a+bi. Where a is real part, b is imaginary part and i is imaginary
4-
# unit. Real a equals complex a+0i mathematically.
2+
# A Complex object houses a pair of values, given when the object is created as
3+
# either *rectangular coordinates* or *polar coordinates*.
54
#
6-
# You can create a Complex object explicitly with:
5+
# ## Rectangular Coordinates
76
#
8-
# * A [complex literal](rdoc-ref:syntax/literals.rdoc@Complex+Literals).
7+
# The rectangular coordinates of a complex number are called the *real* and
8+
# *imaginary* parts; see [Complex number
9+
# definition](https://en.wikipedia.org/wiki/Complex_number#Definition).
910
#
11+
# You can create a Complex object from rectangular coordinates with:
1012
#
11-
# You can convert certain objects to Complex objects with:
13+
# * A [complex literal](rdoc-ref:doc/syntax/literals.rdoc@Complex+Literals).
14+
# * Method Complex.rect.
15+
# * Method Kernel#Complex, either with numeric arguments or with certain
16+
# string arguments.
17+
# * Method String#to_c, for certain strings.
1218
#
13-
# * Method #Complex.
1419
#
20+
# Note that each of the stored parts may be a an instance one of the classes
21+
# Complex, Float, Integer, or Rational; they may be retrieved:
1522
#
16-
# Complex object can be created as literal, and also by using Kernel#Complex,
17-
# Complex::rect, Complex::polar or to_c method.
23+
# * Separately, with methods Complex#real and Complex#imaginary.
24+
# * Together, with method Complex#rect.
1825
#
19-
# 2+1i #=> (2+1i)
20-
# Complex(1) #=> (1+0i)
21-
# Complex(2, 3) #=> (2+3i)
22-
# Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i)
23-
# 3.to_c #=> (3+0i)
2426
#
25-
# You can also create complex object from floating-point numbers or strings.
27+
# The corresponding (computed) polar values may be retrieved:
2628
#
27-
# Complex(0.3) #=> (0.3+0i)
28-
# Complex('0.3-0.5i') #=> (0.3-0.5i)
29-
# Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i)
30-
# Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i)
29+
# * Separately, with methods Complex#abs and Complex#arg.
30+
# * Together, with method Complex#polar.
3131
#
32-
# 0.3.to_c #=> (0.3+0i)
33-
# '0.3-0.5i'.to_c #=> (0.3-0.5i)
34-
# '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i)
35-
# '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i)
3632
#
37-
# A complex object is either an exact or an inexact number.
33+
# ## Polar Coordinates
3834
#
39-
# Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i)
40-
# Complex(1, 1) / 2.0 #=> (0.5+0.5i)
35+
# The polar coordinates of a complex number are called the *absolute* and
36+
# *argument* parts; see [Complex polar
37+
# plane](https://en.wikipedia.org/wiki/Complex_number#Polar_complex_plane).
38+
#
39+
# You can create a Complex object from polar coordinates with:
40+
#
41+
# * Method Complex.polar.
42+
# * Method Kernel#Complex, with certain string arguments.
43+
# * Method String#to_c, for certain strings.
44+
#
45+
#
46+
# Note that each of the stored parts may be a an instance one of the classes
47+
# Complex, Float, Integer, or Rational; they may be retrieved:
48+
#
49+
# * Separately, with methods Complex#abs and Complex#arg.
50+
# * Together, with method Complex#polar.
51+
#
52+
#
53+
# The corresponding (computed) rectangular values may be retrieved:
54+
#
55+
# * Separately, with methods Complex#real and Complex#imag.
56+
# * Together, with method Complex#rect.
4157
#
4258
class Complex < Numeric
4359
# <!--
4460
# rdoc-file=complex.c
45-
# - Complex.polar(abs[, arg]) -> complex
61+
# - Complex.polar(abs, arg = 0) -> complex
4662
# -->
47-
# Returns a complex object which denotes the given polar form.
63+
# Returns a new Complex object formed from the arguments, each of which must be
64+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
65+
# Float, Integer, Rational; see [Polar
66+
# Coordinates](rdoc-ref:Complex@Polar+Coordinates):
4867
#
49-
# Complex.polar(3, 0) #=> (3.0+0.0i)
50-
# Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i)
51-
# Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i)
52-
# Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i)
68+
# Complex.polar(3) # => (3+0i)
69+
# Complex.polar(3, 2.0) # => (-1.2484405096414273+2.727892280477045i)
70+
# Complex.polar(-3, -2.0) # => (1.2484405096414273+2.727892280477045i)
5371
#
5472
def self.polar: (Numeric, ?Numeric) -> Complex
5573

5674
# <!--
5775
# rdoc-file=complex.c
58-
# - Complex.rect(real[, imag]) -> complex
59-
# - Complex.rectangular(real[, imag]) -> complex
76+
# - Complex.rect(real, imag = 0) -> complex
6077
# -->
61-
# Returns a complex object which denotes the given rectangular form.
78+
# Returns a new Complex object formed from the arguments, each of which must be
79+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
80+
# Float, Integer, Rational; see [Rectangular
81+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
82+
#
83+
# Complex.rect(3) # => (3+0i)
84+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
85+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
6286
#
63-
# Complex.rectangular(1, 2) #=> (1+2i)
87+
# Complex.rectangular is an alias for Complex.rect.
6488
#
6589
def self.rect: (Numeric, ?Numeric) -> Complex
6690

6791
# <!--
6892
# rdoc-file=complex.c
69-
# - Complex.rect(real[, imag]) -> complex
70-
# - Complex.rectangular(real[, imag]) -> complex
93+
# - Complex.rect(real, imag = 0) -> complex
7194
# -->
72-
# Returns a complex object which denotes the given rectangular form.
95+
# Returns a new Complex object formed from the arguments, each of which must be
96+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
97+
# Float, Integer, Rational; see [Rectangular
98+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
7399
#
74-
# Complex.rectangular(1, 2) #=> (1+2i)
100+
# Complex.rect(3) # => (3+0i)
101+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
102+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
103+
#
104+
# Complex.rectangular is an alias for Complex.rect.
75105
#
76106
alias self.rectangular self.rect
77107

@@ -462,9 +492,16 @@ class Complex < Numeric
462492
def real?: () -> false
463493

464494
# <!-- rdoc-file=complex.c -->
465-
# Returns a complex object which denotes the given rectangular form.
495+
# Returns a new Complex object formed from the arguments, each of which must be
496+
# an instance of Numeric, or an instance of one of its subclasses: Complex,
497+
# Float, Integer, Rational; see [Rectangular
498+
# Coordinates](rdoc-ref:Complex@Rectangular+Coordinates):
499+
#
500+
# Complex.rect(3) # => (3+0i)
501+
# Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
502+
# Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
466503
#
467-
# Complex.rectangular(1, 2) #=> (1+2i)
504+
# Complex.rectangular is an alias for Complex.rect.
468505
#
469506
def rect: () -> [ Numeric, Numeric ]
470507

@@ -559,6 +596,8 @@ class Complex < Numeric
559596
end
560597

561598
# <!-- rdoc-file=complex.c -->
562-
# The imaginary unit.
599+
# Equivalent to `Complex(0, 1)`:
600+
#
601+
# Complex::I # => (0+1i)
563602
#
564603
Complex::I: Complex

core/dir.rbs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ class Dir
362362
# Dir.exist?('/nosuch') # => false
363363
# Dir.exist?('/example/main.rb') # => false
364364
#
365+
# Same as File.directory?.
366+
#
365367
def self.exist?: (path | io file_name) -> bool
366368

367369
# <!--
@@ -580,14 +582,14 @@ class Dir
580582
# Dir.glob('io.?') # => ["io.c"]
581583
#
582584
# * `'[*set*]'`: Matches any one character in the string *set*; behaves like a
583-
# [Regexp character class](rdoc-ref:regexp.rdoc@Character+Classes),
584-
# including set negation (`'[^a-z]'`):
585+
# [Regexp character class](rdoc-ref:Regexp@Character+Classes), including set
586+
# negation (`'[^a-z]'`):
585587
#
586588
# Dir.glob('*.[a-z][a-z]').take(3)
587589
# # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"]
588590
#
589591
# * `'{*abc*,*xyz*}'`: Matches either string *abc* or string *xyz*; behaves
590-
# like [Regexp alternation](rdoc-ref:regexp.rdoc@Alternation):
592+
# like [Regexp alternation](rdoc-ref:Regexp@Alternation):
591593
#
592594
# Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"]
593595
#
@@ -666,9 +668,13 @@ class Dir
666668
# <!--
667669
# rdoc-file=dir.c
668670
# - Dir.home(user_name = nil) -> dirpath
669-
# - Dir.home # => "/home/me"
670-
# - Dir.home('root') # => "/root"
671671
# -->
672+
# Retruns the home directory path of the user specified with `user_name` if it
673+
# is not `nil`, or the current login user:
674+
#
675+
# Dir.home # => "/home/me"
676+
# Dir.home('root') # => "/root"
677+
#
672678
# Raises ArgumentError if `user_name` is not a user name.
673679
#
674680
def self.home: (?string? user) -> String
@@ -764,7 +770,7 @@ class Dir
764770
# Dir.pwd # => "/"
765771
# dir = Dir.new('example')
766772
# dir.chdir
767-
# dir.pwd # => "/example"
773+
# Dir.pwd # => "/example"
768774
#
769775
def chdir: () -> Integer
770776
| [T] { () -> T } -> T

core/fiber.rbs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,21 @@ class Fiber < Object
373373
# rdoc-file=cont.c
374374
# - fiber.kill -> nil
375375
# -->
376-
# Terminates `fiber` by raising an uncatchable exception, returning the
377-
# terminated Fiber.
376+
# Terminates the fiber by raising an uncatchable exception. It only terminates
377+
# the given fiber and no other fiber, returning `nil` to another fiber if that
378+
# fiber was calling #resume or #transfer.
379+
#
380+
# `Fiber#kill` only interrupts another fiber when it is in Fiber.yield. If
381+
# called on the current fiber then it raises that exception at the `Fiber#kill`
382+
# call site.
378383
#
379384
# If the fiber has not been started, transition directly to the terminated
380385
# state.
381386
#
382387
# If the fiber is already terminated, does nothing.
383388
#
389+
# Raises FiberError if called on a fiber belonging to another thread.
390+
#
384391
def kill: () -> nil
385392

386393
# <!--
@@ -403,6 +410,8 @@ class Fiber < Object
403410
# parameter is an array of callback information. Exceptions are caught by the
404411
# `rescue` clause of `begin...end` blocks.
405412
#
413+
# Raises `FiberError` if called on a Fiber belonging to another `Thread`.
414+
#
406415
def raise: (?string msg) -> untyped
407416
| (_Exception, ?string msg, ?Array[string] backtrace) -> untyped
408417

core/file.rbs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,15 @@ class File < IO
931931

932932
# <!--
933933
# rdoc-file=file.c
934-
# - birthtime(p1)
934+
# - File.birthtime(file_name) -> time
935935
# -->
936+
# Returns the birth time for the named file.
937+
#
938+
# *file_name* can be an IO object.
939+
#
940+
# File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
941+
#
942+
# If the platform doesn't have birthtime, raises NotImplementedError.
936943
#
937944
def self.birthtime: (string | _ToPath | IO file_name) -> Time
938945

@@ -1914,8 +1921,11 @@ class File < IO
19141921

19151922
# <!--
19161923
# rdoc-file=file.c
1917-
# - size()
1924+
# - file.size -> integer
19181925
# -->
1926+
# Returns the size of *file* in bytes.
1927+
#
1928+
# File.new("testfile").size #=> 66
19191929
#
19201930
def size: () -> Integer
19211931

@@ -2504,19 +2514,12 @@ class File::Stat < Object
25042514

25052515
# <!--
25062516
# rdoc-file=file.c
2507-
# - File.directory?(path) -> true or false
2517+
# - stat.directory? -> true or false
25082518
# -->
2509-
# With string `object` given, returns `true` if `path` is a string path leading
2510-
# to a directory, or to a symbolic link to a directory; `false` otherwise:
2519+
# Returns `true` if *stat* is a directory, `false` otherwise.
25112520
#
2512-
# File.directory?('.') # => true
2513-
# File.directory?('foo') # => false
2514-
# File.symlink('.', 'dirlink') # => 0
2515-
# File.directory?('dirlink') # => true
2516-
# File.symlink('t,txt', 'filelink') # => 0
2517-
# File.directory?('filelink') # => false
2518-
#
2519-
# Argument `path` can be an IO object.
2521+
# File.stat("testfile").directory? #=> false
2522+
# File.stat(".").directory? #=> true
25202523
#
25212524
def directory?: () -> bool
25222525

0 commit comments

Comments
 (0)