Equivalent of perl's Pod::Usage?

Nick Craig-Wood nick at craig-wood.com
Mon Dec 10 12:30:03 EST 2007


Adam Funk <a24061 at ducksburg.com> wrote:
>  Sorry about that!  POD is a mark-up language that Perl's Pod::Usage
>  module can translate into man pages (and other documentation formats).
> 
>  So what I'm really after is an easy way to generate something that
>  looks like a man page.

You might want to investigate reST

  http://docutils.sourceforge.net/rst.html

That said, python does a good job of turning doc strings and class
descriptions into man pages even without any special markup, if you
wrote docstrings everywhere.  Try pydoc on any bit of python (without
the .py) and you'll see what I mean

As for Pod::Usage - write the instructions for your script as a
docstring at the top of your file, then use this little function...

def usage(error):
    """
    Print the usage, an error message, then exit with an error
    """
    print >>sys.stderr, globals()['__doc__']
    print >>sys.stderr, error
    sys.exit(1)

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list