473,395 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Documentation

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?
--
Kind Regards,
Jan Danielsson
Te audire no possum. Musa sapientum fixa est in aure.
Aug 10 '05 #1
2 1259
The standard pydoc module is very useful. A simple example of how you
could use it:
import pydoc
mymodule = pydoc.importfile(r"C:\My Py\my_foo.py")
html = pydoc.html.page(pydoc.describe(mymodule), pydoc.html.document(mymodule))
open("foo.html", "w").write(html)


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.

Aug 10 '05 #2
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

Aug 10 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Daniel R. Smorey Jr. | last post by:
I'm looking for a good place for Python documentation. I'm really lost on why it's so hard to find anything when it comes to me looking up a particular function in Python. My example would be the...
11
by: Steve | last post by:
posted on: comp.lang.python emailed to: docs@python.org I have a suggestion/request that will, I think, improve the Python documentation. Currently, the Python documentation in HTML format is...
24
by: Christopher J. Bottaro | last post by:
This post is just the culmination of my thoughts and discussions with my coworkers on Python. If you are not interested, please skip over it. At my work, we are developing a product from...
0
by: Jeff Levinson [mcsd] | last post by:
I'm an architect for a very large fortune 100 company and we still struggle with the best balance. However, I use a couple of simple guidelines that have worked very well for me in almost all...
0
by: Almoni | last post by:
Hi, I have a few .xsd files that include each other in the following way: <!-- lets call the main schema file AA.xsd and it includes BB.xsd inside it --> <xs:schema...
1
by: Ole Hanson | last post by:
I would like to be able to generate documentation for a custom configuration file (xml) to enable future support engineers to understand applicable values to the various elements inside the...
97
by: Cameron Laird | last post by:
QOTW: "Python makes it easy to implement algorithms." - casevh "Most of the discussion of immutables here seems to be caused by newcomers wanting to copy an idiom from another language which...
0
by: innovasys | last post by:
TORQUAY, DEVON, UK - Innovasys announced the release of Document! X 5, the fifth version of the documentation solution of choice for developers using Microsoft Visual Studio or the .NET Framework....
34
by: nicolasfr | last post by:
Hi, I am a bit disapointed with the current Python online documentation. I have read many messages of people complaining about the documentation, it's lack of examples and the use of complicated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.