Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs in RBS from ruby-3.3.0-preview3 #1676

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
runs-on: "ubuntu-latest"
container:
image: rubylang/ruby:3.2-dev-focal
env:
RUBY_COMMIT: v3_3_0_preview3
steps:
- uses: actions/checkout@v4
- name: Install dependencies
Expand All @@ -22,11 +24,6 @@ jobs:
run: |
ruby -v
gem update --system
- name: bundle config set with
run: |
echo "NO_MINITEST=true" >> $GITHUB_ENV
bundle config set --local without 'minitest'
if: "contains(matrix.container_tag, 'master-nightly')"
- name: bin/setup
run: |
bin/setup
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ gem "goodcheck"
gem "dbm"
gem 'digest'
gem 'tempfile'
gem "rdoc", "~> 6.4.0"
gem "rdoc"

# Test gems
gem "rbs-amber", path: "test/assets/test-gem"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GEM
rake (13.1.0)
rake-compiler (1.2.5)
rake
rdoc (6.4.0)
rdoc (6.6.1)
psych (>= 4.0.0)
regexp_parser (2.8.3)
rexml (3.2.6)
Expand Down Expand Up @@ -81,7 +81,7 @@ GEM
rubocop (~> 1.0)
ruby-progressbar (1.13.0)
stackprof (0.2.25)
stringio (3.0.7)
stringio (3.1.0)
strong_json (2.1.2)
tempfile (0.2.1)
test-unit (3.6.1)
Expand All @@ -105,7 +105,7 @@ DEPENDENCIES
rake-compiler
rbs!
rbs-amber!
rdoc (~> 6.4.0)
rdoc
rspec
rubocop
rubocop-rubycw
Expand Down
32 changes: 21 additions & 11 deletions bin/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@

set -ex

if [ -z ${RUBY_VERSION} ]; then
RUBY_VERSION=`ruby -e 'puts RUBY_VERSION'`
if [ -z ${RUBY_COMMIT} ]; then
RUBY_COMMIT=v`ruby -e 'puts RUBY_VERSION.gsub(".", "_")'`
fi

echo "RUBY_VERSION = ${RUBY_VERSION}"
if [ -z ${RBS_RDOC_BASE_DIR} ]; then
RBS_RDOC_BASE_DIR=/tmp/rbs-rdoc
fi

REPO_ROOT=$(cd $(dirname $(dirname $0)); pwd)

rm -f /tmp/ruby.tar.gz
rm -rf /tmp/ruby-${RUBY_VERSION}
echo "RBS_RDOC_BASE_DIR = ${RBS_RDOC_BASE_DIR}"
echo "RUBY_COMMIT = ${RUBY_COMMIT}"

RUBY_SRC_DIR=${RBS_RDOC_BASE_DIR}/ruby-${RUBY_COMMIT}
RDOC_OUT_DIR=${RBS_RDOC_BASE_DIR}/rdoc-${RUBY_COMMIT}

curl -L https://cache.ruby-lang.org/pub/ruby/${RUBY_VERSION%.*}/ruby-${RUBY_VERSION}.tar.gz | tar xzf - -C /tmp
rm -rf ${RUBY_SRC_DIR} ${RDOC_OUT_DIR}

rm -rf /tmp/rdoc-${RUBY_VERSION}
(
mkdir -p ${RUBY_SRC_DIR}
cd ${RUBY_SRC_DIR}
git init
git remote add origin https://github.com/ruby/ruby.git
git fetch --depth 1 origin ${RUBY_COMMIT}
git checkout FETCH_HEAD
bundle exec --gemfile=${REPO_ROOT}/Gemfile rdoc --output=${RDOC_OUT_DIR} --root="." --all --ri --page-dir="doc" "."
)

