11

Obviously I am missing something serious here. Here is my test program:

"""
Doc and nothing but doc
"""

class TestMe(object):
    """
    class documentation goes here
    """
    def testFunc(self):
        """
        FunctionDoc Goes here
        """
        print "Hello world"

if __name__ =="__main__":
    t=TestMe()
    t.testFunc()

I run it and it prints "Hello world", natch. But pydoc.py test.py gives this:

no Python documentation found for 'test.py'

Obviously I am missing something simple here, but what?

--edit-- Per Vishnu's suggestion I added "print t.__doc__" to the last line of the file and now running the file gives this:

Hello world

    class documentation goes here

But pydoc still does not find any documentation.

4

1 回答 1

32

Pydoc 需要一个模块名,而不是文件名。试试pydoc test

如果参数中有斜杠,它将使用参数作为文件名: pydoc ./test.py

于 2014-11-26T13:41:32.073 回答