Change html_collapse_toctree setting to an argument of the toctree() callable.

This commit is contained in:
Georg Brandl 2009-02-16 00:08:08 +01:00
parent ddeeccd5c2
commit d5ea00899c
5 changed files with 10 additions and 19 deletions

View File

@ -55,7 +55,9 @@ New features added
and ``staticmethod``.
- Added a ``toctree`` callable to the templates, and the ability
to include external links in toctrees.
to include external links in toctrees. The 'collapse' keyword argument
indicates whether or not to only display subitems of the current page.
(Defaults to True.)
* Configuration:
@ -70,9 +72,6 @@ New features added
- The new ``html_show_sourcelink`` config value can be used to
switch off the links to the reST sources in the sidebar.
- The new ``html_collapse_toctree`` config value can be used to
"collapse" the generated toctree given to the templates.
- The default value for ``htmlhelp_basename`` is now the project
title, cleaned up as a filename.

View File

@ -515,14 +515,6 @@ that use Sphinx' HTMLWriter class.
.. versionadded:: 0.4
.. confval:: html_collapse_toctree
If true, the toctree given to the templates as ``toctree`` will be collapsed,
i.e. only the subitems that contain the current page are visible. Default is
``False``.
.. versionadded:: 0.6
.. confval:: htmlhelp_basename
Output file base name for HTML help builder. Default is ``'pydoc'``.

View File

@ -364,4 +364,5 @@ are in HTML form), these variables are also available:
.. data:: toctree
A callable yielding the global TOC tree containing the current page, rendered
as HTML bullet lists.
as HTML bullet lists. If the optional keyword argument ``collapse`` is true,
all TOC entries that are not ancestors of the current page are collapsed.

View File

@ -184,10 +184,6 @@ class StandaloneHTMLBuilder(Builder):
self.theme.get_options(self.config.html_theme_options).iteritems())
self.globalcontext.update(self.config.html_context)
def _get_local_toctree(self, docname):
return self.render_partial(self.env.get_toctree_for(
docname, self, self.config.html_collapse_toctree))['fragment']
def get_doc_context(self, docname, body, metatags):
"""Collect items for the template context of a page."""
# find out relations
@ -535,6 +531,10 @@ class StandaloneHTMLBuilder(Builder):
if self.indexer is not None and title:
self.indexer.feed(pagename, title, doctree)
def _get_local_toctree(self, docname, collapse=True):
return self.render_partial(self.env.get_toctree_for(
docname, self, collapse))['fragment']
# --------- these are overwritten by the serialization builder
def get_target_uri(self, docname, typ=None):
@ -554,7 +554,7 @@ class StandaloneHTMLBuilder(Builder):
ctx['pathto'] = pathto
ctx['hasdoc'] = lambda name: name in self.env.all_docs
ctx['customsidebar'] = self.config.html_sidebars.get(pagename)
ctx['toctree'] = lambda: self._get_local_toctree(pagename)
ctx['toctree'] = lambda **kw: self._get_local_toctree(pagename, **kw)
ctx.update(addctx)
self.app.emit('html-page-context', pagename, templatename,

View File

@ -72,7 +72,6 @@ class Config(object):
html_use_smartypants = (True, False),
html_translator_class = (None, False),
html_sidebars = ({}, False),
html_collapse_toctree = (False, False),
html_additional_pages = ({}, False),
html_use_modindex = (True, False),
html_add_permalinks = (True, False),