How do I recursively generate documentation of an entire project with pydoc?

Viewed 548

I have a python project inside a specific folder named "Project 1". I want to extract all the docstrings of all the python files inside this project.

In this project all the modules are imported dynamically through __init__.py and, for that reason, when I run pydoc it fails on the imports.

1 Answers

python -m pydoc -w module_folder/ will work for some scenarios, but not all. For example, if you want to document modules and submodules of an installed package, it won't work, you'd need to pivot to a different tool.

Using your favorite language you will need to:

  1. Iterate through files in your target folder
  2. Call pydoc once per (sub)module

Here is one of many examples on Github.

Pdoc, pydoctor both handle walking folders automatically, my fork of pydoc walks the module dependency tree by default.

Related