-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug: duplicate rST hyperlink targets don't appear to emit a warning during project processing? #13383
Comments
I'm beginning to think that this is not a bug in Sphinx (nor |
(...but even if so, I suppose we could warn about situations where duplicate link target definitions are encountered) |
I think this may be a false alarm. We already have code to detect and warn about declaration of duplicate labels: sphinx/sphinx/domains/std/__init__.py Lines 807 to 810 in a1510de
I don't know why that message doesn't appear in the build output from that package yet, though. |
Docutils nodes that contain |
Basically I think the fix here is to disambiguate the names of these hyperlink targets in the Linux kernel documentation. But it surprises me that we don't warn about it in Sphinx. |
A minimal reproducer for this is: index.rst index
=====
link to `something <duplicate>`_.
.. _duplicate:
index-testing another.rst another
=======
link to `something <duplicate>`_.
.. _duplicate:
testing conf.py # empty; no custom configuration required |
@khanxmetu I'd like to apologize for failing to recognize your report of this problem earlier; I believe it is the same issue you described at: #6714 (comment) I was slightly distracted by travel and my mind was focused narrowly on the |
There's a difference between:
In case 1. the Internal hyperlink target is meant to be linked within the same page, per reST spec notice the emphasis on "within a document":
In case 2. it's Sphinx's The MRE in the above post is correct because the (At least from experience that's how I read the difference between the reST spec and how Sphinx's |
Thank you @electric-coder. If I understand your explanation and the referenced |
I'm not sure if it is a bug, the reST spec says: "within a document" but extension of the behavior by Sphinx (to make the links work cross-document if there aren't multiple targets) doesn't seem invalid... Maybe it can be considered an undocumented Sphinx feature extending the basic reST spec of internal hyperlink targets (cross-reference functionalities are also an extension building on basic reST) - but this begs the question: the "internal" in "internal hyperlink targets" would the be internal to what? (Internal to the whole "docs" doesn't make much sense, or does it?!) If it is, indeed, undefined and not a bug the community should arbitrate what to consider it. What would be the reasons for or against it? Maybe enforcing use of I honestly don't know so at this point I'll defer. |
Describe the bug
This is observed from a build of the Linux kernel documentation in Arch Linux; relevant
diffoscope
output can be found here: https://reproducible.archlinux.org/api/v0/builds/740203/diffoscopeIt seems that sometimes the hyperlink
href
(destination) included in the HTML output for a document may resolve to a different document, despite a local declaration of the target (in the RST source).This is visible as a diff in the output
quickly-build-trimmed-linux.html
HTML file as:One characteristic of the problem link is that it is declared locally within
quickly-build-trimmed-linux.rst
-- but also, separately within theverify-bugs-and-bisect-regressions.rst
file that the referencing link sometimes mistakenly resolves to.I believe this problem was previously identified as one of I think three non-determinism problems reported in #6714 (we fixed one of those, another remains open, and the item I'm reporting again here seems untracked).
A workaround could be to remove the ambiguity in the kernel documentation, and that may be straightforward to do. Even so, I think this may be a bug in Sphinx.
cc @bmwiedemann
cc @kpcyrd
How to Reproduce
TBD
Environment Information
Sphinx extensions
Additional context
No response
The text was updated successfully, but these errors were encountered: