简体   繁体   中英

Pydoc not seeing docstrings?

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.

Pydoc wants a module name, not a file name. Try pydoc test .

It will use the argument as a file name if it has a slash in it: pydoc ./test.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM