Skip to content

Commit

Permalink
Generate RDoc from 3.3.0-preview3
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Dec 14, 2023
1 parent e3bd960 commit 6b49416
Show file tree
Hide file tree
Showing 67 changed files with 7,248 additions and 3,985 deletions.
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
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
6 changes: 2 additions & 4 deletions core/data.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# distance.unit #=> "km"
#
# Constructed object also has a reasonable definitions of #== operator, #to_h
# hash conversion, and #deconstruct/#deconstruct_keys to be used in pattern
# hash conversion, and #deconstruct / #deconstruct_keys to be used in pattern
# matching.
#
# ::define method accepts an optional block and evaluates it in the context of
Expand Down Expand Up @@ -66,11 +66,9 @@
class Data
# <!--
# rdoc-file=struct.c
# - define(name, *symbols) -> class
# - define(*symbols) -> class
# -->
# Defines a new Data class. If the first argument is a string, the class is
# stored in `Data::<name>` constant.
# Defines a new Data class.
#
# measure = Data.define(:amount, :unit)
# #=> #<Class:0x00007f70c6868498>
Expand Down
Loading

0 comments on commit 6b49416

Please sign in to comment.