Go to your folder and try:
pydoc -w pydoc_learning
It should generate an .html file
Answer from BoilingFire on Stack OverflowGo to your folder and try:
pydoc -w pydoc_learning
It should generate an .html file
Your first shot should be pydoc --help which is a fairly standard modern way to get help from a command line tool. You can try this with any other commands you have to learn about. When you come to write your own command line tools you would do well to consider adding such an option to your own tools.
Even when a tool does not explicitly support help with either --help or -h (such as pydoc), they sometimes help with option hints when given unsupported input. This is the case with pydoc.
On a unixy system you can also try man (short for manual as in manual page).
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
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.