79

モジュールからドキュメントを作成しようとしています。pydocPython3.2.3を使用してWindows7のコマンドラインから使用しました。

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

これにより、シェルがテキストで埋められ、モジュール内のファイルごとに1行、次のようになりました。

no Python documentation found for '<file_name>'

Pydocがファイルのドキュメントを取得しようとしているようですが、自動作成したいと思います。Googleを使った良いチュートリアルが見つかりませんでした。Pydocの使い方に関するヒントはありますか?

を使用して1つのファイルからドキュメントを作成しようとすると

python ... -w myModule\myFile.py

それは言うwrote myFile.html、そして私がそれを開くとき、それは言う一行のテキストを持っている:

# ../myModule/myFile.py

また、コンピューター上のファイル自体へのリンクがあり、クリックすると、Webブラウザーでファイルの内容が表示されます。

4

3 に答える 3

106

Another thing that people may find useful...make sure to leave off ".py" from your module name. For example, if you are trying to generate documentation for 'original' in 'original.py':

yourcode_dir$ pydoc -w original.py
no Python documentation found for 'original.py'

yourcode_dir$ pydoc -w original
wrote original.html
于 2015-01-11T18:36:48.403 に答える
84

pydoc is fantastic for generating documentation, but the documentation has to be written in the first place. You must have docstrings in your source code as was mentioned by RocketDonkey in the comments:

"""
This example module shows various types of documentation available for use
with pydoc.  To generate HTML documentation for this module issue the
command:

    pydoc -w foo

"""

class Foo(object):
    """
    Foo encapsulates a name and an age.
    """
    def __init__(self, name, age):
        """
        Construct a new 'Foo' object.

        :param name: The name of foo
        :param age: The ageof foo
        :return: returns nothing
        """
        self.name = name
        self.age = age

def bar(baz):
    """
    Prints baz to the display.
    """
    print baz

if __name__ == '__main__':
    f = Foo('John Doe', 42)
    bar("hello world")

The first docstring provides instructions for creating the documentation with pydoc. There are examples of different types of docstrings so you can see how they look when generated with pydoc.

于 2012-10-24T13:17:18.833 に答える
38

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.

于 2012-10-24T06:04:38.770 に答える