best-practice-and-impact / qa-of-code-guidance

Guidance for quality assurance of code for civil service researchers and analysts.
https://best-practice-and-impact.github.io/qa-of-code-guidance
Other
74 stars 18 forks source link

Fix "Table of Contents file is malformed" error when `jb build book` is run #161

Closed jaetowers closed 1 year ago

jaetowers commented 1 year ago

Building the book from a python 3.7.9 virtual environment produced this error:

Traceback (most recent call last): File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\jupyter_book\cli\main.py", line 244, in build parse_toc_yaml(toc) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\sphinx_external_toc\parsing.py", line 89, in parse_toc_yaml return parse_toc_data(data) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\sphinx_external_toc\parsing.py", line 99, in parse_toc_data raise MalformedError(f"toc is not a mapping: {type(data)}") sphinx_external_toc.parsing.MalformedError: toc is not a mapping: <class 'list'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Jaehee\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Users\Jaehee\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\Scripts\jb.exe__main.py", line 7, in File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\click\core.py", line 1130, in call return self.main(*args, kwargs) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\click\core.py", line 1055, in main rv = self.invoke(ctx) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\click\core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\click\core.py", line 760, in invoke return callback(*args, **kwargs) File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\jupyter_book\cli\main.py", line 247, in build f"The Table of Contents file is malformed: {exc}\n" File "C:\Users\Jaehee\Documents_WORK_ONS\venv_py_3_7\lib\site-packages\jupyter_book\utils.py", line 48, in _error raise kind(box) RuntimeError: ←[91m===============================================================================←[0m

The Table of Contents file is malformed: toc is not a mapping: <class 'list'> You may need to migrate from the old format, using:

    jupyter-book toc migrate C:\Users\Jaehee\Documents\_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book\_toc.yml -o C:\Users\Jaehee\Documents\_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book\_toc.yml
jaetowers commented 1 year ago

Tried on Python 3.8.3 and still got the same error

RuntimeError: ←[91m===============================================================================←[0m

The Table of Contents file is malformed: toc is not a mapping: <class 'list'> You may need to migrate from the old format, using:

    jupyter-book toc migrate C:\Users\Jaehee\Documents\_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book\_toc.yml -o C:\Users\Jaehee\Documents\_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book\_toc.yml

←[91m===============================================================================←[0m

jaetowers commented 1 year ago

Running the quoted line resolved the error:

jupyter-book toc migrate C:\Users\Jaehee\Documents_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book_toc.yml -o C:\Users\Jaehee\Documents_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book_toc.yml

Written to: C:\Users\Jaehee\Documents_WORK_ONS\GIT_REPOS\qa-of-code-guidance\book_toc.yml