如何使用Pydoc创建文档? [英] How do I create documentation with Pydoc?

查看:129
本文介绍了如何使用Pydoc创建文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的模块中创建一个文档。我使用Python 3.2.3在Windows 7的命令行中使用了 pydoc

  python< path_to_pydoc_> \pydoc.py-w myModule 

在我的shell中填充文本,在我的模块中的每个文件一行,说:

 没有为'< ; file_name>'

就像Pydoc试图获取我的文件的文档一样,但我想自动创建它。我找不到使用Google的好教程。有没有人有任何关于如何使用Pydoc的提示?



如果我尝试使用

  python ... -w myModule\myFile.py,它说写了myFile.html,当我打开它,它有一行文字说:

#../myModule/myFile.py

此外,它还有一个链接到文件本身在我的电脑上,我可以点击它显示在我的网页浏览器里面的文件。

解决方案

作为RocketDonkey建议,你的模块本身需要有一些docstrings。



例如,在 myModule / __ init __。py / p>

 
模块

您还想为 myModule / *。py 中的每个文件生成文档,使用

  pydoc myModule.thefilename 

,以确保生成的文件与refe匹配从主模块文档文件中退出。


I'm trying to create a document out of my module. I used pydoc from the command-line in Windows 7 using Python 3.2.3:

python "<path_to_pydoc_>\pydoc.py" -w myModule

This led to my shell being filled with text, one line for each file in my module, saying:

no Python documentation found for '<file_name>'

It's as if Pydoc's trying to get documentation for my files, but I want to autocreate it. I couldn't find a good tutorial using Google. Does anyone have any tips on how to use Pydoc?

If I try to create documentation from one file using

python ... -w myModule\myFile.py, it says "wrote myFile.html", and when I open it, it has one line of text saying:

# ../myModule/myFile.py

Also, it has a link to the file itself on my computer, which I can click and it shows what's inside the file on my web-browser.

解决方案

As RocketDonkey suggested, your module itself needs to have some docstrings.

For example, in myModule/__init__.py:

"""
The mod module
"""

You'd also want to generate documentation for each file in myModule/*.py using

pydoc myModule.thefilename

to make sure the generated files match the ones that are referenced from the main module documentation file.

这篇关于如何使用Pydoc创建文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