@@ -76,9 +76,10 @@ def parse_toc_to_env(app: Sphinx, config: Config) -> None:
76
76
config .external_site_map = site_map
77
77
78
78
# Update the master_doc to the root doc of the site map
79
- if config ["master_doc" ] != site_map .root .docname :
80
- logger .info ("[etoc] Changing master_doc to '%s'" , site_map .root .docname )
81
- config ["master_doc" ] = site_map .root .docname
79
+ root_doc = remove_suffix (site_map .root .docname , config .source_suffix )
80
+ if config ["master_doc" ] != root_doc :
81
+ logger .info ("[etoc] Changing master_doc to '%s'" , root_doc )
82
+ config ["master_doc" ] = root_doc
82
83
83
84
if config ["external_toc_exclude_missing" ]:
84
85
# add files not specified in ToC file to exclude list
@@ -181,6 +182,14 @@ def insert_toctrees(app: Sphinx, doctree: nodes.document) -> None:
181
182
site_map : SiteMap = app .env .external_site_map
182
183
doc_item : Optional [Document ] = site_map .get (app .env .docname )
183
184
185
+ # check for matches with suffix
186
+ # TODO check in sitemap, that we do not have multiple docs of the same name
187
+ # (strip extensions on creation)
188
+ for suffix in app .config .source_suffix :
189
+ if doc_item is not None :
190
+ break
191
+ doc_item = site_map .get (app .env .docname + suffix )
192
+
184
193
if doc_item is None or not doc_item .subtrees :
185
194
if toc_placeholders :
186
195
create_warning (
0 commit comments