executablebooks / sphinx-external-toc

A sphinx extension that allows the site-map to be defined in a single YAML file
https://sphinx-external-toc.readthedocs.io
MIT License
33 stars 18 forks source link

Totally blank pages result in a confusing error #54

Closed choldgraf closed 2 years ago

choldgraf commented 2 years ago

Describe the problem

When a blank page has sub-pages attached to it, Sphinx throws this confusing error:

Exception occurred:
  File "/home/choldgraf/github/forks/python/ebp/sphinx-external-toc/sphinx_external_toc/events.py", line 294, in insert_toctrees
    doctree.children[-1].extend(node_list)
IndexError: list index out of range

This is because the page is blank and has no doctree children, so the indexing above fails.

Link to your repository or website

No response

Steps to reproduce

It was a bit wonky to run down this bug so I figured the easiest thing was to open a draft PR that demonstrates the problem. Check it out here: https://github.com/executablebooks/sphinx-external-toc/pull/53

The version of Python you're using

No response

Your operating system

No response

Versions of your packages

No response

Additional context

No response