opdoc
Opinionated, self-contained pdoc documentation sites. One command turns a
project's docs/ directory plus its README.md into a themed static site with prose pages, API
reference, client-side search, and no config file.
opdoc docs/ public
DOCS is required; OUT defaults to <project-root>/public. The project root is the parent of
DOCS, so opdoc docs/ works from a normal checkout.
What a project supplies
project/
├── README.md home page (rendered as guide.html)
├── docs/
│ ├── custom.css optional project CSS, appended after opdoc's base style
│ ├── source/**/PAGE.md prose pages; the page-dir tree is the "Pages" sidebar
│ └── scripts/*.py optional build-time page generators
└── <packages>/ auto-detected API roots
That is the whole contract. Theme, template, search, link rewriting, and the pdoc pin live in opdoc.
API pages
Without flags, opdoc documents every top-level package directory (a directory with __init__.py),
skipping docs/, test/, examples/, pkg/, build/, dist/, and public/. Each package's
re-exports are blanked in memory by default, so a class is documented once on its own module page.
For a src/ layout, namespace packages, or a subset of packages, pass --api-package and the
matching import roots:
opdoc docs/ public \
--api-package src/robolib \
--api-package src/robosim \
--import-path src \
--import-path .
--keep-reexports leaves __all__ alone when a package landing page should show its re-exports.
Scripts
Every non-underscore docs/scripts/*.py is imported before docs/source is scanned. It must
define:
def generate(site):
text, _missing = build_the_page()
site.write_page("reference/generated/PAGE.md", text) # text starts with the PAGE.md header
site.write_page(relative_path, text) writes a PAGE.md below docs/source; the normal scan
then renders it to HTML. site.root, site.docs, and site.out are absolute paths. Scripts run
in filename order. _-prefixed files are helpers and are not run.
Scripts can import project code: --import-path entries are already on sys.path and in
PYTHONPATH. The scripts directory is on sys.path too, so a script may import _helper from a
sibling _-prefixed file.
Pages menu
A page is a directory holding a PAGE.md. The file starts with a header, then free-form
markdown:
**Menu Title**: Getting started
**Menu Position**: 1
# Getting started
...
docs/source/
├── examples/
│ ├── PAGE.md header only (empty body) -> a label-only menu group
│ └── getting-started/
│ ├── PAGE.md a page, child of "examples"
│ └── images/run.png asset: 
└── architecture/
└── PAGE.md
- the header holds exactly
**Menu Title**(the sidebar label) and**Menu Position**; sibling pages are numbered 1..N (no holes, no repeats) and sort by it; - a subdirectory with its own
PAGE.mdis a child page, to any depth; the URL comes from the dir names (examples/getting-started->guide/examples/getting_started.html); - any other file or subdirectory is an asset of the page; linking to it (from any page or the README) copies it next to the page;
- an empty body makes a label-only group; a page with an empty body and no children is an error;
- a
.mdthat is not aPAGE.md, or aPAGE.mdbelow a plain (asset) dir, is an error; _-prefixed files/dirs are drafts; dir names that slugify to the same module are an error.
Links are plain relative paths, relative to the file holding them, the way GitLab's file view
and editors resolve them, so one link works on GitLab, locally, and in the site. opdoc rewrites a
link to a page (<dir>/PAGE.md or <dir>/) to the generated page and a link to README.md to
the home page, copies linked page assets and images, and sends other project paths to GitLab
blob/tree URLs. A link in a page whose target does not exist, or leaves the project, fails the
build (README links are not checked); the error names each link as file:line:col, where it
resolved to, and the closest page. Links inside code blocks and inline code are left alone. Set
--repo-slug owner/project and --repo-branch branch when the git remote does not describe the
published repo (for example, a vendored checkout).
Math
--math loads MathJax (from a CDN) on every page, so $...$ renders inline and $$...$$ as a
block. In the README and PAGE.md files a formula reaches MathJax exactly as written: opdoc
escapes it from markdown, so _, * and \\ mean what they mean in TeX. Break display lines inside
an environment, e.g. \begin{gathered} a \\ b \end{gathered} (MathJax 3 ignores a bare top-level
\\). It is off by default: it is a network fetch on each page view, and with it on, a $ pair in
plain prose turns into math. Code blocks and inline code are never touched.
Vendored sites
--vendored NAME adds vendored/NAME/index.html to the sidebar. It does not build that site;
an orchestrating project script builds each pkg/NAME/docs into OUT/vendored/NAME/ with the same
tool. This keeps every site self-contained and avoids module collisions between projects.
Install
pip install opdoc
opdoc pins the pdoc version it is tested against (pdoc==16.0.0) because it drives pdoc's render
API directly. Python 3.12+.
For development:
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
python -m pytest test/
python -m opdoc docs/ public
Tests
test/unit/exercises the pure helpers (slugging, PAGE.md headers, source scanning and layout errors, script loading, path guards).test/integration/builds a real fixture site with pdoc and checks the home page, API pages, generated script page, nested and label-only pages, rewritten links, page assets, and CSS.
Metadata
Release files for opdoc 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opdoc-0.2.2.tar.gz | 26.9 kB | Without provenance | Details for opdoc-0.2.2.tar.gz |
Release files / opdoc-0.2.2.tar.gz
| Download URL | opdoc-0.2.2.tar.gz |
|---|---|
| Size | 26.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f58c78f805bd4e6584f8618af99048a51dc5e445aa04344822f70a3c197ce4b
|
|
BLAKE2b-256 checksum How to use checksums |
c19aefe0e49565193251aa8b297ad2558be9d22a4e24636aac513a261303b274
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for opdoc 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.