[Tutor] pydoc introspecting info via OptionParser?

Neal McBurnett neal at bcn.boulder.co.us
Fri Mar 14 18:43:08 CET 2008


I'm trying to do nice clean documentation for a python script I run
from the command-line, and I'd like pydoc or a similar program to
document it well.  But I don't want to duplicate option information by
putting it both in my docstring and in optparse.

I would think that pydoc might notice an OptionParser instance at the
module level and show the options defined there, but it doesn't seem
to.  Would it be hard to add to pydoc?  Do any other documentation
programs do that?

I know that on aspn there is a library to parse a docstring and pass
options to optparse:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278844

But it has limitations (doesn't support all of optparse, won't work
with -OO) and is a bit uglier.

Cheers,

Neal McBurnett                 http://mcburnett.org/neal/


More information about the Tutor mailing list