Skip to content

chore: generate readme from jinja2 template - #133

Merged
smarlhens merged 2 commits into
mainfrom
chore/readme-template
Nov 1, 2026
Merged

smarlhens merged 2 commits into
mainfrom
chore/readme-template

Conversation

@smarlhens

Copy link
Copy Markdown
Owner

Summary

# Commit What
1 1c19f66 Generate README.md from templates/README.md.j2 with scripts/regen_readme.py (Jinja2), same approach as the Tera templates in riri-node-tools
2 3731eda uv sync --no-dev for the production venv, dev dependencies only in the development stage

README generation

Values come from the files that pin them, outputs from real runs:

README value Source
Python constraint / tested with requires-python / .python-version
pre-commit constraint / tested with dev group spec / uv.lock (pre-commit is now a locked dev dependency)
uv constraint / tested with [tool.uv] required-version / Dockerfile ghcr.io/astral-sh/uv tag
pytest & coverage output blocks pytest tests --cov=src (one run feeds both blocks)
Docker run output python -m python_boilerplate.main
  • Output is compacted to the shape the README always had (collected line, test results without [100%] padding, one coverage header line, table). The coverage header is redrawn at width 80 with the platform pinned to linux, so the README doesn't depend on the machine or terminal.
  • --check prints a diff and fails with README.md is out of date: edit templates/README.md.j2, then run uv run scripts/regen_readme.py. A failing test surfaces pytest's own output.
  • README diff vs main: Python line now shows requires-python as written (>=3.15, the old <3.16.0 upper bound wasn't declared anywhere), coverage header in the pytest-cov 7 format, ruff commands include scripts.

Wiring

  • pre-commit: pytest & readme drift local hook (--check mode, never rewrites the README, so manual edits aren't lost) replaces the pytest hook; triggered by the template, script, pyproject, uv.lock, .python-version, Dockerfile, src/, tests/.
  • mypy moved from mirrors-mypy to a local uv run mypy hook: mirrors-mypy's isolated env lacks jinja2 and needed a duplicate jinja2==3.1.6 pin; the local hook uses uv.lock versions, same as CI. Added to ci.skip with the other uv-based hooks.
  • oxfmt excludes the generated README.md.
  • CI: Test with pytest tees its output, Check README drift reuses it via --pytest-output (suite runs once); ruff lint/format now cover scripts.
  • scripts/ added to ruff src, mypy files, ty include (INP001 ignored there).

Notes

  • Renovate PRs that bump the Dockerfile uv tag, .python-version or pre-commit will fail the drift check; regenerate by hand with uv run scripts/regen_readme.py.
  • Docker image build not verified locally (registry/DNS blocked on my machine); relying on the build-image job.

Test plan

  • pre-commit run --all-files
  • uv run scripts/regen_readme.py --check clean; drift detected after a manual README edit, a Dockerfile uv bump and a failing test
  • CI green

Comment thread scripts/regen_readme.py Fixed
@smarlhens
smarlhens force-pushed the chore/readme-template branch from 3731eda to d8e3ec0 Compare November 1, 2026 18:18
@smarlhens
smarlhens merged commit 04b900b into main Nov 1, 2026
8 checks passed
@smarlhens
smarlhens deleted the chore/readme-template branch November 1, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants