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
Enhanced RDoc for Integer #5118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some more research into the chr
method, and think the documentation should be fixed for it. It's probably best to fix the documentation, but still include the fixed documentation in the numeric.c
file, for consistency. Only methods defined in numeric.rb
should be documented there.
numeric.rb
Outdated
# 65.chr # => "A" | ||
# 0..chr # => "\x00" | ||
# 255.chr # => "\xFF" | ||
# 255.chr(Encoding::UTF_8) # => "ÿ" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove this example line, or change it so it doesn't have the ÿ
character? For example:
string = 255.chr(Encoding::UTF_8)
string.encoding # => Encoding::UTF_8
FWIW, on my machine (where Encoding.default_internal
is nil
):
255.chr(Encoding::UTF_8) # => "\u00FF"
So the example you are using depends on configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
numeric.rb
Outdated
|
||
# Document-method: Integer#chr | ||
# call-seq: | ||
# chr(encoding = Encoding.default_internal) -> string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this call-seq is correct in terms of the default argument:
Encoding.default_internal ='UTF-8'
255.chr.encoding # => #<Encoding:ASCII-8BIT>
255.chr(Encoding.default_internal).encoding # => #<Encoding:UTF-8>
Encoding.default_internal = nil
255.chr.encoding # => #<Encoding:ASCII-8BIT>
255.chr(Encoding.default_internal) # TypeError
Probably needs two call-seq
lines, one for no argument and one for an argument provided, since the behavior when providing a argument with the given default value is not the same as not providing an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
TY! |
Treats:
This is a replacement for the merged-then-reverted PR 5099, which had an offending character in a C-code comment (from an irb example). The containing RDoc is now moved out of numeric.c and into numeric.rb, which I hope will be ok.