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/**/*.md           prose pages; the directory 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("3. Reference/generated.md", text)

site.write_page(relative_path, text) writes a markdown page 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

docs/source/ is the sidebar:

  • every *.md is a page; the title is its first # heading (fallback: file name);
  • a directory is a collapsible group; index.md makes the group itself a page;
  • a leading number sorts first and numerically (1. Examples, 2. Architecture);
  • _-prefixed files/dirs are drafts; a top-level README.md is ignored (the repo README is home);
  • names that slugify to the same module are an error.

Links in README.md and pages stay repo-relative. opdoc rewrites *.md links to the generated pages, copies referenced images, and sends other repo paths to GitLab blob/tree URLs. 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, ordering, source scanning, script loading, path guards).
  • test/integration/ builds a real fixture site with pdoc and checks the home page, API pages, generated script page, sidebar, rewritten links, assets, and CSS.

Metadata

Release files for opdoc 0.1.0

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.1.0
File Size Uploaded Provenance
opdoc-0.1.0.tar.gz 23.0 kB Without provenance Details

Release files / opdoc-0.1.0.tar.gz

Download URL opdoc-0.1.0.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3916fe8a9206c27d0d23232c6a1c848ee2e5688233166bd952ef3f1a85255472
BLAKE2b-256 checksum
How to use checksums
b74bf015c79bcce45c06ddf2f505a9869353d207f444624b507227cf0bb14c0c
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.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

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