Skip to content

docs: move the docs to MkDocs on Read the Docs - #233

Merged
uniqueg merged 6 commits into
devfrom
docs/mkdocs
Nov 6, 2026
Merged

uniqueg merged 6 commits into
devfrom
docs/mkdocs

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

This moves the docs from Sphinx to MkDocs Material on Read the Docs, as in cloud-registry, and builds them strictly in CI.

  • Docs move:
    • documentation/ becomes docs/, with images in docs/images/ and the Sphinx files removed.
    • mkdocs.yml uses the Material theme (deep purple, as in cloud-registry) with strict link validation.
    • mkdocs-redirects keeps the old Sphinx URLs working: tesintro.html, deployment.html, integrated_wes_tes.html and local_ftp.html.
  • Read the Docs: .readthedocs.yaml installs uv (latest), runs uv sync --locked --only-group docs, and builds with fail_on_warning.
  • Tools: pyproject.toml and uv.lock, not a package.
    • The docs dependency group holds MkDocs, Material, redirects and pymdown-extensions.
    • The dev group includes it, plus pytest, coverage and mypy.
    • Settings for ruff and mypy are as in cloud-registry. Coverage must be 100%.
  • CI: new jobs test (the tests of the docs hooks, coverage to Codecov with secrets.CODECOV_TOKEN) and docs (mkdocs build --strict). Both are in the gate's needs.
  • pre-commit: ruff (check and format) and mypy hooks. source/ is excluded.
  • Links: fixed so that the strict build passes. Links to the chart and examples point to GitHub, and the WES-TES descriptors point to their last commit. The README points to 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:

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's data filter, 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.md explains all of this.

Closes #224

Verification

  • pytest with coverage: 40 tests pass, 100% coverage of docs/hooks.py. This includes an end-to-end build with pulled docs, the limits, cleanup after failed pulls, and shutdown.
  • mypy: no issues.
  • ruff check and ruff format --check on docs/ and tests/: pass.
  • mkdocs build --strict: passes.
  • After the rebase onto dev, fix: default to taskmaster and filer v0.10.6 #220's change to the deployment page carried over to docs/deployment.md. Its relative link to the chart README now points to GitHub, so the strict build passes.
  • CI: all jobs pass, including Test and Docs. The Read the Docs preview builds: https://tesk--233.org.readthedocs.build/en/233/. Its first build failed because Read the Docs could not parse the command that read uv's version from the lock, so it now installs the latest uv (--locked still pins the packages).

Review

Full review, because of real code (the hooks) and CI changes: adversarial-reviewer and quality-reviewer, 2 rounds.

  • Round 1: no high findings.
    • Medium findings fixed: an end-to-end test instead of a site-build test, and cleanup of temporary directories on failure and at shutdown.
    • Low findings fixed: docs-sources.yml is resolved next to mkdocs.yml, download limits were added, a rename, and the CI header was rewrapped.
  • Round 2: no high findings.
    • Both reviewers noted that the extracted size was not capped, and that the member limit counted the whole repository. Fixed: only the docs count, and there is a new size cap.
    • Low findings fixed: the docs name the limits, the shutdown test is clearer, and the cleanup test is parametrized over a fetch failure and a repository without docs/.

Sourcery

Three findings were fixed in 109e1a2: an overall download deadline, keeping invalid ref/branch values 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

  • Round 2 suggested calling on_shutdown in the end-to-end test. Declined: test_on_shutdown covers it, and the test fixture resets the state.

User actions after merge

  • Set the Read the Docs project's default branch to dev. It is still main, a branch from 2018, so latest does not show these docs.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 4 commits November 6, 2026 06:18
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The 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 documentation

sequenceDiagram
    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
Loading

Flow diagram for the strict documentation CI gate

flowchart 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]
Loading

File-Level Changes

Change Details Files
Migrates the documentation site from Sphinx to MkDocs Material with strict validation and legacy URL redirects.
  • Moves Markdown content and images into docs/, removes Sphinx configuration and requirements, and adds MkDocs navigation/theme settings.
  • Updates links and README references to the new documentation paths, GitHub-hosted repository files, and Read the Docs.
  • Adds pinned documentation dependencies and reproducible Read the Docs configuration using uv.
.readthedocs.yaml
README.md
documentation/conf.py
documentation/index.rst
documentation/requirements.txt
documentation/*.md
documentation/img/*
docs/index.md
docs/*.md
docs/images/*
mkdocs.yml
pyproject.toml
uv.lock
Adds a MkDocs hook system for reproducibly incorporating tesk-api and tesk-core documentation.
  • Loads external sources from docs-sources.yml, requiring valid repository names and full commit SHAs, with placeholders for unset refs.
  • Downloads pinned GitHub tarballs over HTTPS, applies archive/member/size limits, safely extracts only documentation content, and cleans up temporary state.
  • Injects external navigation and files into MkDocs while preserving repository-specific nav ordering and edit links.
  • Adds comprehensive unit and end-to-end coverage for parsing, extraction safety, limits, failures, cleanup, navigation, and MkDocs integration.
docs-sources.yml
docs/hooks.py
tests/test_hooks.py
docs/development.md
Makes documentation and hook quality checks mandatory in local development and CI.
  • Adds CI test and strict docs-build jobs, including 100% coverage reporting to Codecov.
  • Adds the test and docs jobs to the required CI gate.
  • Adds Ruff and mypy pre-commit hooks and configures pytest, coverage, Ruff, and mypy in pyproject.toml.
.github/workflows/ci.yml
.pre-commit-config.yaml
codecov.yml
pyproject.toml

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dev@471d11f). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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]>
@uniqueg
uniqueg marked this pull request as ready for review November 6, 2026 05:27

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/hooks.py Resolved
Comment thread docs/hooks.py Resolved
Comment thread docs/hooks.py Resolved
Comment thread docs/hooks.py Resolved
Comment thread docs/hooks.py Resolved
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]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs-sources.yml Resolved
@uniqueg
uniqueg merged commit e1ec1db into dev Nov 6, 2026
28 checks passed
@uniqueg
uniqueg deleted the docs/mkdocs branch November 6, 2026 05:42
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.

docs: move the docs to MkDocs on Read the Docs

1 participant