Documentation

J

Jan Danielsson

Hello all,

What is the proper way to document a class in Python? I have written
a few python libraries that I would like to document.

I'm doing a lot of this:

class Foo(object):
"""
This is a class which blah, blah, blah... It's features are blah,
blah, blah...
"""

def addStuff(self):
"""
This method does blah, blah, blah...
"""

I'm going to assume that Python has some "official" tool which can be
used to automatically create documentation for a .py-file (like Java
does), but what do I need to do to support it, and how does it work?
 
J

Jason Drew

The standard pydoc module is very useful. A simple example of how you
could use it:

Then you have a nice foo.html document for your module.

The above isn't necessarily the best way to use pydoc though it's
useful for a single-file bunch of classes. The documentation on pydoc
seems pretty sketchy, but reading the pydoc.py file is a good way to
learn how to use it.
 
P

Paul McGuire

Get epydoc from SourceForge (http://epydoc.sourceforge.net/). It will
auto-generate beautiful HTML doc pages for your Python classes, using
the information you have inserted as the doc strings for your classes
and methods. I use it to generate the pyparsing documentation, and it
works very well for me (and I only use about 20% of epydoc's
capabilities).

-- Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top