Re: automatically generating a help file

[email protected] Thu, 3 Jul 2008 14:05:30 -0500
Newsgroups gmane.comp.python.optik.user
Message-ID <OF1CD8985B.EDAD2793-ON8625747B.00684DC7-8625747B.0068DF99@uscmail.uscourts.gov>
[email protected] wrote on 07/03/2008 01:41:23 PM:

> Hi all,
>    I am trying to write a function that will use an OptionParser
> object to generate a help file. Ultimately, I will have it generate
> an HTML file  so the help doc for my program can be viewed from the
> web. The problem I'm having is that I can't figure out how to have
> OptionParser return a list of the names of the options I have
> defined and the corresponding help information. Does anyone have a
> suggestion on how I could do this?
>

if you load up something like ipython and dig into your parser you can pull
out the options.

if p is your parser, you can look at the items in p.option_list, they will
have ._long_opts, ._short_opts, .dest, and .help attributes (as well as a
handful of others).

But if you already have your parser generated the quickest way is to
directly call the p.format_help() method, which would be the same as
calling the help switch for the application at the cli.


-greg


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08