@@ -161,7 +161,7 @@ def parse_toc_yaml(path: Union[str, Path], encoding: str = "utf8") -> SiteMap:
161
161
def parse_toc_data (data : Dict [str , Any ]) -> SiteMap :
162
162
"""Parse a dictionary of the ToC."""
163
163
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 )} " )
165
165
166
166
defaults : Dict [str , Any ] = data .get ("defaults" , {})
167
167
@@ -210,11 +210,22 @@ def _parse_doc_item(
210
210
"toctree section contains incompatible keys "
211
211
f"{ link_keys !r} : { path } { part_idx } /{ sect_idx } "
212
212
)
213
+
213
214
if link_keys == {FILE_KEY }:
214
215
sections .append (FileItem (section [FILE_KEY ]))
215
216
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
+ )
216
222
sections .append (GlobItem (section [GLOB_KEY ]))
217
223
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
+ )
218
229
sections .append (UrlItem (section [URL_KEY ], section .get ("title" )))
219
230
220
231
# generate toc key-word arguments
0 commit comments