You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ext.viewcode following imports does not put correct [docs] links. #6651
My top level package imports some objects from subpackages and submodules so that users can access them directly. viewcode_follow_imported_members is made to still find the correct source file in this case. However, the [docs] link that should lead back to the documentation leads to the documentation of the submodule that actually contains the code (which is perfectly fine), but the jump label references the object's alias in the top level package, which is not defined like that on the submodule's documentation page.
To be more clear:
The top level package package has a package.html file that documents package.MyClass. Now MyClass is really defined in the source module package/submodule.py. The [source] link in package.html takes me to _modules/package/submodule.html and the correct code line. But the [docs] link there takes me to package.submodule.html#package.MyClass. The #package.MyClass part is incorrect; such jump label doesn't exist there. The correct jump label would be #package.submodule.MyClass.
The [docs] link goes to ../../sub.html#pkg.func, but sub.html only has id="pkg.sub.func".
has_tag creates one entry per module, and the refname stored in it is the module of the first signature that reaches that module (L140). used[fullname], on the other hand, is overwritten by each later page (L144). collect_pages then joins the two (L329), taking the page from the last document and the anchor prefix from the first. Here pkg.rst is read first and sub.rst last, so the link has the prefix pkg and the page sub.html. The other reading order breaks it too, with the page pkg.html and the prefix pkg.sub.
In a parallel build, which links break varies from build to build. env_merge_info keeps the entry, and with it the refname, of whichever worker is merged first, and keeps the first used docname instead of the last (L190-L198). In the GeoVista docs, a serial build breaks the 7 links of geovista.themes, and a -j 2 build broke the 22 of geovista.common as well.
Storing the refname with each object in used, instead of once per module, would let each link use the module its object was documented under on that page. Until then, GeoVista relinks a module by its own name once the reads are merged, when every object it holds is documented under that name on the page the link goes to (bjlittle/geovista#2672).
🤖 Investigated, reproduced and written up by Claude (Claude Opus 5.5) in Claude Code while working on GeoVista, and reviewed by @bjlittle before posting. The reproduction above was run as written.
Activity
bjlittle commentedon Oct 20, 2026
This still happens on Sphinx 9.1.0. A minimal reproduction:
The
[docs]link goes to../../sub.html#pkg.func, butsub.htmlonly hasid="pkg.sub.func".has_tagcreates one entry per module, and therefnamestored in it is the module of the first signature that reaches that module (L140).used[fullname], on the other hand, is overwritten by each later page (L144).collect_pagesthen joins the two (L329), taking the page from the last document and the anchor prefix from the first. Herepkg.rstis read first andsub.rstlast, so the link has the prefixpkgand the pagesub.html. The other reading order breaks it too, with the pagepkg.htmland the prefixpkg.sub.In a parallel build, which links break varies from build to build.
env_merge_infokeeps the entry, and with it therefname, of whichever worker is merged first, and keeps the firstuseddocname instead of the last (L190-L198). In the GeoVista docs, a serial build breaks the 7 links ofgeovista.themes, and a-j 2build broke the 22 ofgeovista.commonas well.Storing the
refnamewith each object inused, instead of once per module, would let each link use the module its object was documented under on that page. Until then, GeoVista relinks a module by its own name once the reads are merged, when every object it holds is documented under that name on the page the link goes to (bjlittle/geovista#2672).🤖 Investigated, reproduced and written up by Claude (Claude Opus 5.5) in Claude Code while working on GeoVista, and reviewed by @bjlittle before posting. The reproduction above was run as written.