File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,9 @@ Bugs fixed
99
99
* #12796: Enable parallel reading if requested,
100
100
even if there are fewer than 6 documents.
101
101
Patch by Matthias Geier.
102
- * #12888: Ensure deterministic resolution of global toctree in parallel builds
103
- when document is included in multiple toctrees by choosing lexicographically
104
- greatest parent document.
102
+ * #12888: Add a warning when document is included in multiple toctrees
103
+ and ensure deterministic resolution of global toctree in parallel builds
104
+ by choosing lexicographically greatest parent document.
105
105
Patch by A. Rafey Khan
106
106
107
107
Original file line number Diff line number Diff line change @@ -758,6 +758,7 @@ def check_consistency(self) -> None:
758
758
continue
759
759
logger .warning (__ ("document isn't included in any toctree" ),
760
760
location = docname )
761
+ _check_toc_parents (self .toctree_includes )
761
762
762
763
# call check-consistency for all extensions
763
764
for domain in self .domains .values ():
@@ -788,3 +789,22 @@ def _traverse_toctree(
788
789
if sub_docname not in traversed :
789
790
yield sub_parent , sub_docname
790
791
traversed .add (sub_docname )
792
+
793
+
794
+ def _check_toc_parents (toctree_includes : dict [str , list [str ]]):
795
+ toc_parents : dict [str , list [str ]] = {}
796
+ for parent , children in toctree_includes .items ():
797
+ for child in children :
798
+ toc_parents .setdefault (child , []).append (parent )
799
+
800
+ for doc , parents in sorted (toc_parents .items ()):
801
+ if len (parents ) > 1 :
802
+ logger .warning (
803
+ __ ("document is referenced in multiple toctrees: %s, "
804
+ "selecting: %s <- %s" ),
805
+ parents ,
806
+ max (parents ),
807
+ doc ,
808
+ location = doc , type = 'toc' ,
809
+ subtype = 'multiple_toc_parents'
810
+ )
Original file line number Diff line number Diff line change @@ -100,6 +100,15 @@ def test_numbered_circular_toctree(app):
100
100
) in warnings
101
101
102
102
103
+ @pytest .mark .sphinx ('text' , testroot = 'toctree-multiple-parents' )
104
+ def test_multiple_parents_toctree (app ):
105
+ app .build (force_all = True )
106
+ warnings = app .warning .getvalue ()
107
+ assert (
108
+ "document is referenced in multiple toctrees: ['bar', 'baz'], selecting: baz <- qux"
109
+ ) in warnings
110
+
111
+
103
112
@pytest .mark .usefixtures ('_http_teapot' )
104
113
@pytest .mark .sphinx ('dummy' , testroot = 'images' )
105
114
def test_image_glob (app ):
You can’t perform that action at this time.
0 commit comments