Skip to content

Enhanced RDoc for GetoptLong#4

Merged
BurdetteLamar merged 5 commits intoruby:masterfrom
BurdetteLamar:rdoc
May 2, 2022
Merged

Enhanced RDoc for GetoptLong#4
BurdetteLamar merged 5 commits intoruby:masterfrom
BurdetteLamar:rdoc

Conversation

@BurdetteLamar
Copy link
Copy Markdown
Member

@BurdetteLamar BurdetteLamar commented Oct 26, 2021

Enhanced RDoc for GetoptLong.

@BurdetteLamar BurdetteLamar added the documentation Improvements or additions to documentation label Oct 26, 2021
Copy link
Copy Markdown
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

👏 Thanks, @BurdetteLamar for working on the readability of this documentation.

Comment on lines +126 to +128
# Note that an option type has to do with the <em>option argument</em>
# (whether it is required, optional, or forbidden),
# not with whether the option itself is required.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Super good note!

#
# ==== Option with Optional Argument
#
# An option of type <tt>GetoptLong::OPTIONAL_ARGUMENT</tt>:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# An option of type <tt>GetoptLong::OPTIONAL_ARGUMENT</tt>:
# An option of type <tt>GetoptLong::OPTIONAL_ARGUMENT</tt>

(Same as above, perhaps the colon is unnecessary.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed.

# ["--xxx", "Foo"]
# ["--yyy", "Bar"]
# ["--zzz", ""]
# Remaining ARGV: ["Baz", "Bat", "Bam"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice example!

@BurdetteLamar
Copy link
Copy Markdown
Member Author

👏 Thanks, @BurdetteLamar for working on the readability of this documentation.

And thanks, @olleolleolle, for your careful review.

@BurdetteLamar
Copy link
Copy Markdown
Member Author

@hsbt, is this ready for review and/or merge?

@BurdetteLamar BurdetteLamar requested a review from hsbt November 4, 2021 19:13
@hsbt
Copy link
Copy Markdown
Member

hsbt commented Nov 4, 2021

I'm not native. I couldn't review this.

@hsbt hsbt removed their request for review November 4, 2021 23:29
# ["--xxx", ""]
# ["--xyz", ""]
#
# === Protected Options
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems weird to call this "protected options"? Does GetoptLong use that wording internally? -- on the command line indicates that all following entries in argv are arguments and not options, even if they start with a dash.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree that "protected options" is weak, and is not used internally. I don't have a better term to use as the heading.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe "Treating Remaining Options as Arguments"?

# pure Ruby implementation.
# A simple example: file <tt>simple.rb</tt>:
#
# :include: ../doc/simple.rb
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How does this including work for usage as a default gem in Ruby? I'm guessing it wouldn't work, since we don't want to have simple.rb in doc in the Ruby repository. Possibly we could use a doc/getoptlong directory instead. Not sure if that is desired. Hopefully @hsbt can provide input.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will wait for direction on this one.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Have moved included files to doc/getoptlong, which is consistent with other default gems' usage. Also (the horror!), I did not realize that directory doc was in the .gitignore file, and so only now are the .rdoc files getting into this PR.

@jeremyevans jeremyevans requested a review from hsbt November 5, 2021 17:48
@BurdetteLamar
Copy link
Copy Markdown
Member Author

I see that there's no maintainer for this repo. So how does this (or anything) get reviewed and merged?

Copy link
Copy Markdown

@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.

I think this is a major improvement to the documentation, I just have a couple of requests for changes.

# === ARGV
#
# \GetoptLong does not process the command line itself,
# but instead processes array ARGV (which is derived from the command line).
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would remove discussion of command lines. Outside of Windows, programs in general are called with array of arguments, not with a command line. If you are executing commands from the shell, the shell will take the command line, parse it, and call the program with an array of arguments. You can focus discussion on ARGV, without discussing command lines.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean just here? Or throughout (28 mentions of command line, including example command lines)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When discussing example command lines, it's fine to keep the reference. However, any place you are discussing argument processing, the reference should be removed. It's important to understand that the command line to argument processing is unrelated to option parsing. Option parsing via optparse/getoptlong is for taking an array of arguments and separating out the options. From a lexing/parsing perspective, the shell lexes, and optparse/getoptlong parses.

/.yardoc
/_yardoc/
/coverage/
/doc/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/doc/ may be ignored for a reason. Maybe because it is the default location for rdoc to generate documentation? I recommend having the example code in an examples directory, as that better indicates that these are executable examples. You can still include the code in the documentation with :include:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved to examples directory.

@BurdetteLamar
Copy link
Copy Markdown
Member Author

@jeremyevans, ready for review.

Copy link
Copy Markdown

@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.

examples change looks fine. I still think it would be a good idea to change the command line references, but I'll leave that to you. getoptlong is currently unmaintained, so you can merge this yourself after you decide whether to change the references to the command line.

@BurdetteLamar
Copy link
Copy Markdown
Member Author

examples change looks fine. I still think it would be a good idea to change the command line references, but I'll leave that to you. getoptlong is currently unmaintained, so you can merge this yourself after you decide whether to change the references to the command line.

@jeremyevans, I'm happy to make these further changes. I've removed a dozen referenced to the command line, leaving only those that refer to an actual example command line. Hope I haven't removed too many.

@BurdetteLamar BurdetteLamar merged commit 1544f2f into ruby:master May 2, 2022
matzbot pushed a commit to ruby/ruby that referenced this pull request May 2, 2022
schneems pushed a commit to schneems/ruby that referenced this pull request May 23, 2022
schneems pushed a commit to schneems/ruby that referenced this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants