Repository navigation
docs: move the docs to MkDocs on Read the Docs - #233
Conversation
Move `documentation/` (Sphinx) to `docs/` with MkDocs Material, as in cloud-registry: `mkdocs.yml`, `.readthedocs.yaml` (docs dependencies from the lock, strict build), redirects from the old Sphinx pages, and a strict build in the new `docs` job of CI. The docs of tesk-api and tesk-core stay in their repositories and are pulled into the site at build time, at the commits pinned in `docs-sources.yml`, by hooks in `docs/hooks.py`, as the sections "tesk-api" and "tesk-core" (placeholders until they have docs). The hooks are tested (`tests/`, 100% coverage, reported to Codecov by the new `test` job) and checked with ruff and mypy. Add a home page and a development page, which documents the checks, the docs build and the pull mechanism; fix links that left the docs folder; point the README to the new location. Closes #224 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read `docs-sources.yml` next to `mkdocs.yml`; remove the temporary directories of pulled docs on failure and on shutdown; limit the size and number of files of pulled tarballs; test a build with pulled docs end to end instead of building the site in the tests; rename the list of the current build's docs; rewrap the CI header. Refs #224 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Count only the extracted docs files against MAX_MEMBERS and add MAX_EXTRACTED_BYTES for their total size, so that a small tarball cannot expand to gigabytes and large repositories with small docs do not fail. Test cleanup after a pull without docs/ and shutdown of unused pulls; document the limits by name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The relative link from #220 points outside docs/ and fails the strict build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR replaces the Sphinx documentation pipeline with a reproducible MkDocs Material site on Read the Docs, adds secure commit-pinned ingestion of tesk-api and tesk-core documentation through MkDocs hooks, and makes strict docs builds, fully covered hook tests, linting, and type checking part of the CI gate. Sequence diagram for pulling external repository documentationsequenceDiagram
participant MkDocs
participant Hooks as docs/hooks.py
participant Config as docs-sources.yml
participant GitHub
participant Files as MkDocs files
MkDocs->>Hooks: on_config(config)
Hooks->>Config: load_sources(path)
Config-->>Hooks: pinned Source entries
Hooks->>GitHub: download(ARCHIVE_URL, archive)
GitHub-->>Hooks: commit tarball
Hooks->>Hooks: extract_docs(archive, target)
Hooks->>Hooks: section_nav(root, name)
Hooks-->>MkDocs: replace external marker with nav
MkDocs->>Hooks: on_files(files, config)
Hooks->>Files: add pulled docs with File.generated
MkDocs->>Hooks: on_page_markdown(markdown, page, config, files)
Hooks-->>MkDocs: set page.edit_url
Flow diagram for the strict documentation CI gateflowchart TD
Commit[Pull request or push] --> Test[test job]
Commit --> Docs[docs job]
Test --> Coverage[coverage run -m pytest\n100% required]
Coverage --> Codecov[Submit coverage to Codecov]
Docs --> Install[uv sync --locked\n--only-group docs]
Install --> Build[mkdocs build --strict]
Coverage --> Gate[passed gate]
Build --> Gate
Gate --> Result[CI passed]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #233 +/- ##
=======================================
Coverage ? 100.00%
=======================================
Files ? 1
Lines ? 199
Branches ? 0
=======================================
Hits ? 199
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Read the Docs fails to parse the command substitution that read the version of uv from the lock. Install the latest uv instead; --locked still installs the locked packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="docs/hooks.py" line_range="185-188" />
<code_context>
+ `MAX_MEMBERS` or larger than `MAX_EXTRACTED_BYTES` in total, or
+ if the repository has no `docs/`.
+ """
+ with tarfile.open(archive, "r:gz") as tar:
+ members = []
+ size = 0
+ for member in tar:
+ parts = member.name.split("/", 1)
+ if len(parts) < 2 or not (member.isfile() or member.isdir()):
</code_context>
<issue_to_address>
**Unrelated tar entries exhaust builds**
When a pinned repository tarball contains very large or numerous non-doc files while remaining under `MAX_ARCHIVE_BYTES`, `extract_docs` iterates and decompresses every tar member before filtering to `docs/` and `mkdocs.yml`, while `MAX_MEMBERS` and expanded-size accounting exclude unrelated entries; the build worker can be exhausted and the documentation build fails.
Apply member-count and expanded-size limits to all tar entries before skipping unrelated entries.
</issue_to_address>
### Comment 2
<location path="docs/hooks.py" line_range="158-161" />
<code_context>
+ raise PluginError(f"Refusing to download {url}: not HTTPS")
+ try:
+ with (
+ urllib.request.urlopen(url, timeout=TIMEOUT) as response, # noqa: S310
+ target.open("wb") as file,
+ ):
+ while chunk := response.read(1024 * 1024):
+ if file.tell() + len(chunk) > MAX_ARCHIVE_BYTES:
+ raise PluginError(f"{url}: larger than {MAX_ARCHIVE_BYTES} bytes")
</code_context>
<issue_to_address>
**Slow downloads stall builds**
When the tarball endpoint trickles data often enough to avoid a socket timeout but takes longer than the build budget, `urlopen` applies `TIMEOUT` to individual socket operations, but each successful `response.read` starts another wait with no overall deadline. A server that keeps sending data within each timeout can hold the docs build until the CI job or hosting build times out.
Enforce an overall download deadline in addition to the per-operation socket timeout.
</issue_to_address>
### Comment 3
<location path="docs/hooks.py" line_range="374" />
<code_context>
+ name = pulled.source.name
+ if pulled.root is None:
+ content = PLACEHOLDER.format(name=name, repository=pulled.source.repository)
+ files.append(File.generated(config, f"{name}/index.md", content=content))
+ continue
+ docs = pulled.root / "docs"
</code_context>
<issue_to_address>
**Placeholder shadows local page**
When a placeholder source has a URI matching a local page, such as `name/index.md`, `on_files` appends a generated placeholder without checking existing site files, so MkDocs receives duplicate source paths and the placeholder can shadow the local page or fail the build.
Check for an existing file at the placeholder URI before appending the generated placeholder.
</issue_to_address>
### Comment 4
<location path="docs/hooks.py" line_range="127-128" />
<code_context>
+ if not isinstance(entry, dict):
+ raise PluginError(f"{path}: {name}: expected a mapping")
+ repository = entry.get("repository")
+ ref = entry.get("ref") or ""
+ branch = entry.get("branch") or "dev"
+ if not isinstance(name, str) or not NAME.match(name):
+ raise PluginError(f"{path}: invalid name {name!r}")
</code_context>
<issue_to_address>
**Invalid values silently change sources**
When a source entry has a missing, null, or falsey non-string `ref`, or a falsey non-string `branch` such as `0`, `load_sources` applies `or` before type-checking: an invalid `ref` becomes `""` and `pull` creates a placeholder instead of downloading the docs, while an invalid `branch` becomes `"dev"` and produces edit links to the wrong branch; invalid refs also avoid configuration validation.
Validate the raw `ref` and `branch` values before applying defaults, while allowing the documented empty-string `ref`.
</issue_to_address>
### Comment 5
<location path="docs/hooks.py" line_range="247-250" />
<code_context>
+ Returns:
+ The nav, with prefixed paths.
+ """
+ if isinstance(nav, list):
+ return [prefix_nav(item, prefix) for item in nav]
+ if isinstance(nav, dict):
+ return {title: prefix_nav(value, prefix) for title, value in nav.items()}
+ if isinstance(nav, str) and "://" not in nav:
+ return f"{prefix}/{nav}"
</code_context>
<issue_to_address>
**Recursive nav aliases crash builds**
When an upstream docs contributor's commit is pinned and its `mkdocs.yml` contains a self-referential YAML alias in `nav`, `section_nav` loads that alias and `prefix_nav` recursively follows the list or dict cycle without a visited-node guard, raising `RecursionError` and failing the docs build.
Reject cyclic nav structures or track visited containers before recursively prefixing them.
</issue_to_address>Linked issues
#224 docs: move the docs to MkDocs on Read the Docs · 3 of 4 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Move the docs to docs/ with MkDocs Material and the MkDocs and Read the Docs configuration. |
✅ Met | The existing documentation is under docs/, with MkDocs Material configured in mkdocs.yml and Read the Docs configured in .readthedocs.yaml. |
| 2 | Build the docs strictly in CI and on Read the Docs. | ✅ Met | The CI docs job runs mkdocs build --strict, and .readthedocs.yaml sets fail_on_warning: true. |
| 3 | Pull the tesk-api and tesk-core docs from those repositories at pinned commits as site sections. | 🟡 Partly met | The hooks and nav markers support pulling pinned docs, but both refs are empty, so the sections currently show placeholders instead of repository docs. |
| 4 | Keep likely-linked URLs working with redirects. | ✅ Met | mkdocs.yml configures redirects for the four listed Sphinx page URLs. |
Sourcery assessment
Needs a human reviewer. 5 findings to address first, and the new CI job passes CODECOV_TOKEN to the Codecov action while uploading coverage; if that credential or the report were exposed beyond the intended service, reverting would not undo the exposure or any access already obtained. The documentation changes themselves are reversible, but the credential handoff creates a risk that outlives a revert.
Blocking findings: docs/hooks.py:188, docs/hooks.py:161, docs/hooks.py:374, docs/hooks.py:128, docs/hooks.py:250
Add an overall deadline to downloads, keep explicit but invalid ref and branch values from silently turning into defaults, and fail when a placeholder page would replace a page of the site (Sourcery review). Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Linked issues
#224 docs: move the docs to MkDocs on Read the Docs · 2 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Build the docs strictly in CI and on Read the Docs. | ✅ Met | The CI docs job runs mkdocs build --strict, and Read the Docs is configured with fail_on_warning: true. |
| 2 | Pull tesk-api and tesk-core docs from pinned commits into their site sections. | 🟡 Partly met | The hook supports pulling docs at pinned commits and adding them to the sections, but both configured refs are empty, so the sections currently show placeholders. |
| 3 | Keep likely-linked URLs working with redirects. | ✅ Met | mkdocs.yml configures redirects for the four moved Sphinx pages. |
Summary
This moves the docs from Sphinx to MkDocs Material on Read the Docs, as in cloud-registry, and builds them strictly in CI.
documentation/becomesdocs/, with images indocs/images/and the Sphinx files removed.mkdocs.ymluses the Material theme (deep purple, as in cloud-registry) with strict link validation.mkdocs-redirectskeeps the old Sphinx URLs working:tesintro.html,deployment.html,integrated_wes_tes.htmlandlocal_ftp.html..readthedocs.yamlinstalls uv (latest), runsuv sync --locked --only-group docs, and builds withfail_on_warning.pyproject.tomlanduv.lock, not a package.docsdependency group holds MkDocs, Material, redirects and pymdown-extensions.devgroup includes it, plus pytest, coverage and mypy.test(the tests of the docs hooks, coverage to Codecov withsecrets.CODECOV_TOKEN) anddocs(mkdocs build --strict). Both are in the gate'sneeds.source/is excluded.docs/and Read the Docs.Content changes (rewritten pages, configuration reference, upgrade notes, architecture, API) follow in the PR for #225. This PR moves the existing content.
tesk-api and tesk-core docs
Each repository keeps its own docs in its
docs/. This site pulls them in at build time:docs-sources.ymlpins each repository to a full commit SHA (ref).docs/hooks.pydownload that commit's tarball from GitHub and take itsdocs/andmkdocs.yml.tesk-api/andtesk-core/, for example https://tesk.readthedocs.io/en/latest/tesk-api/. The nav comes from each repository's ownmkdocs.ymland fills theexternal:tesk-apiandexternal:tesk-coremarkers in this site's nav.docs/and tesk-core's docs exist (docs: add MkDocs docs, pulled into TESK's site tesk-core#65).Why pinned tarballs rather than the multirepo plugin. mkdocs-multirepo-plugin imports by branch or tag. A branch moves, so this site would change or break without any change here. Tags in those repositories exist only for releases. Pinned commits keep builds reproducible, need no extra dependency and no
git, and fail the build on any problem.Limits. The hook caps the compressed tarball, and the number and total size of the extracted docs files (
MAX_ARCHIVE_BYTES,MAX_MEMBERS,MAX_EXTRACTED_BYTES). It extracts with tarfile'sdatafilter, so only regular files and directories come out, with no paths outside the target. The pinned content is otherwise trusted, so review the other repository's docs before bumping a ref.Build plugins. The pulled pages are built with this site's
mkdocs.yml, so they can use only this site's plugins and Markdown extensions. If tesk-api's docs need build plugins such as mkdocstrings, the plan is to pull them as Pubgrade does Sidecar's (git submodule), or to leave those pages out.docs/development.mdexplains all of this.Closes #224
Verification
pytestwith coverage: 40 tests pass, 100% coverage ofdocs/hooks.py. This includes an end-to-end build with pulled docs, the limits, cleanup after failed pulls, and shutdown.mypy: no issues.ruff checkandruff format --checkondocs/andtests/: pass.mkdocs build --strict: passes.dev, fix: default to taskmaster and filer v0.10.6 #220's change to the deployment page carried over todocs/deployment.md. Its relative link to the chart README now points to GitHub, so the strict build passes.--lockedstill pins the packages).Review
Full review, because of real code (the hooks) and CI changes: adversarial-reviewer and quality-reviewer, 2 rounds.
docs-sources.ymlis resolved next tomkdocs.yml, download limits were added, a rename, and the CI header was rewrapped.docs/.Sourcery
Three findings were fixed in 109e1a2: an overall download deadline, keeping invalid
ref/branchvalues from becoming defaults, and failing when a placeholder page would replace a site page. Three were answered and resolved: decompression of non-docs entries, cyclic nav aliases, and the empty refs, which are on purpose until the docs of tesk-api and tesk-core exist.Declined review findings
on_shutdownin the end-to-end test. Declined:test_on_shutdowncovers it, and the test fixture resets the state.User actions after merge
dev. It is stillmain, a branch from 2018, solatestdoes not show these docs.Open questions
None.
🤖 Generated with Claude Code