Skip to content

Fix example/schema links on versioned spec pages pointing at dev - #607

Open
normanrz wants to merge 1 commit into
ome:mainfrom
normanrz:claude/ngff-spec-version-links-6b6269
Open

Fix example/schema links on versioned spec pages pointing at dev#607
normanrz wants to merge 1 commit into
ome:mainfrom
normanrz:claude/ngff-spec-version-links-6b6269

Conversation

@normanrz

@normanrz normanrz commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Problem

On https://ngff.openmicroscopy.org/specifications/0.5/examples/index.html, every example link points at the dev spec instead of 0.5. Same for the schemas index:

page link
0.5/examples/index.html ../../dev/examples/multiscales_strict/multiscales_strict.html#examples-multiscales-strict-multiscales-example
0.5/schemas/index.html ../../dev/schemas/image.html#schemas-image

This affects 0.1–0.5; only dev was correct, by accident.

Cause

Each version submodule's pre_build.py generates its examples/schemas pages with identical MyST label names — (examples:multiscales_strict:multiscales-example)=, (schemas:image)=, and so on. Sphinx reads all six versions into a single project, so those labels collide. Sphinx keeps one instance, drops the rest (1500+ duplicate label warnings in the build log), and every […](#examples:…) link in every version then resolves to the surviving one — dev.

The hand-written spec prose doesn't have this problem because its labels are already namespaced: version0.5:intro, version0.5:multiscale-md. The generated ones weren't.

Fix

A namespace_generated_labels() pass in conf.py that runs right after pre_build.py and rewrites the generated markdown to prefix those targets and links with version{version}:, matching the existing convention.

It lives in the superproject for the same reason the Bikeshed boilerplate injection just above it does — otherwise this would mean editing, committing, and bumping all six ngff-spec version branches. The substitution is idempotent (an already-prefixed label no longer matches), so re-running the build is safe.

Verification

Full local Sphinx build of all six versions:

before after
0.5 examples ../../dev/examples/multiscales_strict/…#examples-… multiscales_strict/multiscales_strict.html#version0-5-examples-…
0.5 schemas ../../dev/schemas/image.html#schemas-image image.html#version0-5-schemas-image
  • The anchors exist on the target pages (id="version0-5-examples-multiscales-strict-multiscales-example", id="versiondev-schemas-image").
  • dev's own links still resolve to dev.
  • All duplicate label warnings for examples:/schemas: are gone; one unrelated one remains (rfcs:rfc9:comment2 in rfc/9/comments/).
  • Build exits 0.

Notes for the reviewer

  • Anchor slugs change (#examples-…#version0-5-examples-…). Any external deep link to a generated example/schema anchor will break. Given those anchors currently all land on the wrong version anyway, that seemed like the right trade, but worth a second opinion.
  • An alternative would be to namespace the labels in pre_build.py inside ngff-spec itself, which is arguably the more correct home — at the cost of a change on all six version branches plus six submodule bumps. Happy to go that route instead if you'd prefer.
  • Two pre-existing issues I did not touch:
    • href="#schemas/image.html" in every schemas index is separately broken — pre_build.py writes the HTML link as schemas/image.html, but the index already lives in schemas/, so it should be image.html. That fix belongs in the ngff-spec submodule.
    • The duplicate rfcs:rfc9:comment2 label.

🤖 Generated with Claude Code

Each version submodule's pre_build.py generates its examples and schemas
pages with identical MyST label names (examples:multiscales_strict:...,
schemas:image, ...). Sphinx reads all six versions into a single project,
so those labels collide: it keeps one instance and drops the rest, and
every [...](#examples:...) link in every version resolved to the surviving
one — dev. Clicking an example link on the 0.5 examples index silently
took you to the dev spec.

The hand-written spec prose does not have this problem because its labels
are already namespaced (version0.5:intro, version0.5:multiscale-md). Do
the same for the generated ones: rewrite them to version{version}: right
after pre_build.py runs.

Kept in the superproject, like the boilerplate injection above it, so we
do not have to edit, commit, and bump every ngff-spec version submodule.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Automated Review URLs

@lubianat

lubianat commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks @normanrz ! It is a good change, I think, but the claude note is somewhat long, would you mind providing a tl;dr at least for triage?

Copilot AI 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.

🟢 Approval recommended

The change is narrowly scoped to the build pipeline, is consistent with existing version{version}: label conventions, and directly addresses the documented root cause (duplicate label collisions) without introducing API/runtime behavior changes.

Pull request overview

This PR fixes cross-version link resolution on the rendered, versioned specification site by namespacing the MyST labels generated for examples and schemas so they no longer collide across versions in a single Sphinx project.

Changes:

  • Added a namespace_generated_labels() pass in conf.py to prefix generated examples:/schemas: labels and their in-page links with version{version}:.
  • Hooked that pass into the build flow immediately after each version’s pre_build.py runs, so the rewritten Markdown is what Sphinx/Jupyter Book consumes.
File summaries
File Description
conf.py Adds and invokes a Markdown rewrite step to namespace generated MyST labels/links per spec version, preventing Sphinx duplicate-label collisions that previously redirected versioned links to dev.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@normanrz

normanrz commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

tl;dr
If you go to https://ngff.openmicroscopy.org/specifications/0.5/examples/index.html, all the links point to the dev version examples instead of the 0.5 examples. This PR fixes that.

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.

3 participants