File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -365,11 +365,11 @@ def _parse_item(item):
365365 # apply shorthand if possible (one toctree in subtrees)
366366 if len (data [subtrees_key ]) == 1 and items_key in data [subtrees_key ][0 ]:
367367 old_toctree_data = data .pop (subtrees_key )[0 ]
368- data [items_key ] = old_toctree_data [items_key ]
369368 # move options to options key
370369 if len (old_toctree_data ) > 1 :
371370 data ["options" ] = {
372371 k : v for k , v in old_toctree_data .items () if k != items_key
373372 }
373+ data [items_key ] = old_toctree_data [items_key ]
374374
375375 return data
Original file line number Diff line number Diff line change @@ -321,8 +321,9 @@ def migrate_jupyter_book(
321321 raise MalformedError ("ToC is not a list or dict" )
322322
323323 # convert first `file` to `root`
324- if "file" in toc :
325- toc ["root" ] = toc .pop ("file" )
324+ if "file" not in toc :
325+ raise MalformedError ("no top-level 'file' key found" )
326+ toc ["root" ] = toc .pop ("file" )
326327
327328 # setting `titlesonly` True is now part of the file format
328329 # toc["defaults"] = {"titlesonly": True}
@@ -375,7 +376,10 @@ def migrate_jupyter_book(
375376 subtree ["numbered" ] = numbered
376377
377378 # now convert to a site map, so we can validate
378- site_map = parse_toc_data (toc )
379+ try :
380+ site_map = parse_toc_data (toc )
381+ except MalformedError as err :
382+ raise MalformedError (f"Error parsing migrated output: { err } " ) from err
379383 # change the file format and convert back to a dict
380384 site_map .file_format = file_format
381385 return create_toc_dict (site_map , skip_defaults = True )
You can’t perform that action at this time.
0 commit comments