8
8
from sphinx import addnodes
9
9
from sphinx .builders .latex .nodes import thebibliography
10
10
11
- from .utils import getFilename , removeExtension
11
+ from .utils import getFilenameWithSubpath , removeExtension
12
12
from .nodes import HiddenCellNode , H2Node , H3Node
13
13
14
14
# Utility functions
@@ -103,7 +103,12 @@ def alterNodes(sectLevelsDict, parentSect):
103
103
replaceWithNode (sect , HiddenCellNode , False )
104
104
105
105
# check if the document is the masterdoc
106
- if getFilename (self .document ["source" ]) == self .app .config .master_doc :
106
+ numbSlashes = self .app .config .master_doc .count ("/" )
107
+
108
+ if (
109
+ getFilenameWithSubpath (self .document ["source" ], numbSlashes )
110
+ == self .app .config .master_doc
111
+ ):
107
112
# pull the toctree-wrapper and append it later to the topmost document level
108
113
for node in self .document .traverse (docutils .nodes .compound ):
109
114
if "toctree-wrapper" in node ["classes" ]:
@@ -122,7 +127,7 @@ class handleSubSections(SphinxPostTransform):
122
127
123
128
def apply (self , ** kwargs : Any ) -> None :
124
129
docname = self .document ["source" ]
125
- if getFilename (docname ) == self .app .config .master_doc :
130
+ if getFilenameWithSubpath (docname , 0 ) == self .app .config .master_doc :
126
131
for compound in self .document .traverse (docutils .nodes .compound ):
127
132
if "toctree-wrapper" in compound ["classes" ]:
128
133
nodecopy = compound
@@ -149,7 +154,7 @@ def checkNodeIsInPart(part, node):
149
154
return False
150
155
151
156
docname = self .document ["source" ]
152
- if getFilename (docname ) == self .app .config .master_doc :
157
+ if getFilenameWithSubpath (docname , 0 ) == self .app .config .master_doc :
153
158
TOC_PATH = Path (self .app .confdir ).joinpath ("_toc.yml" )
154
159
tocfile = yaml .safe_load (TOC_PATH .read_text ("utf8" ))
155
160
0 commit comments