Skip to content

rST: add notice about duplicate hyperlink target names#13400

Open
jayaddison wants to merge 19 commits intosphinx-doc:masterfrom
jayaddison:issue-13383/duplicate-internal-hyperlink-target-warning
Open

rST: add notice about duplicate hyperlink target names#13400
jayaddison wants to merge 19 commits intosphinx-doc:masterfrom
jayaddison:issue-13383/duplicate-internal-hyperlink-target-warning

Conversation

@jayaddison
Copy link
Contributor

Purpose

The goal of this pull request is to identify duplicate internal hyperlink targets -- the presence of these can cause documentation hyperlinks to resolve ambiguously (e.g. sometimes incorrectly) at build-time.

References

@AA-Turner AA-Turner added this to the 8.3.0 milestone Mar 1, 2025
@jayaddison
Copy link
Contributor Author

The changes in 4df6239 seem to introduce a large number of false-positive warnings; numbered footnotes, for example, are frequently a source of distraction with this in place. I'll move this pull request back into draft status until I can resolve that problem.

@jayaddison jayaddison marked this pull request as draft March 1, 2025 22:52
…tions

Re-uses some existing filtering for footnotes and other acceptable duplicates.

Some false-positives continue to occur with this change in place; for example,
internal hyperlink targets that are subsequently `include`d into other docs.
@jayaddison
Copy link
Contributor Author

Todo: extend the test coverage to add an example of document that is include'd into more than one other location; this appears to be another case where the same symptom (ambiguous resolution of anonymous hyperlinks) can occur.

Comment on lines +3 to +5
.. _ambiguous_shared_hyperlink:

This hyperlink target is declared once and is included by multiple documents.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AA-Turner @picnixz is there a way to determine a unique declaration identifier/path -- e.g. where a hyperlink was defined, instead of where it is used?

When reporting warnings about duplicated anonymous hyperlinks, it'd be nice to be able to indicate clearly that the duplication originates from multiple includes of a common document, instead of weird/confusing warnings about the hyperlinks appearing in multiple documents.

@gmilde
Copy link
Contributor

gmilde commented May 21, 2025

The term "anonymous" in the name of this PR is confusing:

The goal of this pull request is to identify duplicate internal hyperlink targets
[...]

Anonymous hyperlink targets don't use a reference name and may be internal or external. Example:

See `the web site`__ of my `favorite programming language`__.

__ https://www.python.org
__ Why I like Python_

Why I like Python
*****************
its nice

In every document, the number of anonymous references must match the number of anonymous targets.
Duplicate anonymous hyperlink targets would be a bug in the assignment of IDs to their <target> elements.

@jayaddison jayaddison changed the title rST: add warning about duplicate anonymous hyperlink targets rST: add warning about duplicate-declaration hyperlink targets May 21, 2025
@jayaddison
Copy link
Contributor Author

Thank you @gmilde - is edited version (rST: add warning about duplicate-declaration hyperlink targets) reasonably accurate?

@gmilde
Copy link
Contributor

gmilde commented May 21, 2025

I'd call it "rST: add warning about duplicate hyperlink target names".

@jayaddison jayaddison changed the title rST: add warning about duplicate-declaration hyperlink targets rST: add warning about duplicate hyperlink target names May 21, 2025
@jayaddison
Copy link
Contributor Author

Thank you; updated.

@gmilde
Copy link
Contributor

gmilde commented May 21, 2025

Regarding spurious warnings, see also my comment on the issue page.
#13383 (comment)

@jayaddison jayaddison marked this pull request as ready for review August 2, 2025 09:49
@AA-Turner AA-Turner modified the milestones: 8.3.0, 9.0.0 Nov 25, 2025
@jayaddison
Copy link
Contributor Author

@AA-Turner thanks for adding the 9.0.0 milestone - I worry about the potential for this to cause build breakage for potentially lots of downstream Sphinx projects, but I would also like for it to be included in an upcoming release.

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an INFO level notice for now, and add a note to upgrade it to WARNING in eg Sphinx 11?

A

@jayaddison
Copy link
Contributor Author

Seems reasonable, yep. Perhaps I'll mention it on the release thread too for inclusion, just in case anyone feels like testing it (or at least being aware of it) in advance.

@jayaddison jayaddison mentioned this pull request Nov 29, 2025
@AA-Turner AA-Turner added the awaiting:response Waiting for a response from the author of this issue label Nov 30, 2025
@jayaddison jayaddison changed the title rST: add warning about duplicate hyperlink target names rST: add notice about duplicate hyperlink target names Nov 30, 2025
@AA-Turner AA-Turner modified the milestones: 9.0.0, 9.x Nov 30, 2025
@AA-Turner
Copy link
Member

I'm going to delay this to 9.1.

A

@jayaddison
Copy link
Contributor Author

@AA-Turner this is probably too late for the 9.1.0 boat (I notice the rc1 ship has sailed), but should be ready for review.

@jayaddison jayaddison requested a review from AA-Turner January 3, 2026 13:09
@jayaddison
Copy link
Contributor Author

I'm uncomfortable with the way that I offensively dismissed what I felt to be a spammy issue request about AI in an unrelated FOSS project thread yesterday (2026-02-14). I mention this in case you'd prefer not to accept my contributions; however you are still welcome to. I don't use AI myself and would like not to be critical of those who do, but I was angry.

cc @AA-Turner @picnixz @francoisfreitag @danieleades (I'm not going to repost this on all five of the threads I have option, but do want to make you aware)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting:response Waiting for a response from the author of this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible bug: duplicate rST hyperlink targets don't appear to emit a warning during project processing?

3 participants