Documenting a package with Pydoc
Gabriel Genellina
gagsl-py at yahoo.com.ar
Sat Aug 19 07:58:56 EDT 2006
At Friday 18/8/2006 11:45, Rob Cowie wrote:
>Pydoc seems to be capable of writing documentation for all modules
>within a package by simply pointing it to the package on the command
>line...
>
>pydoc -w <packagename_without_/>
>
>Certainly, the method writedocs() appears to descend into a directory
>and create docs for each importable object.
>
>Perhaps I'm doing something wrong but when I do this, pydoc reports
>that no Python documentation can be found for each of the contents of
>the package. Of course, if I point pydoc directly to the modules, it
>succeeds.
>
>Am I doing something wrong?
That appears to be a bug. In pydoc.writedocs, when iterating over the
package directory contents, it uses inspect.getmodulename(path). That
returns the bare filename (without path nor extension) (is it ok???),
and later the resolve() function can't load the module because it
lacks package information.
For simple cases this patch may work: In writedocs, add the following
line at the beginning:
if pkgpath=='' and ispackage(dir): pkgpath = os.path.basename(dir) + '.'
This works for top level packages located at sys.path, but not for
packages located elsewhere.
By example, I can generate now the docs for pychart:
python c:\apps\python\lib\pydoc.py -w c:\apps\python\lib\site-packages\pychart
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list