473,387 Members | 1,624 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,387 software developers and data experts.

Documenting a package with Pydoc

I have searched this group and the wider net to find an answer to this,
but I haven't been successful.

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?

Cheers, Rob C

Aug 18 '06 #1
3 7409
Anyone?

Aug 19 '06 #2
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

Aug 19 '06 #3

Gabriel Genellina wrote:
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.
I don't think this is a bug; inspect.getmodulename(path) does indeed
return a bare filename, but this is later augmented with the pkgpath.

I also can't find a resolve() function. Perhaps we have different
versions? I have revision 1.38.
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

Thanks,

Rob C
>
__________________________________________________
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
Aug 19 '06 #4

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

Similar topics

2
by: Greg Kuperberg | last post by:
I plan to use pydoc for my Python project. After looking through the standard documentation, I am not sure how pydoc interprets its input. In its basic operation it evidently looks at the first...
2
by: Rony | last post by:
A question on python source documentation. Does there exist a standard for documenting code ? I've included here an example generated by pydoc of one of my modules. Is this the right way or is it...
0
by: Tony C | last post by:
According to the help for pydoc, it can be run as a script, from the command line. "Or, at the shell command line outside of Python: Run "pydoc <name>" to show documentation on something" ...
1
by: M.E.Farmer | last post by:
Hello again!, I just wanted to start off saying I love this newsgroup! Everytime I have an idea someone seems to post on it, or about it. The word for today is **Synchronicity** ! The reason for...
1
by: Frans Englich | last post by:
Hello, I have a custom module which among others contains a dictionary, acting as a "constant". I want to document it, but no matter what I do, it doesn't show up in `pydoc`. For example, the...
7
by: Brian van den Broek | last post by:
Hi all, I'm posting partly so my problem and solution might be more easily found by google, and partly out of mere curiosity. I've just spent a frustrating bit of time figuring out why pydoc...
9
by: newsposter | last post by:
>>> import pydoc >>> import sys >>> sys.version '2.4.2 (#67, Sep 28 2005, 12:41:11) ' >>> pydoc sys SyntaxError: invalid syntax >>> The documentation for pydoc says: "Run "pydoc <name>" to...
1
by: timw.google | last post by:
Hi all, I'm discovering pydoc, and it seems to me that this is a great way to have online documentation for my application. Are there any examples of using this in some kind of help menu in an...
5
by: Wijaya Edward | last post by:
I tried to call pydoc from my Linux box. To my realization that it doesn't contain pydoc. I thought this module should be a default module. Can anybody suggest where can I find the module? I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.