Skip to content

fix(docs): build subpackage docs from the package directory - #286

Open
d-v-b wants to merge 1 commit into
mainfrom
claude/fix-rtd-docs-cwd
Open

fix(docs): build subpackage docs from the package directory#286
d-v-b wants to merge 1 commit into
mainfrom
claude/fix-rtd-docs-cwd

Conversation

@d-v-b

@d-v-b d-v-b commented Aug 12, 2026

Copy link
Copy Markdown
Owner

🤖 AI text below 🤖

The failure

The zarr_indexing-v0.2.0 docs build fails on Read the Docs:

ERROR   -  Error reading page 'index.md': Snippet at path 'snippets/canonical_slice.py' could not be found
pymdownx.snippets.SnippetMissingError: Snippet at path 'snippets/canonical_slice.py' could not be found

The file is not missing. It is at packages/zarr-indexing/docs/snippets/canonical_slice.py, and the build is looking somewhere else.

Cause

pymdownx.snippets resolves a relative base_path against the current working directory, not against the config file. zarr-indexing/mkdocs.yml has:

- pymdownx.snippets:
    base_path: [docs, examples]

and docs/index.md does --8<-- "snippets/canonical_slice.py:landing-quickstart", so the snippet is looked for at <cwd>/docs/snippets/canonical_slice.py:

Build Working directory Resolves to
just docs-check, CI packages/zarr-indexing packages/zarr-indexing/docs/snippets/…
Read the Docs (-f from the repo root) repo root <repo>/docs/snippets/… — zarr-python's core docs

That is why CI is green and Read the Docs is not.

Fix

Build from inside the package instead of pointing -f at its config from the repo root:

-        - mkdocs build --strict -f packages/zarr-indexing/mkdocs.yml --site-dir $READTHEDOCS_OUTPUT/html
+        - cd packages/zarr-indexing && mkdocs build --strict --site-dir $READTHEDOCS_OUTPUT/html

$READTHEDOCS_OUTPUT is absolute, so the cd does not change where the site lands.

This is preferred over making base_path config-relative, which would also require rewriting every --8<-- path. More importantly it makes the Read the Docs invocation identical to the local and CI ones, so a green just docs-check means a green Read the Docs build — the class of bug goes away rather than this one instance of it.

Scope

Applied to all three packages. Only zarr-indexing is failing today; zarr-metadata and zarr-http-server do not use snippets, so for them this is preventive — the hazard is any setting resolved against the working directory, and it would surface only on Read the Docs, after a release.

Verification

  • Reproduced the failure against the tagged commit d9af955f in a scratch worktree: building from the repo root with -f fails with the identical error; building from the package directory succeeds.
  • All three packages build clean with the new command, and the rendered snippet is present in zarr-indexing's index.html.
  • The old command still reproduces SnippetMissingError, confirming the diff is what changes the outcome.

Note

Read the Docs builds tags, so this does not repair the published zarr_indexing-v0.2.0 build. A patch release cut from main after this merges will build correctly.

Read the Docs pointed `-f` at each package's mkdocs.yml from the repo
root. mkdocs resolves some settings relative to the current working
directory rather than to the config file, so building from elsewhere
looks for them in the wrong place -- and silently, because the paths are
valid, just wrong.

zarr-indexing hit this at v0.2.0: `pymdownx.snippets` has a relative
`base_path` of `[docs, examples]`, so `--8<-- "snippets/canonical_slice.py"`
resolved against the repo root and searched zarr-python's own docs/
rather than the package's. The build failed with SnippetMissingError
while `just docs-check` passed, because that runs from the package
directory.

Building from the package directory makes the Read the Docs invocation
identical to the local and CI ones, so a green build there means a green
build here. $READTHEDOCS_OUTPUT is absolute, so the cd does not affect
where the site lands.

Applied to all three packages. Only zarr-indexing is failing today;
zarr-metadata and zarr-http-server do not use snippets, so for them this
is preventive -- the hazard is any config resolved against the working
directory, and it would show up only on Read the Docs.

Assisted-by: ClaudeCode:claude-opus-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant