Skip to main content

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: ![run](images/run.png)
└── 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.md is 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 .md that is not a PAGE.md, or a PAGE.md below 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).

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opdoc 0.2.1
File Size Uploaded Provenance Actions
opdoc-0.2.1.tar.gz 25.7 kB Without provenance Details for opdoc-0.2.1.tar.gz

Release files / opdoc-0.2.1.tar.gz

Download URL opdoc-0.2.1.tar.gz
Size 25.7 kB
Tags Source
SHA-256 checksum
How to use checksums
053e4f0ae3dfd1f2fbdc49f5ccff8542b6417b5dee36c49cf9890895a3ca1db0
BLAKE2b-256 checksum
How to use checksums
8197fd96b7a5e5feccd007d61e14f402bf43f206b253ff99d50093ac7165e013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for opdoc 0.2.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page