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.
This commit is contained in:
Georg Brandl 2010-04-06 09:12:22 +02:00
parent 0f76788c57
commit 0ca72d4199
3 changed files with 21 additions and 6 deletions

View File

@ -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

View File

@ -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('<partial node>')
doc.append(node)
return publish_parts(

View File

@ -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):