Fork of cpython's pydoc module to do just html document generation
Project description
pydoc_fork
A fork of pydoc to optimize it for generating, on a build server, html documentation for a python library you wrote.
Less ambitious than the very good pdoc3 and easier to use than Sphinx. Not as pretty as either. But it works, it's small, and the output looks like the pydoc you remember from 2003 (now with themes).
Installation
Requires Python 3.10+
pip install pydoc_fork
# or virtual environment access
pipenv install pydoc_fork
# WARNING- installation by pipx will only allow for doc generation of the python standard library!
pipx install pydoc_fork
Usage
# Generate HTML for all modules and submodules from source code
pydoc_fork my_module --output docs --document_internals
# Generate HTML for a module that is importable, e.g. sys
pydoc_fork sys --output docs
# Pick a theme and label the project
pydoc_fork my_module --output docs --theme dark --project_name "My Cool Lib"
# Link to docs.python.org for stdlib references instead of regenerating them
pydoc_fork my_module --output docs --prefer_docs_python_org
# Skip the index.html (e.g. you have your own landing page)
pydoc_fork my_module --output docs --no_index
# Use a pyproject.toml for configuration (see "Config" below)
pydoc_fork my_module --output docs --config .
# Launch the (extremely minimal) Tk GUI
pydoc gui
Run pydoc_fork --help for the full list of flags.
Config via pyproject.toml
Anything you can pass on the command line you can also stash under
[tool.pydoc_fork] in a pyproject.toml and point at it with --config <dir>:
[tool.pydoc_fork]
PROJECT_NAME = "My Cool Lib"
THEME = "dark"
DOCUMENT_INTERNALS = true
PREFER_DOCS_PYTHON_ORG = true
GENERATE_INDEX = true
SKIP_MODULES = ["typing"]
# CUSTOM_TEMPLATES = "./my_templates" # optional, see below
Themes
Three themes ship in the box. They are CSS variables on a :root block, so if
you want to tweak one, fork pydoc_fork/reporter/themes.py — it's a single dict.
| Theme | Vibe |
|---|---|
classic |
The original pydoc look: lavender, pink, purple. |
light |
A calmer modern light theme. |
dark |
A modern dark theme for people who code at night. |
pydoc_fork my_module --output docs --theme light
Templating
Output is rendered through Jinja2 templates
that live in pydoc_fork/templates/:
class.jinja2 function.jinja2 module.jinja2
data.jinja2 heading.jinja2 multicolumn.jinja2
disabled_text.jinja2 index.jinja2 page.jinja2
fallback.jinja2 section.jinja2
If you want to change the layout, copy that folder somewhere, edit, and point
CUSTOM_TEMPLATES at it in your pyproject.toml. (The plumbing for swapping
the Jinja loader is in pydoc_fork/reporter/jinja_code.py — keep it minimal.)
Publishing to GitHub Pages
A compact workflow that generates docs into ./site on every push to main
and publishes them. Drop it at .github/workflows/docs.yml:
name: docs
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: { python-version: "3.12" }
- run: pip install . pydoc_fork
- run: pydoc_fork my_module --output site --theme light --project_name "My Cool Lib"
- uses: actions/upload-pages-artifact@v3
with: { path: site }
- id: deploy
uses: actions/deploy-pages@v4
One-time setup: in your repo, Settings → Pages → Build and deployment → Source: GitHub Actions. After the first successful run the URL will appear at the top of the Pages settings panel and in the workflow summary.
Docs
pydoc_fork documented in several ways
Because the best way to evaluate a doc generator is to see it run on the same codebase as its peers:
Prior art and alternatives
pydoc_fork exists because none of these were quite the right shape for "generate API HTML on a build server and forget about it." They are all, however, excellent at what they do — try them first.
- pydoc — the stdlib
original. The direct ancestor of this fork. Great for
pydoc -p 0at a REPL; awkward for "render all of my package to a folder of HTML in CI." - pdoc3 / pdoc — the closest peers. Nicer output, more features, more configuration surface. If you want the output to look modern out of the box, start here.
- Sphinx — the heavyweight. Unmatched for
narrative documentation, cross-references, and multi-format output. Has a
learning curve, a
conf.py, anindex.rst, themes, extensions, and opinions. Worth it for large projects. - MkDocs + mkdocstrings —
Markdown-first sites with API docs injected via
::: module.name. Lovely output (especially with the Material theme), but it is a site generator first and an API extractor second. - pdocs / portray — Timothy Crosley's duo. Portray is "MkDocs + pdocs + zero config" — very nice if your project fits the mold.
- PyDoctor — the original API doc tool for Twisted. Strict about docstring formatting, produces dense reference output.
- Pycco — literate-style side-by-side source/docs. Different goal, but worth knowing about.
- Doxygen — yes, it does Python. No, you probably don't want it for Python.
- Read the Docs — not a generator but a hosting platform; pairs with Sphinx or MkDocs. The "obvious" alternative to the GitHub Pages workflow above.
If you are starting a new project and want something modern with a thriving community, pick pdoc or mkdocstrings. If you want output that screams "this is the API and nothing else, rendered the way pydoc has always rendered it" and you want to call it from a one-line shell script in CI, this fork is for you.
Credits
Forked from pydoc in python 3.10.
That code is governed by the cpython license
I picked a MIT license, but I'm no lawyer, the cpython license probably governs in any conflict.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydoc_fork-3.4.0.tar.gz.
File metadata
- Download URL: pydoc_fork-3.4.0.tar.gz
- Upload date:
- Size: 85.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9fd3035d66ac81aff1d3bb51febebb49ca821ea1b582b1bc4bf34b487731287
|
|
| MD5 |
3d62ff6a394f18a7b018936ca8c126ea
|
|
| BLAKE2b-256 |
cd1c20ba0e3ddb78f873f1cc60553e8a500f29d4cef891526e6e4c1cc60caf23
|
Provenance
The following attestation bundles were made for pydoc_fork-3.4.0.tar.gz:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/pydoc_fork
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydoc_fork-3.4.0.tar.gz -
Subject digest:
b9fd3035d66ac81aff1d3bb51febebb49ca821ea1b582b1bc4bf34b487731287 - Sigstore transparency entry: 1625108985
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/pydoc_fork@11fdc362b1b1784bc29e1d2296b56dbe6af03834 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@11fdc362b1b1784bc29e1d2296b56dbe6af03834 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pydoc_fork-3.4.0-py3-none-any.whl.
File metadata
- Download URL: pydoc_fork-3.4.0-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aebd96098a50b35c90c7d4cb626f33f79eac92533ca18d55c2a82abfa3e6d0af
|
|
| MD5 |
8239c04ed3ad0edbc5c7e31751f81ede
|
|
| BLAKE2b-256 |
22f2304f144279d858eb2576095b14529c50a912da806932bb1956e1c014c5eb
|
Provenance
The following attestation bundles were made for pydoc_fork-3.4.0-py3-none-any.whl:
Publisher:
publish_to_pypi.yml on matthewdeanmartin/pydoc_fork
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydoc_fork-3.4.0-py3-none-any.whl -
Subject digest:
aebd96098a50b35c90c7d4cb626f33f79eac92533ca18d55c2a82abfa3e6d0af - Sigstore transparency entry: 1625109032
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/pydoc_fork@11fdc362b1b1784bc29e1d2296b56dbe6af03834 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_to_pypi.yml@11fdc362b1b1784bc29e1d2296b56dbe6af03834 -
Trigger Event:
workflow_dispatch
-
Statement type: