Skip to content

Commit

Permalink
Bugfix for small, 1-page projects (#52)
Browse files Browse the repository at this point in the history
If there are no toctree elements, no deeper node-walk
is performed anymore.

Fixes #51
  • Loading branch information
danwos committed Mar 24, 2022
1 parent 246036d commit 943c447
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sphinx_immaterial/nav_adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ def _get_mkdocs_toc(
) -> List[MkdocsNavEntry]:
"""Converts a docutils toc node into a mkdocs-format JSON toc."""
visitor = _TocVisitor(sphinx.util.docutils.new_document(""), builder)
toc_node.walk(visitor)

# toc_node can be None for projects with no toctree or 1 rst-file only.
if toc_node is not None:
toc_node.walk(visitor)
return visitor._children


Expand Down

0 comments on commit 943c447

Please sign in to comment.