Fix duplicate label warnings for included files (#14413)#14417
Open
FazeelUsmani wants to merge 2 commits intosphinx-doc:masterfrom
Open
Fix duplicate label warnings for included files (#14413)#14417FazeelUsmani wants to merge 2 commits intosphinx-doc:masterfrom
FazeelUsmani wants to merge 2 commits intosphinx-doc:masterfrom
Conversation
77c50a5 to
f8d1efe
Compare
17ca9b0 to
c27fbad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Fix false-positive "duplicate label" warnings when files are both included via
.. include::and processed as standalone documents.When a file containing labels (e.g., figures with
:name:)is included in another document using the.. include::directive, and that same file is also in the toctree as a standalone document, Sphinx would emit duplicate label warnings even though both labels originate from the same source file.This fix tracks the source file path for each label and compares them when detecting duplicates. If both labels come from the same source file, the warning is suppressed and the label from the including document is preferred (for proper figure numbering with
:numref:).Real duplicates (same label defined in different source files) still produce warnings as expected.
References