docs: per-page scoped labels to fix cross-page :ref: resolution#10
Open
petrkalina wants to merge 2 commits into
Open
docs: per-page scoped labels to fix cross-page :ref: resolution#10petrkalina wants to merge 2 commits into
petrkalina wants to merge 2 commits into
Conversation
…rity, etc.) When the same label name (e.g. .. _dcmRulePriority:) is declared in multiple .rst files, Sphinx resolves all :ref:`title <label>` calls to a single canonical page. Result: clicking "Rule Priority" on archiveAttributeCoercion.html jumps to studyRetentionPolicy.html instead of staying on the current page. 30% of labels (221/731) are affected. This commit adds a per-page-scoped twin label below every existing label declaration (e.g. .. _archiveAttributeCoercion-dcmRulePriority:) and rewrites the intra-file :ref: targets to use the scoped form. The original bare label is preserved so external URLs that hard-coded the old anchor (e.g. archiveAttributeCoercion.html#dcmrulepriority) keep working — the HTML emits both anchor IDs side by side. conf.py: add suppress_warnings = ['ref.label'] so the now-intentional duplicate bare labels do not flood the build output. Stats: files changed: 76 scoped labels added: 1165 refs rewritten: 1135 Generated by tools/rewrite_labels.py (script attached in PR).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the same
.. _label:is declared in multiple.rstfiles (e.g.dcmRulePrioritylives in 7 different config pages), Sphinx picks one as the canonical target for:ref:resolution. All other pages':ref:\title `` calls resolve to that single page.User-visible effect: clicking Rule Priority in the Archive Attribute Coercion table jumps to
studyRetentionPolicy.html#dcmrulepriorityinstead of staying on the current page. This affects 221 of 731 attribute labels (~30%) — worst offenders includedcmProperty(24 files),cn(20),dicomDescription(12),dcmURI(11),dicomAETitle(10).Fix — Option B (preserves external URLs)
For every existing
.. _attrName:declaration, stack a per-page-scoped twin below it:Then rewrite intra-file
:ref:\text `` calls to use the scoped form:Sphinx now resolves the
:ref:per page (no more dedup ambiguity). The original.. _attrName:label stays put, so the rendered HTML emits both anchor IDs side by side — existing external links that hard-coded the old anchor (e.g.archiveAttributeCoercion.html#dcmrulepriority) keep working unchanged.conf.py: addedsuppress_warnings = ['ref.label']so the now-intentional duplicate bare labels don't spam the build log.Stats
.rstfiles changed:ref:references rewrittenVerification (local Sphinx 5.0 build with
sphinx_rtd_theme==1.0.0)archiveAttributeCoercion.htmlrendered HTML for Rule Priority row:Same row on
studyRetentionPolicy.htmlnow also links to its own#studyretentionpolicy-dcmrulepriority— i.e. each page resolves locally.External URLs that consumers may have bookmarked (
archiveAttributeCoercion.html#dcmrulepriority,archiveNetworkAE.html#dcmretrieveaet, etc.) continue to work because the legacyid=attributes are still emitted on every page.Reproducibility
The rewrite is idempotent. The script that produced the diff is included at
tools/rewrite_labels.py— re-running it againstdocs/is a no-op once applied.Companion repo
The HL7 conformance statement (
dcm4chee-arc-hl7cs) was checked — its labels are all unique across pages, so this fix isn't needed there.