Closes #1722. Restore `toctree()` template function behavior that was changed at 1.3b1.

This commit is contained in:
shimizukawa 2015-02-15 16:48:49 +09:00
parent 193aadb140
commit a9bcff7a26
2 changed files with 17 additions and 1 deletions

View File

@ -35,6 +35,7 @@ Bugs fixed
* bizstyle theme: nested long title pages make long breadcrumb that breaks page layout.
* bizstyle theme: all breadcrumb items become 'Top' on some mobile browser
(iPhone5s safari).
* #1722: restore ``toctree()`` template function behavior that was changed at 1.3b1.
Release 1.3b2 (released Dec 5, 2014)

View File

@ -1290,6 +1290,18 @@ class BuildEnvironment:
# recurse on visible children
self._toctree_prune(subnode, depth+1, maxdepth, collapse)
def get_toctree_ancestors(self, docname):
parent = {}
for p, children in iteritems(self.toctree_includes):
for child in children:
parent[child] = p
ancestors = []
d = docname
while d in parent:
ancestors.append(d)
d = parent[d]
return ancestors
def resolve_toctree(self, docname, builder, toctree, prune=True, maxdepth=0,
titles_only=False, collapse=False, includehidden=False):
"""Resolve a *toctree* node into individual bullet lists with titles
@ -1324,6 +1336,8 @@ class BuildEnvironment:
# The transformation is made in two passes in order to avoid
# interactions between marking and pruning the tree (see bug #1046).
toctree_ancestors = self.get_toctree_ancestors(docname)
def _toctree_add_classes(node, depth):
"""Add 'toctree-l%d' and 'current' classes to the toctree."""
for subnode in node.children:
@ -1394,7 +1408,8 @@ class BuildEnvironment:
refdoc = ref
toc = self.tocs[ref].deepcopy()
maxdepth = self.metadata[ref].get('tocdepth', 0)
self._toctree_prune(toc, 2, maxdepth, collapse)
if ref not in toctree_ancestors or (prune and maxdepth > 0):
self._toctree_prune(toc, 2, maxdepth, collapse)
self.process_only_nodes(toc, builder, ref)
if title and toc.children and len(toc.children) == 1:
child = toc.children[0]