Pydoc module in Python can be used to generate documentation in the form of html pages or even on the console
python -m pydoc
This command gives options like view the pydoc for a file, -k search for different libraries, -p allows to open a page in web browser to view python packages, -g provides a graphical interface for looking documentation, -w writes an html output. Below are the sample commands that you can fire for testing.
python -m pydoc yourpythonfile
python -m pydoc -k ftplib
python -m pydoc -p 314
python -m pydoc -w file
I have created two sample files in a directory file1.py and file2.py which has a simple code with a single line of comment.
def f2m(ft):
""" Return the number of meters eq to feet """
return 0.30 * ft
One way to see the comment of the files is to simply write below in the same file and you can run python file.py and it would show the comments.
help(f2m)
Other way to see this is to write the command
python -m pydoc file1
One more way to see the comments in an html page by typing this command and exporting it to html
python -m pydoc -w <dir>
If you have multiple python files and if you want to generate HTML into separate folder then simple shell commands can do the job. Below code generates a folder 'htmldocs' and then generates html and moves them to this new folder. If you open any one at the right hand top corner you can see index option through which you can navigate through other pages.
mkdir -p htmldocs
pydoc -w `find . -name '*.py'`
mv *.html htmldocs