mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Change html_collapse_toctree setting to an argument of the toctree() callable.
This commit is contained in:
parent
ddeeccd5c2
commit
d5ea00899c
7
CHANGES
7
CHANGES
@ -55,7 +55,9 @@ New features added
|
|||||||
and ``staticmethod``.
|
and ``staticmethod``.
|
||||||
|
|
||||||
- Added a ``toctree`` callable to the templates, and the ability
|
- 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:
|
* Configuration:
|
||||||
|
|
||||||
@ -70,9 +72,6 @@ New features added
|
|||||||
- The new ``html_show_sourcelink`` config value can be used to
|
- The new ``html_show_sourcelink`` config value can be used to
|
||||||
switch off the links to the reST sources in the sidebar.
|
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
|
- The default value for ``htmlhelp_basename`` is now the project
|
||||||
title, cleaned up as a filename.
|
title, cleaned up as a filename.
|
||||||
|
|
||||||
|
@ -515,14 +515,6 @@ that use Sphinx' HTMLWriter class.
|
|||||||
|
|
||||||
.. versionadded:: 0.4
|
.. 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
|
.. confval:: htmlhelp_basename
|
||||||
|
|
||||||
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
Output file base name for HTML help builder. Default is ``'pydoc'``.
|
||||||
|
@ -364,4 +364,5 @@ are in HTML form), these variables are also available:
|
|||||||
.. data:: toctree
|
.. data:: toctree
|
||||||
|
|
||||||
A callable yielding the global TOC tree containing the current page, rendered
|
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.
|
||||||
|
@ -184,10 +184,6 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
self.theme.get_options(self.config.html_theme_options).iteritems())
|
self.theme.get_options(self.config.html_theme_options).iteritems())
|
||||||
self.globalcontext.update(self.config.html_context)
|
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):
|
def get_doc_context(self, docname, body, metatags):
|
||||||
"""Collect items for the template context of a page."""
|
"""Collect items for the template context of a page."""
|
||||||
# find out relations
|
# find out relations
|
||||||
@ -535,6 +531,10 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
if self.indexer is not None and title:
|
if self.indexer is not None and title:
|
||||||
self.indexer.feed(pagename, title, doctree)
|
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
|
# --------- these are overwritten by the serialization builder
|
||||||
|
|
||||||
def get_target_uri(self, docname, typ=None):
|
def get_target_uri(self, docname, typ=None):
|
||||||
@ -554,7 +554,7 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
ctx['pathto'] = pathto
|
ctx['pathto'] = pathto
|
||||||
ctx['hasdoc'] = lambda name: name in self.env.all_docs
|
ctx['hasdoc'] = lambda name: name in self.env.all_docs
|
||||||
ctx['customsidebar'] = self.config.html_sidebars.get(pagename)
|
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)
|
ctx.update(addctx)
|
||||||
|
|
||||||
self.app.emit('html-page-context', pagename, templatename,
|
self.app.emit('html-page-context', pagename, templatename,
|
||||||
|
@ -72,7 +72,6 @@ class Config(object):
|
|||||||
html_use_smartypants = (True, False),
|
html_use_smartypants = (True, False),
|
||||||
html_translator_class = (None, False),
|
html_translator_class = (None, False),
|
||||||
html_sidebars = ({}, False),
|
html_sidebars = ({}, False),
|
||||||
html_collapse_toctree = (False, False),
|
|
||||||
html_additional_pages = ({}, False),
|
html_additional_pages = ({}, False),
|
||||||
html_use_modindex = (True, False),
|
html_use_modindex = (True, False),
|
||||||
html_add_permalinks = (True, False),
|
html_add_permalinks = (True, False),
|
||||||
|
Loading…
Reference in New Issue
Block a user