javadoc equivalent?

Thomas A. Bryan tbryan at
Sat Feb 12 14:24:30 CET 2000

Michal Wallace wrote:
> Hey All,
> Is there a tool similar to javadoc in python? Something that would go
> through a .py file, read the doc strings (assuming they're in there),
> and then print the results in a nicely formatted HTML document?

Ask the DOC-SIG.  I think that they were looking into such a thing.

It wouldn't be too hard to write a basic thing in python...

Rough sketch

Import a module
elements = dir(modulename)
for each classOrMethod in elements:
   elementType = determineType(classOrMethod)  # for formatting purposes
       format(classOrMethod.__doc__, elementType)
   except AttributeError:
except AttributeError:

> Could such a beast read docstrings in .pyc's, or do they get compiled out?

That's easy to test...

$ cat > 
class Foo:
    """This class exists simply to test whether
    docstrings are preserved in .pyc files."""

$ python -c 'import somedocs'
$ ls  somedocs.pyc
$ rm
$ ls
$ python -c 'import somedocs; print somedocs.Foo.__doc__'
This class exists simply to test whether
    docstrings are preserved in .pyc files.

I've been working on a general-purpose documenatation tool that 
could be used for formatting Python documentation, but it's 
currently stalled.  I'll post again when it's usable.


More information about the Python-list mailing list