claude: support anchor redirects in docs redirect extension - #4812
claude: support anchor redirects in docs redirect extension#4812Liam-DeVoe wants to merge 1 commit into
Conversation
| "details#hypothesis.assume": "reference/api#hypothesis.assume", | ||
| "details#hypothesis.event": "reference/api#hypothesis.event", | ||
| "details#hypothesis.given": "reference/api#hypothesis.given", | ||
| "details#hypothesis.infer": "reference/api#hypothesis.infer", | ||
| "details#hypothesis.note": "reference/api#hypothesis.note", |
There was a problem hiding this comment.
can't these be handled by a page-level redirect, and then finding an anchor on the new page which matches that on the old page?
There was a problem hiding this comment.
the problem for these specifically is we already have a "details": "reference/index.html" redirect, and want to override that redirect only for some specific anchors
details was a big catchall page that doesn't have a single canonical redirect
|
sorry I told claude to open this PR and had intended to edit the description but got pulled away I built this list by asking claude to find all extant and broken links to hypothesis on the internet. It (1) looked on stackoverflow, github search, etc, and (2) also somewhat misinterpreted and looked on the internet archive for old docs versions and pulled down the full anchor list at that time (regardless of whether anyone on the internet actually linked to it). I kept ~all of the first category and only kept the mostly-reasonable ones in the second category. |
Claude-written description
Replaces the vendored sphinx-reredirects extension and its hand-maintained
redirect.html.templatewith a purpose-built redirect extension supporting both page redirects and per-anchor redirects, declared together in theredirectsdict inconf.py.The main improvement is anchor handling on removed pages. When
dead-pageredirects tonew-page#section, a visit todead-page#some-anchornow resolves in order of preference: an explicitdead-page#some-anchorentry, thennew-page#some-anchorif that id still exists on the target page, thennew-page#section. Previously anchors were carried over unconditionally, landing on the target page with a broken fragment whenever the anchor no longer existed there.Anchor redirects also work on live pages: an entry like
live-page#moved-anchorinjects a small script into that page which redirects only when the visited fragment no longer exists on it.All redirect sources and targets are now validated at docs build time against the built doctrees — a target page or anchor that doesn't exist, a stub that would shadow a real page, or a live-page anchor entry whose anchor still exists all fail the build. This replaces the old linkcheck-based checking (which only covered external targets) and means the expanded redirect map in
conf.pycan't silently rot.The old extension's wildcard sources, template file config, and linkcheck integration were unused here and are dropped.
No
RELEASE.rstsince this only touchesdocs/.