ruby-changes:69501
From: Burdette <ko1@a...>
Date: Fri, 29 Oct 2021 07:02:04 +0900 (JST)
Subject: [ruby-changes:69501] 3e743d3147 (master): Cleanup some RDoc (#5050)
https://git.ruby-lang.org/ruby.git/commit/?id=3e743d3147 From 3e743d31473686a0365e60b3f233707ef58625fe Mon Sep 17 00:00:00 2001 From: Burdette Lamar <BurdetteLamar@Y...> Date: Thu, 28 Oct 2021 17:01:49 -0500 Subject: Cleanup some RDoc (#5050) Mostly adding blank line before and after code segment, to improve compliance with doc\documentation_guide.rdoc. --- string.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 106 insertions(+), 23 deletions(-) diff --git a/string.c b/string.c index 64f290d62c9..c1662be4779 100644 --- a/string.c +++ b/string.c @@ -1860,7 +1860,9 @@ rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L1860 * String.new(capacity: 4096) # => "" * * The +string+, +encoding+, and +capacity+ arguments may all be used together: + * * String.new('hello', encoding: 'UTF-8', capacity: 25) + * */ static VALUE @@ -2157,9 +2159,10 @@ rb_str_strlen(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L2159 /* * call-seq: - * string.length -> integer + * length -> integer * * Returns the count of characters (not bytes) in +self+: + * * "\x80\u3042".length # => 2 * "hello".length # => 5 * @@ -2176,9 +2179,10 @@ rb_str_length(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L2179 /* * call-seq: - * string.bytesize -> integer + * bytesize -> integer * * Returns the count of bytes in +self+: + * * "\x80\u3042".bytesize # => 4 * "hello".bytesize # => 5 * @@ -2193,12 +2197,14 @@ rb_str_bytesize(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L2197 /* * call-seq: - * string.empty? -> true or false + * empty? -> true or false * * Returns +true+ if the length of +self+ is zero, +false+ otherwise: + * * "hello".empty? # => false * " ".empty? # => false * "".empty? # => true + * */ static VALUE @@ -2212,7 +2218,9 @@ rb_str_empty(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L2218 * string + other_string -> new_string * * Returns a new \String containing +other_string+ concatenated to +self+: + * * "Hello from " + self.to_s # => "Hello from main" + * */ VALUE @@ -2281,8 +2289,10 @@ rb_str_opt_plus(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L2289 * string * integer -> new_string * * Returns a new \String containing +integer+ copies of +self+: + * * "Ho! " * 3 # => "Ho! Ho! Ho! " * "Ho! " * 0 # => "" + * */ VALUE @@ -2349,13 +2359,16 @@ rb_str_times(VALUE str, VALUE times) https://github.com/ruby/ruby/blob/trunk/string.c#L2359 * * Returns the result of formatting +object+ into the format specification +self+ * (see Kernel#sprintf for formatting details): + * * "%05d" % 123 # => "00123" * * If +self+ contains multiple substitutions, +object+ must be * an \Array or \Hash containing the values to be substituted: + * * "%-5s: %016x" % [ "ID", self.object_id ] # => "ID : 00002b054ec93168" * "foo = %{foo}" % {foo: 'bar'} # => "foo = bar" * "foo = %{foo}, baz = %{baz}" % {foo: 'bar', baz: 'bat'} # => "foo = bar, baz = bat" + * */ static VALUE @@ -2652,7 +2665,7 @@ rb_check_string_type(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L2665 * Otherwise if +object+ responds to <tt>:to_str</tt>, * calls <tt>object.to_str</tt> and returns the result. * - * Returns +nil+ if +object+ does not respond to <tt>:to_str</tt> + * Returns +nil+ if +object+ does not respond to <tt>:to_str</tt>. * * Raises an exception unless <tt>object.to_str</tt> returns a \String object. */ @@ -3340,7 +3353,7 @@ rb_str_concat_literals(size_t num, const VALUE *strary) https://github.com/ruby/ruby/blob/trunk/string.c#L3353 /* * call-seq: - * string.concat(*objects) -> string + * concat(*objects) -> string * * Concatenates each object in +objects+ to +self+ and returns +self+: * @@ -3350,6 +3363,7 @@ rb_str_concat_literals(size_t num, const VALUE *strary) https://github.com/ruby/ruby/blob/trunk/string.c#L3363 * * For each given object +object+ that is an \Integer, * the value is considered a codepoint and converted to a character before concatenation: + * * s = 'foo' * s.concat(32, 'bar', 32, 'baz') # => "foo bar baz" * @@ -3388,6 +3402,7 @@ rb_str_concat_multi(int argc, VALUE *argv, VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L3402 * * If +object+ is an \Integer, * the value is considered a codepoint and converted to a character before concatenation: + * * s = 'foo' * s << 33 # => "foo!" * @@ -3462,6 +3477,7 @@ rb_str_concat(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3477 * string.prepend(*other_strings) -> string * * Prepends each string in +other_strings+ to +self+ and returns +self+: + * * s = 'foo' * s.prepend('bar', 'baz') # => "barbazfoo" * s # => "barbazfoo" @@ -3519,7 +3535,7 @@ rb_str_hash_cmp(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3535 * Returns the integer hash value for +self+. * The value is based on the length, content and encoding of +self+. * - * Related: Object#hash + * Related: Object#hash. */ static VALUE @@ -3589,6 +3605,7 @@ rb_str_cmp(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3605 * * Returns +true+ if +object+ has the same length and content; * as +self+; +false+ otherwise: + * * s = 'foo' * s == 'foo' # => true * s == 'food' # => false @@ -3616,17 +3633,20 @@ rb_str_equal(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3633 /* * call-seq: - * string.eql?(object) -> true or false + * eql?(object) -> true or false * * Returns +true+ if +object+ has the same length and content; * as +self+; +false+ otherwise: + * * s = 'foo' * s.eql?('foo') # => true * s.eql?('food') # => false * s.eql?('FOO') # => false * * Returns +false+ if the two strings' encodings are not compatible: + * * "\u{e4 f6 fc}".encode("ISO-8859-1").eql?("\u{c4 d6 dc}") # => false + * */ MJIT_FUNC_EXPORTED VALUE @@ -3642,18 +3662,21 @@ rb_str_eql(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3662 * string <=> other_string -> -1, 0, 1, or nil * * Compares +self+ and +other_string+, returning: + * * - -1 if +other_string+ is larger. * - 0 if the two are equal. * - 1 if +other_string+ is smaller. * - +nil+ if the two are incomparable. * * Examples: + * * 'foo' <=> 'foo' # => 0 * 'foo' <=> 'food' # => -1 * 'food' <=> 'foo' # => 1 * 'FOO' <=> 'foo' # => -1 * 'foo' <=> 'FOO' # => 1 * 'foo' <=> 1 # => nil + * */ static VALUE @@ -3673,21 +3696,24 @@ static VALUE str_casecmp_p(VALUE str1, VALUE str2); https://github.com/ruby/ruby/blob/trunk/string.c#L3696 /* * call-seq: - * str.casecmp(other_str) -> -1, 0, 1, or nil + * casecmp(other_str) -> -1, 0, 1, or nil * * Compares +self+ and +other_string+, ignoring case, and returning: + * * - -1 if +other_string+ is larger. * - 0 if the two are equal. * - 1 if +other_string+ is smaller. * - +nil+ if the two are incomparable. * * Examples: + * * 'foo'.casecmp('foo') # => 0 * 'foo'.casecmp('food') # => -1 * 'food'.casecmp('foo') # => 1 * 'FOO'.casecmp('foo') # => 0 * 'foo'.casecmp('FOO') # => 0 * 'foo'.casecmp(1) # => nil + * */ static VALUE @@ -3759,10 +3785,11 @@ str_casecmp(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3785 /* * call-seq: - * string.casecmp?(other_string) -> true, false, or nil + * casecmp?(other_string) -> true, false, or nil * * Returns +true+ if +self+ and +other_string+ are equal after * Unicode case folding, otherwise +false+: + * * 'foo'.casecmp?('foo') # => true * 'foo'.casecmp?('food') # => false * 'food'.casecmp?('foo') # => false @@ -3770,7 +3797,9 @@ str_casecmp(VALUE str1, VALUE str2) https://github.com/ruby/ruby/blob/trunk/string.c#L3797 * 'foo'.casecmp?('FOO') # => true * * Returns +nil+ if the two values are incomparable: + * * 'foo'.casecmp?(1) # => nil + * */ static VALUE @@ -3864,11 +3893,12 @@ rb_strseq_index(VALUE str, VALUE sub, long offset, int in_byte) https://github.com/ruby/ruby/blob/trunk/string.c#L3893 /* * call-seq: - * string.index(substring, offset = 0) -> integer or nil - * string.index(regexp, offset = 0) -> integer or nil + * index(substring, offset = 0) -> integer or nil + * index(regexp, offset = 0) -> integer or nil * * Returns the \Integer index of the first occurrence of the given +substring+, * or +nil+ if none found: + * * 'foo'.index('f') # => 0 * 'foo'.index('o') # => 1 * 'foo'.index('oo') # => 1 @@ -3876,6 +3906,7 @@ rb_strseq_index(VALUE str, VALUE sub, long offset, int in_byte) https://github.com/ruby/ruby/blob/trunk/string.c#L3906 * * Returns the \Integer index of the first match for the given \Regexp +regexp+, * or +nil+ if none found: + * * 'foo'.index(/f/) # => 0 * 'foo'.index(/o/) # => 1 * 'foo'.index(/oo/) # => 1 @@ -3883,17 +3914,19 @@ rb_strseq_index(VALUE str, VALUE sub, long offset, int in_byte) https://github.com/ruby/ruby/blob/trunk/string.c#L3914 * * \Integer argument +offset+, if given, specifies the position in the * string to begin the search: + * * 'foo'.index('o', 1) # => 1 * 'foo'.index('o', 2) # => 2 * 'foo'.index('o', 3) # => nil * * If +offset+ is negative, counts backward from the end of +self+: + * * 'foo'.index('o', -1) # => 2 * 'foo'.index('o', -2) # => 1 * 'foo'.index('o', -3) # => 1 * 'foo'.index('o', -4) # => nil * - * Related: String#rindex + * Related: String#rindex. */ static VALUE @@ -4037,11 +4070,12 (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/