Skip to content

Commit 57877a7

Browse files
committed
Add style and restart_numbering to toctree data
Added 'style' and 'restart_numbering' fields to toctree structures in YAML and XML test files to support new features. Updated TocTreeCollectorWithStyles to skip non-internal document references when fixing nested toctrees. This improves handling of toctree options and ensures correct processing of document references.
1 parent f114098 commit 57877a7

11 files changed

Lines changed: 38 additions & 4 deletions

sphinx_external_toc/collectors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ def __replace_toc(self, env, ref, node, style):
256256

257257
def __fix_nested_toc(self, env, toctree, style):
258258
for _, ref in toctree["entries"]:
259+
# Only process internal document references
260+
if ref not in env.titles:
261+
continue
262+
259263
if "secnumber" not in env.titles[ref]:
260264
continue
261265
new_secnumber = self.__renumber(

tests/test_parsing/test_file_to_sitemap_basic_.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ documents:
1818
url: https://example.com
1919
maxdepth: -1
2020
numbered: false
21+
restart_numbering: null
2122
reversed: false
23+
style: numerical
2224
titlesonly: true
2325
title: null
2426
intro:
@@ -32,7 +34,9 @@ documents:
3234
- doc3
3335
maxdepth: -1
3436
numbered: true
37+
restart_numbering: null
3538
reversed: false
39+
style: numerical
3640
titlesonly: true
3741
title: null
3842
subfolder/doc4:

tests/test_parsing/test_file_to_sitemap_basic_compressed_.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ documents:
1818
url: https://example.com
1919
maxdepth: -1
2020
numbered: false
21+
restart_numbering: null
2122
reversed: false
23+
style: numerical
2224
titlesonly: true
2325
title: null
2426
doc4:
@@ -36,7 +38,9 @@ documents:
3638
- doc3
3739
maxdepth: -1
3840
numbered: true
41+
restart_numbering: null
3942
reversed: false
43+
style: numerical
4044
titlesonly: true
4145
title: null
4246
meta:

tests/test_parsing/test_file_to_sitemap_exclude_missing_.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ documents:
1313
- subfolder/other*
1414
maxdepth: -1
1515
numbered: false
16+
restart_numbering: null
1617
reversed: false
18+
style: numerical
1719
titlesonly: false
1820
title: null
1921
meta:

tests/test_parsing/test_file_to_sitemap_glob_.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ documents:
88
- doc*
99
maxdepth: -1
1010
numbered: false
11+
restart_numbering: null
1112
reversed: false
13+
style: numerical
1214
titlesonly: false
1315
title: null
1416
meta:

tests/test_parsing/test_file_to_sitemap_nested_.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ documents:
1717
- folder/globfolder/*
1818
maxdepth: -1
1919
numbered: false
20+
restart_numbering: null
2021
reversed: false
22+
style: numerical
2123
titlesonly: false
2224
title: null
2325
folder/subfolder/doc4:
@@ -35,7 +37,9 @@ documents:
3537
- folder/doc3
3638
maxdepth: -1
3739
numbered: false
40+
restart_numbering: null
3841
reversed: false
42+
style: numerical
3943
titlesonly: false
4044
title: null
4145
meta:

tests/test_parsing/test_file_to_sitemap_tableofcontents_.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ documents:
1616
- doc1
1717
maxdepth: -1
1818
numbered: false
19+
restart_numbering: null
1920
reversed: false
21+
style: numerical
2022
titlesonly: false
2123
- caption: null
2224
hidden: true
2325
items:
2426
- doc2
2527
maxdepth: -1
2628
numbered: false
29+
restart_numbering: null
2730
reversed: false
31+
style: numerical
2832
titlesonly: false
2933
title: null
3034
meta:

tests/test_sphinx/test_success_basic_.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<title>
44
Heading: intro.rst
55
<compound classes="toctree-wrapper">
6-
<toctree caption="Part Caption" entries="(None,\ 'doc1') (None,\ 'doc2') (None,\ 'doc3')" glob="False" hidden="True" includefiles="doc1 doc2 doc3" includehidden="False" maxdepth="-1" numbered="999" parent="intro" rawcaption="Part Caption" titlesonly="True">
6+
<toctree caption="Part Caption" entries="(None,\ 'doc1') (None,\ 'doc2') (None,\ 'doc3')" glob="False" hidden="True" includefiles="doc1 doc2 doc3" includehidden="False" maxdepth="-1" numbered="999" parent="intro" rawcaption="Part Caption" restart_numbering="True" style="numerical" titlesonly="True">

tests/test_sphinx/test_success_basic_compressed_.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<title>
44
Heading: intro.rst
55
<compound classes="toctree-wrapper">
6-
<toctree caption="True" entries="(None,\ 'doc1') (None,\ 'doc2') (None,\ 'doc3')" glob="False" hidden="True" includefiles="doc1 doc2 doc3" includehidden="False" maxdepth="-1" numbered="999" parent="intro" rawcaption="" titlesonly="True">
6+
<toctree caption="True" entries="(None,\ 'doc1') (None,\ 'doc2') (None,\ 'doc3')" glob="False" hidden="True" includefiles="doc1 doc2 doc3" includehidden="False" maxdepth="-1" numbered="999" parent="intro" rawcaption="" restart_numbering="True" style="numerical" titlesonly="True">

tests/test_sphinx/test_success_tableofcontents_.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<title>
44
Heading: intro.rst
55
<compound classes="toctree-wrapper">
6-
<toctree caption="True" entries="(None,\ 'doc1')" glob="False" hidden="False" includefiles="doc1" includehidden="False" maxdepth="-1" numbered="0" parent="intro" rawcaption="" titlesonly="False">
6+
<toctree caption="True" entries="(None,\ 'doc1')" glob="False" hidden="False" includefiles="doc1" includehidden="False" maxdepth="-1" numbered="0" parent="intro" rawcaption="" restart_numbering="True" style="numerical" titlesonly="False">
77
<compound classes="toctree-wrapper">
8-
<toctree caption="True" entries="(None,\ 'doc2')" glob="False" hidden="False" includefiles="doc2" includehidden="False" maxdepth="-1" numbered="0" parent="intro" rawcaption="" titlesonly="False">
8+
<toctree caption="True" entries="(None,\ 'doc2')" glob="False" hidden="False" includefiles="doc2" includehidden="False" maxdepth="-1" numbered="0" parent="intro" rawcaption="" restart_numbering="True" style="numerical" titlesonly="False">

0 commit comments

Comments
 (0)