cd /tmp/ruby-${RUBY_VERSION}
bundle exec --gemfile=${REPO_ROOT}/Gemfile rdoc --output=/tmp/rdoc-${RUBY_VERSION} --root="." --all --ri --page-dir="doc" "."
cd ${REPO_ROOT}
bundle exec rbs annotate --no-system --no-gems --no-site --no-home -d /tmp/rdoc-${RUBY_VERSION} core stdlib
bundle exec rbs annotate --no-system --no-gems --no-site --no-home -d ${RDOC_OUT_DIR} core stdlib
68 changes: 19 additions & 49 deletions core/array.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ class Array[unchecked out Elem] < Object
# - array & other_array -> new_array
# -->
# Returns a new Array containing each element found in both `array` and Array
# `other_array`; duplicates are omitted; items are compared using `eql?`:
# `other_array`; duplicates are omitted; items are compared using `eql?` (items
# must also implement `hash` correctly):
#
# [0, 1, 2, 3] & [1, 2] # => [1, 2]
# [0, 1, 0, 1] & [0, 1] # => [0, 1]
Expand Down Expand Up @@ -837,8 +838,6 @@ class Array[unchecked out Elem] < Object
# # Raises TypeError (no implicit conversion of Symbol into Integer):
# a[:foo]
#
# Array#slice is an alias for Array#[].
#
def []: %a{implicitly-returns-nil} (int index) -> Elem
| (int start, int length) -> ::Array[Elem]?
| (::Range[::Integer?] range) -> ::Array[Elem]?
Expand Down Expand Up @@ -972,6 +971,8 @@ class Array[unchecked out Elem] < Object
# -->
# Returns `true` if all elements of `self` meet a given criterion.
#
# If `self` has no element, returns `true` and argument or block are not used.
#
# With no block given and no argument, returns `true` if `self` contains only
# truthy elements, `false` otherwise:
#
Expand Down Expand Up @@ -1009,6 +1010,8 @@ class Array[unchecked out Elem] < Object
# -->
# Returns `true` if any element of `self` meets a given criterion.
#
# If `self` has no element, returns `false` and argument or block are not used.
#
# With no block given and no argument, returns `true` if `self` has any truthy
# element, `false` otherwise:
#
Expand Down Expand Up @@ -1050,8 +1053,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.push([:baz, :bat], [:bam, :bad])
# a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
#
# Array#append is an alias for Array#push.
#
# Related: #pop, #shift, #unshift.
#
alias append push
Expand Down Expand Up @@ -1135,8 +1136,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.map
# a1 # => #<Enumerator: [:foo, "bar", 2]:map>
#
# Array#collect is an alias for Array#map.
#
def collect: [U] () { (Elem item) -> U } -> ::Array[U]
| () -> ::Enumerator[Elem, ::Array[untyped]]

Expand All @@ -1157,8 +1156,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.map!
# a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
#
# Array#collect! is an alias for Array#map!.
#
def collect!: () { (Elem item) -> Elem } -> self
| () -> ::Enumerator[Elem, self]

Expand Down Expand Up @@ -1388,18 +1385,16 @@ class Array[unchecked out Elem] < Object
# - array.delete_if {|element| ... } -> self
# - array.delete_if -> Enumerator
# -->
# Removes each element in +self+ for which the block returns a truthy value;
# returns +self+:
#
# a = [:foo, 'bar', 2, 'bat']
# a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
# Removes each element in `self` for which the block returns a truthy value;
# returns `self`:
#
# Returns a new \Enumerator if no block given:
# a = [:foo, 'bar', 2, 'bat']
# a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
#
# a = [:foo, 'bar', 2]
# a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
# Returns a new Enumerator if no block given:
#
# 3
# a = [:foo, 'bar', 2]
# a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
#
def delete_if: () { (Elem item) -> boolish } -> self
| () -> ::Enumerator[Elem, self]
Expand Down Expand Up @@ -1854,8 +1849,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2, :bam]
# a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
#
# Array#filter is an alias for Array#select.
#
def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, ::Array[Elem]]

Expand All @@ -1875,8 +1868,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2, :bam]
# a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
#
# Array#filter! is an alias for Array#select!.
#
def filter!: () { (Elem item) -> boolish } -> self?
| () -> ::Enumerator[Elem, self?]

Expand Down Expand Up @@ -1912,16 +1903,14 @@ class Array[unchecked out Elem] < Object
# e # => #<Enumerator: [:foo, "bar", 2]:index>
# e.each {|element| element == 'bar' } # => 1
#
# Array#find_index is an alias for Array#index.
#
# Related: #rindex.
#
def find_index: (untyped obj) -> ::Integer?
| () { (Elem item) -> boolish } -> ::Integer?
| () -> ::Enumerator[Elem, ::Integer?]

# <!--
# rdoc-file=array.c
# rdoc-file=array.rb
# - array.first -> object or nil
# - array.first(n) -> new_array
# -->
Expand Down Expand Up @@ -2078,8 +2067,6 @@ class Array[unchecked out Elem] < Object
# e # => #<Enumerator: [:foo, "bar", 2]:index>
# e.each {|element| element == 'bar' } # => 1
#
# Array#find_index is an alias for Array#index.
#
# Related: #rindex.
#
alias index find_index
Expand Down Expand Up @@ -2130,8 +2117,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2]
# a.inspect # => "[:foo, \"bar\", 2]"
#
# Array#to_s is an alias for Array#inspect.
#
def inspect: () -> String

# <!--
Expand All @@ -2147,6 +2132,9 @@ class Array[unchecked out Elem] < Object
# a.intersect?(b) #=> true
# a.intersect?(c) #=> false
#
# Array elements are compared using `eql?` (items must also implement `hash`
# correctly).
#
def intersect?: (_ToAry[untyped]) -> bool

# <!--
Expand All @@ -2155,7 +2143,7 @@ class Array[unchecked out Elem] < Object
# -->
# Returns a new Array containing each element found both in `self` and in all of
# the given Arrays `other_arrays`; duplicates are omitted; items are compared
# using `eql?`:
# using `eql?` (items must also implement `hash` correctly):
#
# [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
# [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
Expand Down Expand Up @@ -2221,7 +2209,7 @@ class Array[unchecked out Elem] < Object
| () -> ::Enumerator[Elem, self]

