Last Modified
2013-04-17 00:31:49 -0700
Requires
  • rdoc/markup/simple_markup
  • rdoc/markup/simple_markup/to_flow
  • rdoc/ri/ri_formatter
  • rdoc/ri/ri_options

Description

Synopsis

This library allows command-line tools to encapsulate their usage as a comment at the top of the main file. Calling RDoc::usage then displays some or all of that comment, and optionally exits the program with an exit status. We always look for the comment in the main program file, so it is safe to call this method from anywhere in the executing program.

Usage

RDoc::usage( [ exit_status ], [ section, ...])
RDoc::usage_no_exit( [ section, ...])

where:

exit_status

the integer exit code (default zero). RDoc::usage will exit the calling program with this status.

section

an optional list of section names. If specified, only the sections with the given names as headings will be output. For example, this section is named ‘Usage’, and the next section is named ‘Examples’. The section names are case insensitive.

Examples

# Comment block describing usage
# with (optional) section headings
# . . .

require 'rdoc/usage'

# Display all usage and exit with a status of 0

RDoc::usage

# Display all usage and exit with a status of 99

RDoc::usage(99)

# Display usage in the 'Summary' section only, then
# exit with a status of 99

RDoc::usage(99, 'Summary')

# Display information in the Author and Copyright
# sections, then exit 0.

RDoc::usage('Author', 'Copyright')

# Display information in the Author and Copyright
# sections, but don't exit

RDoc::usage_no_exit('Author', 'Copyright')

Author

Dave Thomas, The Pragmatic Programmers, LLC

Copyright

Copyright © 2004 Dave Thomas. Licensed under the same terms as Ruby

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus