Skip to content
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 IO #5367

Merged
merged 3 commits into from Dec 30, 2021
Merged

Enhanced RDoc for IO #5367

merged 3 commits into from Dec 30, 2021

Conversation

BurdetteLamar
Copy link
Member

Adds sections to class RDoc:

  • Lines
    • Line Separator
    • Line Limit
    • Line Number

Revises example text file t.txt to:

  • Include paragraphs (separated by double line separator).
  • Avoid being too long.

Revises examples that use the changed example file.

There are several other methods that will point to the added sections.

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Dec 28, 2021
io.c Outdated
Comment on lines 4028 to 4030
* f.gets(chomp: true)# => ""
* f.gets(chomp: true) # => "Fourth line"
* f.gets(chomp: true) # => "Fifth line"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* f.gets(chomp: true)# => ""
* f.gets(chomp: true) # => "Fourth line"
* f.gets(chomp: true) # => "Fifth line"
* f.gets(chomp: true) # => ""
* f.gets(chomp: true) # => "Fourth line"
* f.gets(chomp: true) # => "Fifth line"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

io.c Outdated
@@ -3461,19 +3460,19 @@ io_write_nonblock(rb_execution_context_t *ec, VALUE io, VALUE str, VALUE ex)
* When argument +out_string+ is given,
* the returned value is +out_string+, whose content is replaced:
*
* f = File.new('t.txt')
* f = File.ne w('t.txt')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* f = File.ne w('t.txt')
* f = File.new('t.txt')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

io.c Outdated
Comment on lines 3998 to 4001
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

io.c Outdated
Comment on lines 13972 to 13975
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"
* f.gets('l') # => "First l"
* f.gets('li') # => "ine\nSecond li"
* f.gets('lin') # => "ne\n\nFourth lin"
* f.gets # => "e\n"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

io.c Outdated
*
* There are two special line separators:
*
* - +nil+: The entire stream is read into a single string:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* - +nil+: The entire stream is read into a single string:
* - +nil+: The entire stream is read into a single string:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only one minor change requested.

*
* These methods include:
*
* - IO::foreach.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems odd to use periods after each of these entries. However, that's just an observation, so if you think periods should be used, I'm fine with that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the periods.

io.c Outdated
*
* - Returns the next line as determined by line separator +sep+,
* or +nil+ if none.
* - But returns no more than <tt>limit+1</tt> bytes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be correct for multibyte IO:

File.binwrite("t.t", "\u{10000}".b) # => 4
File.open('t.t', "r:UTF-8"){|f| f.gets("\n", 1).bytesize} #=> 4

The actual value is probably limit + maximum bytesize of single character in encoding - 1 (limit+3 for UTF-8, I'm not sure about other encodings). Not sure if there is a succinct way of stating that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of limit discussion recast.

Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New wording looks good. Thanks!

@BurdetteLamar BurdetteLamar merged commit 87c0369 into ruby:master Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
3 participants