diff --git a/sphinx_ape/sphinx_ext/directives.py b/sphinx_ape/sphinx_ext/directives.py index b788100..77327ca 100644 --- a/sphinx_ape/sphinx_ext/directives.py +++ b/sphinx_ape/sphinx_ext/directives.py @@ -67,6 +67,11 @@ def builder(self) -> DocumentationBuilder: def run(self): userguides = self._get_userguides() + + # TODO: DELETE THIS! FORCED TO DEBUG LIKE THIS. + if not userguides: + raise ValueError("DEBUG") + cli_docs = self._get_cli_references() methoddocs = self._get_methoddocs() @@ -85,6 +90,10 @@ def run(self): # Plugin or regular package. sections["Python Reference"] = methoddocs + # Ensure TOC is not empty (no docs?). + if not sections or not any(len(x) for x in sections.values()): + raise BuildError("Empty TOC.") + toc_trees = [] for caption, entries in sections.items(): if len(entries) < 1: @@ -101,10 +110,6 @@ def run(self): if toc_tree_rst: restructured_text = f"{restructured_text}\n\n{toc_tree_rst}" - # Ensure TOC is not empty (no docs?). - if not sections or not any(len(x) for x in sections.values()): - raise BuildError("Empty TOC.") - return self.parse_text_to_nodes(restructured_text) def _get_userguides(self) -> list[str]: