@@ -76,9 +76,10 @@ def parse_toc_to_env(app: Sphinx, config: Config) -> None:
7676 config .external_site_map = site_map
7777
7878 # 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
8283
8384 if config ["external_toc_exclude_missing" ]:
8485 # add files not specified in ToC file to exclude list
@@ -181,6 +182,14 @@ def insert_toctrees(app: Sphinx, doctree: nodes.document) -> None:
181182 site_map : SiteMap = app .env .external_site_map
182183 doc_item : Optional [Document ] = site_map .get (app .env .docname )
183184
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+
184193 if doc_item is None or not doc_item .subtrees :
185194 if toc_placeholders :
186195 create_warning (
0 commit comments