Skip to content

rST: add warning about duplicate hyperlink target names #13400

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

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

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

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

gmilde commented May 21, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
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