8
8
from sphinx import addnodes
9
9
from sphinx .builders .latex .nodes import thebibliography
10
10
11
- from .utils import get_filename
11
+ from .utils import getFilename , removeExtension
12
12
from .nodes import HiddenCellNode , H2Node , H3Node
13
13
14
14
# Utility functions
@@ -103,7 +103,7 @@ def alterNodes(sectLevelsDict, parentSect):
103
103
replaceWithNode (sect , HiddenCellNode , False )
104
104
105
105
# check if the document is the masterdoc
106
- if get_filename (self .document ["source" ]) == self .app .config .master_doc :
106
+ if getFilename (self .document ["source" ]) == self .app .config .master_doc :
107
107
# pull the toctree-wrapper and append it later to the topmost document level
108
108
for node in self .document .traverse (docutils .nodes .compound ):
109
109
if "toctree-wrapper" in node ["classes" ]:
@@ -122,7 +122,7 @@ class handleSubSections(SphinxPostTransform):
122
122
123
123
def apply (self , ** kwargs : Any ) -> None :
124
124
docname = self .document ["source" ]
125
- if get_filename (docname ) == self .app .config .master_doc :
125
+ if getFilename (docname ) == self .app .config .master_doc :
126
126
for compound in self .document .traverse (docutils .nodes .compound ):
127
127
if "toctree-wrapper" in compound ["classes" ]:
128
128
nodecopy = compound
@@ -141,12 +141,15 @@ def checkNodeIsInPart(part, node):
141
141
nodefile = node .children [0 ].attributes ["docname" ]
142
142
chapfiles = part ["chapters" ]
143
143
for chap in chapfiles :
144
- if nodefile in chap .values ():
144
+ chapname = removeExtension (
145
+ list (chap .values ())[0 ]
146
+ ) # get filename without extension
147
+ if nodefile in chapname :
145
148
return True
146
149
return False
147
150
148
151
docname = self .document ["source" ]
149
- if get_filename (docname ) == self .app .config .master_doc :
152
+ if getFilename (docname ) == self .app .config .master_doc :
150
153
TOC_PATH = Path (self .app .confdir ).joinpath ("_toc.yml" )
151
154
tocfile = yaml .safe_load (TOC_PATH .read_text ("utf8" ))
152
155
@@ -178,6 +181,7 @@ def checkNodeIsInPart(part, node):
178
181
replaceWithNode (node , HiddenCellNode , False )
179
182
sectionName .append (nodecopy )
180
183
self .document .append (compoundParent )
184
+
181
185
# append bib at the end
182
186
if len (bibNodes ):
183
187
self .document .extend (bibNodes )
0 commit comments