Forum: Ruby-core [ruby-trunk - Bug #6997][Open] Improve documentation for OptionParser

Posted by eike.rb (Eike Dierks) (Guest)
on 2012-09-08 21:24
(Received via mailing list)
Issue #6997 has been reported by eike.rb (Eike Dierks).

----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997

Author: eike.rb (Eike Dierks)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Posted by eike.rb (Eike Dierks) (Guest)
on 2012-09-10 22:02
(Received via mailing list)
Issue #6997 has been updated by eike.rb (Eike Dierks).


Ok, I was a bit blind on that,
I think that I now do understand how it works.

But anyway, the documentation should be improved.

I'd suggest to improve the examples to make it more clear upfront.


----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997#change-29235

Author: eike.rb (Eike Dierks)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Posted by Zachary Scott (Guest)
on 2012-09-10 22:31
(Received via mailing list)
Better and more examples are always welcome, if you have any ideas
please feel free to submit a patch.

Otherwise, I'll try to put something together for this and #6996
sometime this week.
Posted by zzak (Zachary Scott) (Guest)
on 2012-09-14 21:03
(Received via mailing list)
Issue #6997 has been updated by zzak (Zachary Scott).

Category set to DOC
Assignee set to zzak (Zachary Scott)
Target version set to 2.0.0


----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997#change-29313

Author: eike.rb (Eike Dierks)
Status: Open
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: DOC
Target version: 2.0.0
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Posted by usa (Usaku NAKAMURA) (Guest)
on 2012-12-21 14:27
(Received via mailing list)
Issue #6997 has been updated by usa (Usaku NAKAMURA).

Status changed from Open to Assigned


----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997#change-34962

Author: eike.rb (Eike Dierks)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: DOC
Target version: 2.0.0
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Posted by stomar (Marcus Stollsteimer) (Guest)
on 2012-12-22 11:51
(Received via mailing list)
Issue #6997 has been updated by stomar (Marcus Stollsteimer).

File rdoc_lib_optparse.patch added

I tried to make this clearer, see patch.
I also changed the example to avoid a warning for "shadowed outer local 
variable".

@zzak: Do you think that the "Further documentation" section is of any 
use in the current form (since changeset r36960)? I would suggest to 
remove it completely, since filing a ticket for usage questions seems 
not the right thing to do.
----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997#change-35007

Author: eike.rb (Eike Dierks)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: DOC
Target version: 2.0.0
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Posted by zzak (Zachary Scott) (Guest)
on 2012-12-22 17:39
(Received via mailing list)
Issue #6997 has been updated by zzak (Zachary Scott).


Thanks Marcus, I was holding off on this until I got around to some 
other patches I have in mind for OptionParser, but you beat me to it :)

Re: remove further documentation: I think we should keep it, it doesn't 
hurt to mention the tracker if anyone comes across any bugs it will 
probably be documentation related when reading the optparse docs.
----------------------------------------
Bug #6997: Improve documentation for OptionParser
https://bugs.ruby-lang.org/issues/6997#change-35013

Author: eike.rb (Eike Dierks)
Status: Closed
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: DOC
Target version: 2.0.0
ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10]


The documentation for OptionParser should be improved.

The current examples and and documentation do not yet describe
how to access non option args

I suggest to change the simple example in the doc as follows:

   opts.banner = "Usage: example.rb [options] file ..."

   p "files:" + ARGV


It should be stated explicitely in the description,
that parse! modifies the ARGV and removes all parseable args.

At least that is how I believe that the OptionParser.parse! works?
not yet tried it myself
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.