A ready-to-build documentation environment for Sphinx
- Sphinx-Needs (8.x), with the
useblocks toolchain wired in: the
ubcvalidator, and both the HTML and ubTrace builders. It ships a dev container and a uv-managed environment so the whole thing builds the moment you open it.
Use it as a base: click “Use this template” on GitHub, or just clone this repository. Drop your
.rstfiles intosource/, build, and you're good to go.
| Piece | What it does |
|---|---|
| uv | Pins and installs the Sphinx toolchain (uv sync). Non-package project — there's nothing to build but the docs. |
| Dev container | Pulls a prebuilt image (Python 3.12 + uv + Graphviz/PlantUML/Java), fetches the ubc CLI on create, and preloads the right VS Code extensions. |
| Sphinx-Needs 8.x | Requirements/specs/tests as first-class, traceable objects. |
| Furo theme | Clean, responsive HTML output. |
| HTML builder | make html → browsable docs. |
| ubTrace builder | make ubtrace → structured output for ubTrace. |
ubproject.toml |
Single source of truth for need types, shared by ubc (lint) and the Sphinx build. |
| Diagrams | Graphviz, PlantUML, and Mermaid render during the build — toolchain preinstalled in the dev container. See source/diagrams.rst. |
Requires Docker and VS Code with the Dev Containers extension.
-
Open this folder in VS Code.
-
Reopen in Container when prompted (or run Dev Containers: Reopen in Container). The dev container pulls the prebuilt base image (
ghcr.io/patdhlk/sphinx-needs-starter), fetches theubcCLI, then runsuv syncautomatically — no local image build. -
Build the docs:
make html
Open
build/html/index.html.
For a live-reloading preview while you write:
make serve # http://localhost:8000Requires uv and Python 3.12.
uv sync # create .venv with the toolchain
./.devcontainer/install-ubc.sh # optional: install the ubc CLI on your host
make html # build the HTML docsDiagrams on a bare host: Graphviz and PlantUML render at build time, so install
graphviz(thedotbinary) andplantuml(needs Java) on your host. The dev container already includes both. Mermaid needs nothing extra.
- Put your
.rstfiles insource/. - Wire them into the
toctreeinsource/index.rst(one document name per line, without the.rstextension). - Rebuild:
make html.
Sphinx-Needs directives (.. req::, .. spec::, .. test::, .. needtable::,
…) work out of the box — see source/index.rst for a minimal example and the
Sphinx-Needs docs for the full set.
Three files hold the values you'll want to make your own:
source/conf.py— project name/author, and the threeubtrace_*settings (ubtrace_organization,ubtrace_project,ubtrace_version). Look for the← customizemarkers.ubproject.toml— your project name and your need types (req,spec,test, …). This file is read by bothubcand the Sphinx build, so the two never drift apart.- Versions to bump when you want to move forward:
sphinx-needsand the rest of the toolchain → editpyproject.toml, thenuv lock --upgrade && uv sync.- The
ubcCLI → theUBC_VERSIONarg in.devcontainer/devcontainer.json(and.devcontainer/Dockerfile).
| Command | Result |
|---|---|
make html |
Build HTML docs into build/html/ |
make ubtrace |
Build ubTrace output into build/ubtrace/ |
make serve |
Live preview with auto-rebuild on http://localhost:8000 |
make clean |
Remove build/ |
All targets run through uv run, so they use the pinned toolchain whether or
not the venv is activated.
The dev container ships the ubc CLI, which works against ubproject.toml.
Ready-made VS Code tasks are in .vscode/tasks.json (run them via
Terminal → Run Task…):
| Task | Command | License? |
|---|---|---|
ubc: build needs.json |
ubc build needs . --outpath build/needs.json |
not required |
ubc: validate needs.json |
ubc build validate-json build/needs.json |
not required |
ubc: index (report warnings) |
ubc build index --show-warnings |
not required |
ubc: check current file |
ubc check <file> |
required |
ubc: check project |
ubc check source |
required |
ubc: schema validate |
ubc schema validate |
required |
docs: build html / ubtrace / serve / clean |
make … |
— |
Licensing. The
buildcommands (needs export, indexing, JSON validation) run with no license.ubc checkandubc schema validaterequire a ubCode license — free for open source, but the project must be recognized as an open-source repo (public, OSI license) or you must configure a license key. See the ubCode docs. Runningubcin CI/CD needs a systems license; this template does not runubcin CI.
Note on diagrams:
ubproject.tomllists PlantUML'sumldirective underparse.ignore_directivessoubcdoesn't flag it as unknown (Sphinx renders it). Graphviz, Mermaid, and Sphinx-Needs directives are recognized natively.
The dev container pulls ghcr.io/patdhlk/sphinx-needs-starter, built from
.devcontainer/Dockerfile.
Automated (preferred). The
Publish base image GitHub Actions
workflow builds and pushes the multi-arch image whenever you publish a
GitHub Release. The release tag drives the image tags:
gh release create v0.1.1 --title v0.1.1 --notes "Bump toolchain"
# -> pushes ghcr.io/patdhlk/sphinx-needs-starter:0.1.1, :0.1, and :latestYou can also run it manually from the Actions tab (pushes :latest). It
uses the repo's GITHUB_TOKEN, so no PAT or login is required.
Manual fallback (local multi-arch build):
gh auth refresh -h github.com -s write:packages
gh auth token | docker login ghcr.io -u patdhlk --password-stdin
docker buildx build --platform linux/amd64,linux/arm64 \
-t ghcr.io/patdhlk/sphinx-needs-starter:latest \
--push .devcontainerThe image deliberately excludes ubc (useblocks' proprietary binary); the
container fetches it on create via .devcontainer/install-ubc.sh. Bump the
pinned tool versions in .devcontainer/Dockerfile (uv) and install-ubc.sh
(UBC_VERSION), then publish a new release.
MIT © 2026 Patrick Dahlke