From 50fadb9e94078e38fa9b3d2974171cd6397bc31a Mon Sep 17 00:00:00 2001 From: Roland Meister Date: Mon, 10 Dec 2012 21:54:11 +0100 Subject: [PATCH 01/29] Bug #1047: templating toctree()'s includehidden argument Document the includehidden option and give it sane defaults. See bug #1047 for implementation alternatives. --- doc/templating.rst | 3 +++ sphinx/builders/html.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/doc/templating.rst b/doc/templating.rst index 05a1346c0..b9dfc683b 100644 --- a/doc/templating.rst +++ b/doc/templating.rst @@ -391,3 +391,6 @@ are in HTML form), these variables are also available: * ``titles_only`` (false by default): if true, put only toplevel document titles in the tree + + * ``includehidden`` (false by default): if true, the TOC tree will also + contain hidden entries. diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index f5218673f..7fa42057f 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -653,6 +653,8 @@ class StandaloneHTMLBuilder(Builder): self.indexer.feed(pagename, title, doctree) def _get_local_toctree(self, docname, collapse=True, **kwds): + if 'includehidden' not in kwds: + kwds['includehidden'] = False return self.render_partial(self.env.get_toctree_for( docname, self, collapse, **kwds))['fragment'] From 567671f4d84f22c8528a098db431c4d36323c808 Mon Sep 17 00:00:00 2001 From: Roland Meister Date: Mon, 10 Dec 2012 22:01:01 +0100 Subject: [PATCH 02/29] Bug #1046: templating toctree() does not expand to maxdepth past maxdepth If the current page is nested larger than maxdepth it gets deleted before it can be marked as current. The toctree then callapses to the top entries. Split _walk_depth in two parts, first just add the current tag, and remove unneeded entries in a second call. --- sphinx/environment.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sphinx/environment.py b/sphinx/environment.py index cada082d7..69dcdf7de 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1342,18 +1342,22 @@ class BuildEnvironment: if maxdepth > 0 and depth > maxdepth: subnode.parent.replace(subnode, []) else: - # to find out what to collapse, *first* walk subitems, - # since that determines which children point to the - # current page + # recurse on children _walk_depth(subnode, depth+1, maxdepth) # cull sub-entries whose parents aren't 'current' if (collapse and depth > 1 and 'iscurrent' not in subnode.parent): subnode.parent.remove(subnode) + def _mark_current(node): + """Mark current page and its parents with the 'current' class.""" + for subnode in node.children[:]: + if isinstance(subnode, (addnodes.compact_paragraph, + nodes.list_item, nodes.bullet_list)): + # for

,

  • and