Extracting documentation for user relevant functions only?

Micah Elliott mde at micah.elliott.name
Mon Nov 28 12:01:41 EST 2005


On Nov 28, Anton81 wrote:
> I've written a python script and added short docstrings. Now I'd
> like to create a short overview of commands the user can use.
> However I don't want the internal stuff that I also commented. Is
> there a way to create a fancy documentation (e.g. pydoc) of certain
> functions only?

You can use the leading underscores convention
<URL:http://docs.python.org/ref/id-classes.html> to "hide" the
intended invisible names.  pydoc and epydoc both honor this...

    $ cat foo.py
    """Foo test mod.
    """

    def spam():
        "Like ham."
        pass

    def _secret():
        "Can't see this docstring."
        pass

    class Mustard(object):
        __name1 = 1
        _name2  = 2
        name3   = 3


    $ pydoc foo
    Help on module foo:

    NAME
        foo - Foo test mod.

    CLASSES
        ...
        class Mustard(__builtin__.object)
         ...
         |  name3 = 3

    FUNCTIONS
        spam()
            Like ham.


-- 
_ _     ___
|V|icah |- lliott             <><             mde at micah.elliott.name
" "     """



More information about the Python-list mailing list