September 28, 2021    Share on: Twitter | Facebook | HackerNews | Reddit

Python project documentation from the code with pdoc3

Sphinx seems to be most common tool for generating documentation. If

Python documentation with pdoc3

Generate html documentation:

pdoc --force --html --output-dir ./doc_myproject myproject

where --force will overwrite any existing generated (--output-dir) files.

Generate html documentation and open in browser:

pdoc --force --html --output-dir ./doc_myproject myproject && xdg-open ./doc_myproject/myproject/index.html

I used to add these two documentation-related targets to the project’s Makefile:

## Generate pdoc HTML documentation for prolog package
doc:
    pdoc --force --html --output-dir ./doc_myproject myproject

## Generate pdoc HTML documentation for prolog package and open in browser
doc_view:
    pdoc --force --html --output-dir ./doc_myproject myproject && xdg-open ./doc_myproject/myproject/index.html