Merge pull request #2999 from sagmor/better-docs

More Docs
This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-10-22 07:10:16 +09:00
20 changed files with 272 additions and 208 deletions
+1 -1
View File
@@ -1068,7 +1068,7 @@ mrb_init_array(mrb_state *mrb)
{
struct RClass *a;
a = mrb->array_class = mrb_define_class(mrb, "Array", mrb->object_class); /* 15.2.12 */
mrb->array_class = a = mrb_define_class(mrb, "Array", mrb->object_class); /* 15.2.12 */
MRB_SET_INSTANCE_TT(a, MRB_TT_ARRAY);
mrb_define_class_method(mrb, a, "[]", mrb_ary_s_create, MRB_ARGS_ANY()); /* 15.2.12.4.1 */
+30 -30
View File
@@ -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"]
* 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"]
* # 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
@@ -827,7 +827,7 @@ mrb_init_hash(mrb_state *mrb)
{
struct RClass *h;
h = mrb->hash_class = mrb_define_class(mrb, "Hash", mrb->object_class); /* 15.2.13 */
mrb->hash_class = h = mrb_define_class(mrb, "Hash", mrb->object_class); /* 15.2.13 */
MRB_SET_INSTANCE_TT(h, MRB_TT_HASH);
mrb_define_method(mrb, h, "[]", mrb_hash_aget, MRB_ARGS_REQ(1)); /* 15.2.13.4.2 */
+1 -1
View File
@@ -1097,7 +1097,7 @@ mrb_init_kernel(mrb_state *mrb)
{
struct RClass *krn;
krn = mrb->kernel_module = mrb_define_module(mrb, "Kernel"); /* 15.3.1 */
mrb->kernel_module = krn = mrb_define_module(mrb, "Kernel"); /* 15.3.1 */
mrb_define_class_method(mrb, krn, "block_given?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.2 */
mrb_define_class_method(mrb, krn, "global_variables", mrb_f_global_variables, MRB_ARGS_NONE()); /* 15.3.1.2.4 */
mrb_define_class_method(mrb, krn, "iterator?", mrb_f_block_given_p_m, MRB_ARGS_NONE()); /* 15.3.1.2.5 */
+2 -2
View File
@@ -1161,7 +1161,7 @@ mrb_init_numeric(mrb_state *mrb)
mrb_define_method(mrb, integer, "to_int", int_to_i, MRB_ARGS_NONE());
/* Fixnum Class */
fixnum = mrb->fixnum_class = mrb_define_class(mrb, "Fixnum", integer);
mrb->fixnum_class = fixnum = mrb_define_class(mrb, "Fixnum", integer);
mrb_define_method(mrb, fixnum, "+", fix_plus, MRB_ARGS_REQ(1)); /* 15.2.8.3.1 */
mrb_define_method(mrb, fixnum, "-", fix_minus, MRB_ARGS_REQ(1)); /* 15.2.8.3.2 */
mrb_define_method(mrb, fixnum, "*", fix_mul, MRB_ARGS_REQ(1)); /* 15.2.8.3.3 */
@@ -1181,7 +1181,7 @@ mrb_init_numeric(mrb_state *mrb)
mrb_define_method(mrb, fixnum, "divmod", fix_divmod, MRB_ARGS_REQ(1)); /* 15.2.8.3.30 (x) */
/* Float Class */
fl = mrb->float_class = mrb_define_class(mrb, "Float", numeric); /* 15.2.9 */
mrb->float_class = fl = mrb_define_class(mrb, "Float", numeric); /* 15.2.9 */
mrb_undef_class_method(mrb, fl, "new");
mrb_define_method(mrb, fl, "+", flo_plus, MRB_ARGS_REQ(1)); /* 15.2.9.3.1 */
mrb_define_method(mrb, fl, "-", flo_minus, MRB_ARGS_REQ(1)); /* 15.2.9.3.2 */
+3 -3
View File
@@ -264,7 +264,7 @@ mrb_init_object(mrb_state *mrb)
struct RClass *t;
struct RClass *f;
n = mrb->nil_class = mrb_define_class(mrb, "NilClass", mrb->object_class);
mrb->nil_class = n = mrb_define_class(mrb, "NilClass", mrb->object_class);
mrb_undef_class_method(mrb, n, "new");
mrb_define_method(mrb, n, "&", false_and, MRB_ARGS_REQ(1)); /* 15.2.4.3.1 */
mrb_define_method(mrb, n, "^", false_xor, MRB_ARGS_REQ(1)); /* 15.2.4.3.2 */
@@ -273,7 +273,7 @@ mrb_init_object(mrb_state *mrb)
mrb_define_method(mrb, n, "to_s", nil_to_s, MRB_ARGS_NONE()); /* 15.2.4.3.5 */
mrb_define_method(mrb, n, "inspect", nil_inspect, MRB_ARGS_NONE());
t = mrb->true_class = mrb_define_class(mrb, "TrueClass", mrb->object_class);
mrb->true_class = t = mrb_define_class(mrb, "TrueClass", mrb->object_class);
mrb_undef_class_method(mrb, t, "new");
mrb_define_method(mrb, t, "&", true_and, MRB_ARGS_REQ(1)); /* 15.2.5.3.1 */
mrb_define_method(mrb, t, "^", true_xor, MRB_ARGS_REQ(1)); /* 15.2.5.3.2 */
@@ -281,7 +281,7 @@ mrb_init_object(mrb_state *mrb)
mrb_define_method(mrb, t, "|", true_or, MRB_ARGS_REQ(1)); /* 15.2.5.3.4 */
mrb_define_method(mrb, t, "inspect", true_to_s, MRB_ARGS_NONE());
f = mrb->false_class = mrb_define_class(mrb, "FalseClass", mrb->object_class);
mrb->false_class = f = mrb_define_class(mrb, "FalseClass", mrb->object_class);
mrb_undef_class_method(mrb, f, "new");
mrb_define_method(mrb, f, "&", false_and, MRB_ARGS_REQ(1)); /* 15.2.6.3.1 */
mrb_define_method(mrb, f, "^", false_xor, MRB_ARGS_REQ(1)); /* 15.2.6.3.2 */
+1 -1
View File
@@ -2674,7 +2674,7 @@ mrb_init_string(mrb_state *mrb)
mrb_static_assert(RSTRING_EMBED_LEN_MAX < (1 << 5), "pointer size too big for embedded string");
s = mrb->string_class = mrb_define_class(mrb, "String", mrb->object_class); /* 15.2.10 */
mrb->string_class = s = mrb_define_class(mrb, "String", mrb->object_class); /* 15.2.10 */
MRB_SET_INSTANCE_TT(s, MRB_TT_STRING);
mrb_define_method(mrb, s, "bytesize", mrb_str_bytesize, MRB_ARGS_NONE());
+1 -1
View File
@@ -478,7 +478,7 @@ mrb_init_symbol(mrb_state *mrb)
{
struct RClass *sym;
sym = mrb->symbol_class = mrb_define_class(mrb, "Symbol", mrb->object_class); /* 15.2.11 */
mrb->symbol_class = sym = mrb_define_class(mrb, "Symbol", mrb->object_class); /* 15.2.11 */
mrb_define_method(mrb, sym, "===", sym_equal, MRB_ARGS_REQ(1)); /* 15.2.11.3.1 */
mrb_define_method(mrb, sym, "id2name", mrb_sym_to_s, MRB_ARGS_NONE()); /* 15.2.11.3.2 */