Commit 13b55253 authored by Seba Gamboa's avatar Seba Gamboa

Remove obvious warnings from docs

parent f0e99742
......@@ -119,8 +119,8 @@ mrb_ary_values_at(mrb_state *mrb, mrb_value self)
* Returns the result of interpreting <i>aray</i> as an array of
* <tt>[key, value]</tt> paris.
*
* [[:foo, :bar], [1, 2]].to_h
* # => {:foo => :bar, 1 => 2}
* [[:foo, :bar], [1, 2]].to_h
* # => {:foo => :bar, 1 => 2}
*
* @mrbgem mruby-array-ext
*/
......
......@@ -78,10 +78,10 @@ module Enumerable
# Passes elements to the block until the block returns +nil+ or +false+,
# then stops iterating and returns an array of all prior elements.
#
# If no block is given, an enumerator is returned instead.
# If no block is given, an enumerator is returned instead.
#
# a = [1, 2, 3, 4, 5, 0]
# a.take_while {|i| i < 3 } #=> [1, 2]
# a = [1, 2, 3, 4, 5, 0]
# a.take_while {|i| i < 3 } #=> [1, 2]
#
# @mrbgem mruby-enum-ext
def take_while(&block)
......@@ -96,13 +96,12 @@ module Enumerable
end
##
# call-seq:
# enum.each_cons(n) {...} -> nil
#
# Iterates the given block for each array of consecutive <n>
# elements.
#
# e.g.:
# @return [nil]
#
# @example
# (1..10).each_cons(3) {|a| p a}
# # outputs below
# [1, 2, 3]
......@@ -130,12 +129,11 @@ module Enumerable
end
##
# call-seq:
# enum.each_slice(n) {...} -> nil
#
# Iterates the given block for each slice of <n> elements.
#
# e.g.:
# @return [nil]
#
# @example
# (1..10).each_slice(3) {|a| p a}
# # outputs below
# [1, 2, 3]
......@@ -170,7 +168,7 @@ module Enumerable
# block, and values are arrays of elements in <i>enum</i>
# corresponding to the key.
#
# (1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
# (1..6).group_by {|i| i%3} #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
#
# @mrbgem mruby-enum-ext
def group_by(&block)
......
......@@ -581,27 +581,27 @@ module Kernel
#
# Here is such an example, with parameter passing and a sizing block:
#
# module Enumerable
# # a generic method to repeat the values of any enumerable
# def repeat(n)
# raise ArgumentError, "#{n} is negative!" if n < 0
# unless block_given?
# return to_enum(__method__, n) do # __method__ is :repeat here
# sz = size # Call size and multiply by n...
# sz * n if sz # but return nil if size itself is nil
# module Enumerable
# # a generic method to repeat the values of any enumerable
# def repeat(n)
# raise ArgumentError, "#{n} is negative!" if n < 0
# unless block_given?
# return to_enum(__method__, n) do # __method__ is :repeat here
# sz = size # Call size and multiply by n...
# sz * n if sz # but return nil if size itself is nil
# end
# end
# each do |*val|
# n.times { yield *val }
# end
# end
# each do |*val|
# n.times { yield *val }
# end
# end
# end
#
# %i[hello world].repeat(2) { |w| puts w }
# # => Prints 'hello', 'hello', 'world', 'world'
# enum = (1..14).repeat(3)
# # => returns an Enumerator when called without a block
# enum.first(4) # => [1, 1, 1, 2]
# %i[hello world].repeat(2) { |w| puts w }
# # => Prints 'hello', 'hello', 'world', 'world'
# enum = (1..14).repeat(3)
# # => returns an Enumerator when called without a block
# enum.first(4) # => [1, 1, 1, 2]
#
def to_enum(meth=:each, *args)
Enumerator.new self, meth, *args
......
......@@ -7,22 +7,22 @@ class Hash
##
# call-seq:
# Hash[ key, value, ... ] -> new_hash
# Hash[ [ [key, value], ... ] ] -> new_hash
# Hash[ object ] -> new_hash
# Hash[ key, value, ... ] -> new_hash
# Hash[ [ [key, value], ... ] ] -> new_hash
# Hash[ object ] -> new_hash
#
# Creates a new hash populated with the given objects.
#
# Similar to the literal <code>{ _key_ => _value_, ... }</code>. In the first
# Similar to the literal `{ _key_ => _value_, ... }`. In the first
# form, keys and values occur in pairs, so there must be an even number of
# arguments.
#
# The second and third form take a single argument which is either an array
# of key-value pairs or an object convertible to a hash.
#
# Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200}
# Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200}
# Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
# Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200}
# Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200}
# Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
#
# @mrbgem mruby-hash-ext
def self.[](*object)
......
......@@ -146,10 +146,10 @@ mrb_f_array(mrb_state *mrb, mrb_value self)
* <i>arg</i><code>.to_hash</code>. Returns an empty <code>Hash</code> when
* <i>arg</i> is <tt>nil</tt> or <tt>[]</tt>.
*
* Hash([]) #=> {}
* Hash(nil) #=> {}
* Hash(key: :value) #=> {:key => :value}
* Hash([1, 2, 3]) #=> TypeError
* Hash([]) #=> {}
* Hash(nil) #=> {}
* Hash(key: :value) #=> {:key => :value}
* Hash([1, 2, 3]) #=> TypeError
*
* @mrbgem mruby-kernel-ext
*/
......
......@@ -236,7 +236,8 @@ math_tan(mrb_state *mrb, mrb_value obj)
* call-seq:
* Math.asin(x) -> float
*
* Computes the arc sine of <i>x</i>. Returns -{PI/2} .. {PI/2}.
* Computes the arc sine of <i>x</i>.
* @return computed value between `-(PI/2)` and `(PI/2)`.
*/
static mrb_value
math_asin(mrb_state *mrb, mrb_value obj)
......@@ -276,7 +277,7 @@ math_acos(mrb_state *mrb, mrb_value obj)
* call-seq:
* Math.atan(x) -> float
*
* Computes the arc tangent of <i>x</i>. Returns -{PI/2} .. {PI/2}.
* Computes the arc tangent of <i>x</i>. Returns `-(PI/2) .. (PI/2)`.
*/
static mrb_value
math_atan(mrb_state *mrb, mrb_value obj)
......
##
# Enumerable
#
# ISO 15.3.2
# The <code>Enumerable</code> mixin provides collection classes with
# several traversal and searching methods, and with the ability to
# sort. The class must provide a method `each`, which
# yields successive members of the collection. If
# {Enumerable#max}, {#min}, or
# {#sort} is used, the objects in the collection must also
# implement a meaningful `<=>` operator, as these methods
# rely on an ordering between members of the collection.
#
# The <code>Enumerable</code> mixin provides collection classes with
# several traversal and searching methods, and with the ability to
# sort. The class must provide a method <code>each</code>, which
# yields successive members of the collection. If
# <code>Enumerable#max</code>, <code>#min</code>, or
# <code>#sort</code> is used, the objects in the collection must also
# implement a meaningful <code><=></code> operator, as these methods
# rely on an ordering between members of the collection.
# @ISO 15.3.2
module Enumerable
##
......
......@@ -74,8 +74,8 @@ class Hash
#
# If no block is given, an enumerator is returned instead.
#
# h = { "a" => 100, "b" => 200 }
# h.each {|key, value| puts "#{key} is #{value}" }
# h = { "a" => 100, "b" => 200 }
# h.each {|key, value| puts "#{key} is #{value}" }
#
# <em>produces:</em>
#
......
......@@ -294,22 +294,22 @@ mrb_hash_modify(mrb_state *mrb, mrb_value hash)
* default value. It is the block's responsibility to store the value
* in the hash if required.
*
* h = Hash.new("Go Fish")
* h["a"] = 100
* h["b"] = 200
* h["a"] #=> 100
* h["c"] #=> "Go Fish"
* # The following alters the single default object
* h["c"].upcase! #=> "GO FISH"
* h["d"] #=> "GO FISH"
* h.keys #=> ["a", "b"]
*
* # While this creates a new default object each time
* h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
* h["c"] #=> "Go Fish: c"
* h["c"].upcase! #=> "GO FISH: C"
* h["d"] #=> "Go Fish: d"
* h.keys #=> ["c", "d"]
* h = Hash.new("Go Fish")
* h["a"] = 100
* h["b"] = 200
* h["a"] #=> 100
* h["c"] #=> "Go Fish"
* # The following alters the single default object
* h["c"].upcase! #=> "GO FISH"
* h["d"] #=> "GO FISH"
* h.keys #=> ["a", "b"]
*
* # While this creates a new default object each time
* h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
* h["c"] #=> "Go Fish: c"
* h["c"].upcase! #=> "GO FISH: C"
* h["d"] #=> "Go Fish: d"
* h.keys #=> ["c", "d"]
*
*/
......@@ -517,10 +517,10 @@ mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key)
* key is not found, pass in the key and return the result of
* <i>block</i>.
*
* h = { "a" => 100, "b" => 200 }
* h.delete("a") #=> 100
* h.delete("z") #=> nil
* h.delete("z") { |el| "#{el} not found" } #=> "z not found"
* h = { "a" => 100, "b" => 200 }
* h.delete("a") #=> 100
* h.delete("z") #=> nil
* h.delete("z") { |el| "#{el} not found" } #=> "z not found"
*
*/
static mrb_value
......@@ -541,9 +541,9 @@ mrb_hash_delete(mrb_state *mrb, mrb_value self)
* two-item array <code>[</code> <i>key, value</i> <code>]</code>, or
* the hash's default value if the hash is empty.
*
* h = { 1 => "a", 2 => "b", 3 => "c" }
* h.shift #=> [1, "a"]
* h #=> {2=>"b", 3=>"c"}
* h = { 1 => "a", 2 => "b", 3 => "c" }
* h.shift #=> [1, "a"]
* h #=> {2=>"b", 3=>"c"}
*/
static mrb_value
......@@ -580,10 +580,10 @@ mrb_hash_shift(mrb_state *mrb, mrb_value hash)
* call-seq:
* hsh.clear -> hsh
*
* Removes all key-value pairs from <i>hsh</i>.
* Removes all key-value pairs from `hsh`.
*
* h = { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200}
* h.clear #=> {}
* h = { "a" => 100, "b" => 200 } #=> {"a"=>100, "b"=>200}
* h.clear #=> {}
*
*/
......@@ -609,10 +609,10 @@ mrb_hash_clear(mrb_state *mrb, mrb_value hash)
* use as a key (a <code>String</code> passed as a key will be
* duplicated and frozen).
*
* h = { "a" => 100, "b" => 200 }
* h["a"] = 9
* h["c"] = 4
* h #=> {"a"=>9, "b"=>200, "c"=>4}
* h = { "a" => 100, "b" => 200 }
* h["a"] = 9
* h["c"] = 4
* h #=> {"a"=>9, "b"=>200, "c"=>4}
*
*/
static mrb_value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment