6

At the moment, to read the documentation of a package, quickly for examle, I do this:

>>> import quickly
>>> help(quickly)
 
>>> import quickly.widgets
>>> help(quickly.widgets)
 
>>> import quickly.widgets.text_editor
>>> help(quickly.widgets.text_editor)
 

and so on...

This is obviously very tedious. How can I export all of the quickly documentation, including all sub-packages, then get it to show up in the devhelp documentation browser?

Exporting the documentation as HTML would be nice too. I would even be happy if some version of it existed on the web, but I can't seem to find one.

Note: By package I mean a alt text python-package, not a .deb package.

1
  • I think Devhelp uses some kind of structured HTML or something.
    – RolandiXor
    Dec 8 '10 at 20:58
6

You can create HTML documentation of a python module using epydoc Install epydoc.

Epydoc is a tool for generating API documentation for Python modules, based on their docstrings.

Here is how to use epydoc to create HTML documentation for the module quickly.widgets:

epydoc --html quickly.widgets -o quickly_widgets_doc

Once this finishes, open up quickly_widgets_doc/index.html in your web browser:

alt text

Or, if you would prefer this documentation in a PDF:

epydoc --pdf quickly.widgets --name "quickly.widgets" -o quickly_widgets_doc_pdf

This creates the file quickly_widgets_doc_pdf/api.pdf

alt text

More information on using epydoc here.

I haven't found a way to convert these to a format DevHelp can use, if I do I'll edit this answer.

4

I little known "secret" is the pydoc tool that is included with every Python installation (so no need to install extra packages).

Start a webserver that generates instant documentation from the source (using the same techniques as help() in the Python console) that listens on http://localhost:8000/ with:

pydoc -p 8000

Launch the webserver and a Tkinter-based GUI that provides search options etc.:

pydoc -g

Write the documentation for quickly.widgets to a HTML file quickly.widgets.html in the current directory:

pydoc -w quickly.widgets
3
  • Brilliant! Although I only got this to work right after running sudo ln -s /usr/bin/python /usr/local/bin/python - just in case anybody has a similar problem. Dec 9 '10 at 22:52
  • That sounds like you have installed python or python modules outside the default Ubuntu packages?
    – JanC
    Dec 10 '10 at 0:13
  • 1
    BTW: the Ubuntu packages also provide pydoc2.6, pydoc2.5, etc., which I assume will show documentation for the respective Python versions...
    – JanC
    Dec 10 '10 at 0:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.