jeudi 11 janvier 2007

[Python] Generating an html doc for your script(s)

Pydoc
Python comes with a "pydoc" utility. On windows it is lacated in C:\Python2X\Lib (you may want to add this directory to your system path)

To produce an html documentation of a script or module type in a DOS shell (at the level of your script) :

pydoc.py -w nameOfYourScript

Warning:
- don't type the .py extension in the command above
- respect the uppercase and small caps even on windows.
- your script must have some docstrings

The above command produce a nameOfYourScript.html doc with the classes, methods, functions, etc.

Epydoc
For a more powerful and complete alternative I use the excellent Epydoc that you can download here:
http://epydoc.sourceforge.net/

On windows after the installation you can find the epydoc script in C:\Python2X\Scripts (you may want to add this directory to your system path)

To use epydoc just type in a shell in the folder containing your script(s):

epydoc.py scriptNameWithoutPyExtension

This will produce an "html" folder : read the index.html in your browser and enjoy :)

Aucun commentaire: