diff --git a/CHANGES b/CHANGES index 70fcabd89..dd87b705e 100644 --- a/CHANGES +++ b/CHANGES @@ -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) diff --git a/sphinx/environment.py b/sphinx/environment.py index e07b5e1c8..535d714cf 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -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]