1. Marijn van der Zee
  2. sphinx

Commits

Georg Brandl  committed 9d68dd8

Fix the handling of multiple toctrees when creating the global TOC for the ``toctree()`` template function.
Fix the handling of hidden toctrees when creating the global TOC for the ``toctree()`` template function.

  • Participants
  • Parent commits 93ae468
  • Branches default

Comments (0)

Files changed (3)

File CHANGES

View file
  • Ignore whitespace
 Release 0.6.6 (in development)
 ==============================
 
+* Fix the handling of multiple toctrees when creating the global
+  TOC for the ``toctree()`` template function.
+
+* Fix the handling of hidden toctrees when creating the global TOC
+  for the ``toctree()`` template function.
+
 * Fix the handling of nested lists in the text writer.
 
 * #362: In autodoc, check for the existence of ``__self__`` on

File sphinx/builders/html.py

View file
  • Ignore whitespace
 
     def render_partial(self, node):
         """Utility: Render a lone doctree node."""
+        if node is None:
+            return {'fragment': ''}
         doc = new_document('<partial node>')
         doc.append(node)
         return publish_parts(

File sphinx/environment.py

View file
  • Ignore whitespace
     def get_toctree_for(self, docname, builder, collapse):
         """Return the global TOC nodetree."""
         doctree = self.get_doctree(self.config.master_doc)
+        toctrees = []
         for toctreenode in doctree.traverse(addnodes.toctree):
-            result = self.resolve_toctree(docname, builder, toctreenode,
-                                          prune=True, collapse=collapse)
-            if result is not None:
-                return result
+            toctree = self.resolve_toctree(docname, builder, toctreenode,
+                                           prune=True, collapse=collapse,
+                                           includehidden=True)
+            toctrees.append(toctree)
+        if not toctrees:
+            return None
+        result = toctrees[0]
+        for toctree in toctrees[1:]:
+            result.extend(toctree.children)
+        return result
 
     # -------
     # these are called from docutils directives and therefore use self.docname
         return doctree
 
     def resolve_toctree(self, docname, builder, toctree, prune=True, maxdepth=0,
-                        titles_only=False, collapse=False):
+                        titles_only=False, collapse=False, includehidden=False):
         """
         Resolve a *toctree* node into individual bullet lists with titles
         as items, returning None (if no containing titles are found) or
         If *collapse* is True, all branches not containing docname will
         be collapsed.
         """
-        if toctree.get('hidden', False):
+        if toctree.get('hidden', False) and not includehidden:
             return None
 
         def _walk_depth(node, depth, maxdepth):