# <!--
# rdoc-file=array.c
# rdoc-file=array.rb
# - array.last -> object or nil
# - array.last(n) -> new_array
# -->
Expand Down Expand Up @@ -2277,8 +2265,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.map
# a1 # => #<Enumerator: [:foo, "bar", 2]:map>
#
# Array#collect is an alias for Array#map.
#
alias map collect

# <!-- rdoc-file=array.c -->
Expand All @@ -2294,8 +2280,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.map!
# a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
#
# Array#collect! is an alias for Array#map!.
#
alias map! collect!

# <!--
Expand Down Expand Up @@ -2608,8 +2592,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2]
# a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
#
# Array#prepend is an alias for Array#unshift.
#
# Related: #push, #pop, #shift.
#
alias prepend unshift
Expand Down Expand Up @@ -2695,8 +2677,6 @@ class Array[unchecked out Elem] < Object
# a1 = a.push([:baz, :bat], [:bam, :bad])
# a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
#
# Array#append is an alias for Array#push.
#
# Related: #pop, #shift, #unshift.
#
def push: (*Elem obj) -> self
Expand Down Expand Up @@ -3159,8 +3139,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2, :bam]
# a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
#
# Array#filter is an alias for Array#select.
#
def select: () { (Elem item) -> boolish } -> ::Array[Elem]
| () -> ::Enumerator[Elem, ::Array[Elem]]

Expand All @@ -3184,8 +3162,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2, :bam]
# a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
#
# Array#filter! is an alias for Array#select!.
#
def select!: () { (Elem item) -> boolish } -> self?
| () -> ::Enumerator[Elem, self?]

Expand Down Expand Up @@ -3347,8 +3323,6 @@ class Array[unchecked out Elem] < Object
# # Raises TypeError (no implicit conversion of Symbol into Integer):
# a[:foo]
#
# Array#slice is an alias for Array#[].
#
def slice: (int index) -> Elem?
| (int start, int length) -> ::Array[Elem]?
| (::Range[::Integer] range) -> ::Array[Elem]?
Expand Down Expand Up @@ -3682,8 +3656,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2]
# a.inspect # => "[:foo, \"bar\", 2]"
#
# Array#to_s is an alias for Array#inspect.
#
alias to_s inspect

# <!--
Expand Down Expand Up @@ -3780,8 +3752,6 @@ class Array[unchecked out Elem] < Object
# a = [:foo, 'bar', 2]
# a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
#
# Array#prepend is an alias for Array#unshift.
#
# Related: #push, #pop, #shift.
#
def unshift: (*Elem obj) -> self
Expand Down
4 changes: 2 additions & 2 deletions core/basic_object.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class BasicObject
# Note: that some objects of builtin classes are reused for optimization. This
# is the case for immediate values and frozen string literals.
#
# BasicObject implements +__id__+, Kernel implements `object_id`.
# BasicObject implements `__id__`, Kernel implements `object_id`.
#
# Immediate values are not passed by reference but are passed by value: `nil`,
# `true`, `false`, Fixnums, Symbols, and some Floats.
Expand All @@ -151,7 +151,7 @@ class BasicObject
# When the method is identified by a string, the string is converted to a
# symbol.
#
# BasicObject implements +__send__+, Kernel implements `send`. `__send__` is
# BasicObject implements `__send__`, Kernel implements `send`. `__send__` is
# safer than `send` when *obj* has the same method name like `Socket`. See also
# `public_send`.
#
Expand Down
10 changes: 8 additions & 2 deletions core/comparable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
# * #<: Returns whether `self` is less than the given object.
# * #<=: Returns whether `self` is less than or equal to the given object.
# * #==: Returns whether `self` is equal to the given object.
# * #>: Returns whether `self` is greater than or equal to the given object.
# * #>=: Returns whether `self` is greater than the given object.
# * #>: Returns whether `self` is greater than the given object.
# * #>=: Returns whether `self` is greater than or equal to the given object.
# * #between?: Returns `true` if `self` is between two given objects.
# * #clamp: For given objects `min` and `max`, or range `(min..max)`, returns:
#
Expand Down Expand Up @@ -124,6 +124,12 @@ module Comparable : _WithSpaceshipOperator
# 'd'.clamp('a', 'f') #=> 'd'
# 'z'.clamp('a', 'f') #=> 'f'
#
# If *min* is `nil`, it is considered smaller than *obj*, and if *max* is `nil`,
# it is considered greater than *obj*.
#
# -20.clamp(0, nil) #=> 0
# 523.clamp(nil, 100) #=> 100
#
# In `(range)` form, returns *range.begin* if *obj* `<=>` *range.begin* is less
# than zero, *range.end* if *obj* `<=>` *range.end* is greater than zero, and
# *obj* otherwise.
Expand Down
Loading