Generate Fern API documentation from Python packages using static analysis.
Simplified fork of sphinx-autodoc2 focused purely on Python → Fern markdown output.
pipx install py2fernTo upgrade to the latest version:
pipx upgrade py2fernOr if installed with pip:
pip install --upgrade py2fernCheck your current version:
py2fern --versionGenerate Fern markdown documentation:
py2fern write /path/to/your/packageSpecify output directory:
py2fern write /path/to/your/package --output ./docs/apiShow warnings for functions missing return type annotations:
py2fern write /path/to/your/package --output ./docs/api --debugWarnings appear in yellow and help identify functions that should have type annotations added.
Use the old regex-based parser instead of the default docstring_parser:
USE_REGEX_PARSER=1 py2fern write /path/to/your/package --output ./docs/apiThis creates:
- MDX files with Fern-compatible frontmatter and slugs
navigation.ymlfor Fern docs structure- Consistent ParamFields for all Parameters and Returns sections
This project is a fork of the excellent sphinx-autodoc2 by Chris Sewell. All credit for the core functionality goes to the original project.
All configuration is mainly in pyproject.toml.
Use tox to run the tests.
pipx install tox
tox -avUse pre-commit to run the linters and formatters.
pipx install pre-commit
pre-commit run --all-files
# pre-commit installflit is used to build the package.
pipx install flit
flit build