diff --git a/CHANGES b/CHANGES index 3b046e980..e6def50b0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ 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 diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 04f070707..306184a3d 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -177,6 +177,8 @@ class StandaloneHTMLBuilder(Builder): def render_partial(self, node): """Utility: Render a lone doctree node.""" + if node is None: + return {'fragment': ''} doc = new_document('') doc.append(node) return publish_parts( diff --git a/sphinx/environment.py b/sphinx/environment.py index a3eecbcb2..257768484 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -936,11 +936,18 @@ class BuildEnvironment: 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 @@ -1011,7 +1018,7 @@ class BuildEnvironment: 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 @@ -1024,7 +1031,7 @@ class BuildEnvironment: 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):