@@ -161,7 +161,7 @@ def parse_toc_yaml(path: Union[str, Path], encoding: str = "utf8") -> SiteMap:
161161def parse_toc_data (data : Dict [str , Any ]) -> SiteMap :
162162 """Parse a dictionary of the ToC."""
163163 if not isinstance (data , Mapping ):
164- MalformedError (f"toc is not a mapping: { type (data )} " )
164+ raise MalformedError (f"toc is not a mapping: { type (data )} " )
165165
166166 defaults : Dict [str , Any ] = data .get ("defaults" , {})
167167
@@ -210,11 +210,22 @@ def _parse_doc_item(
210210 "toctree section contains incompatible keys "
211211 f"{ link_keys !r} : { path } { part_idx } /{ sect_idx } "
212212 )
213+
213214 if link_keys == {FILE_KEY }:
214215 sections .append (FileItem (section [FILE_KEY ]))
215216 elif link_keys == {GLOB_KEY }:
217+ if "sections" in section or "parts" in section :
218+ raise MalformedError (
219+ "toctree section contains incompatible keys "
220+ f"{ GLOB_KEY } and parts/sections: { path } { part_idx } /{ sect_idx } "
221+ )
216222 sections .append (GlobItem (section [GLOB_KEY ]))
217223 elif link_keys == {URL_KEY }:
224+ if "sections" in section or "parts" in section :
225+ raise MalformedError (
226+ "toctree section contains incompatible keys "
227+ f"{ URL_KEY } and parts/sections: { path } { part_idx } /{ sect_idx } "
228+ )
218229 sections .append (UrlItem (section [URL_KEY ], section .get ("title" )))
219230
220231 # generate toc key-word arguments
0 commit comments