mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix the handling of multiple toctrees when creating the global TOC for the `toctree()
` template function.
Fix the handling of hidden toctrees when creating the global TOC for the ``toctree()`` template function.
This commit is contained in:
parent
0f76788c57
commit
0ca72d4199
6
CHANGES
6
CHANGES
@ -1,6 +1,12 @@
|
|||||||
Release 0.6.6 (in development)
|
Release 0.6.6 (in development)
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
* Fix the handling of multiple toctrees when creating the global
|
||||||
|
TOC for the ``toctree()`` template function.
|
||||||
|
|
||||||
|
* Fix the handling of hidden toctrees when creating the global TOC
|
||||||
|
for the ``toctree()`` template function.
|
||||||
|
|
||||||
* Fix the handling of nested lists in the text writer.
|
* Fix the handling of nested lists in the text writer.
|
||||||
|
|
||||||
* #362: In autodoc, check for the existence of ``__self__`` on
|
* #362: In autodoc, check for the existence of ``__self__`` on
|
||||||
|
@ -177,6 +177,8 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
|
|
||||||
def render_partial(self, node):
|
def render_partial(self, node):
|
||||||
"""Utility: Render a lone doctree node."""
|
"""Utility: Render a lone doctree node."""
|
||||||
|
if node is None:
|
||||||
|
return {'fragment': ''}
|
||||||
doc = new_document('<partial node>')
|
doc = new_document('<partial node>')
|
||||||
doc.append(node)
|
doc.append(node)
|
||||||
return publish_parts(
|
return publish_parts(
|
||||||
|
@ -936,11 +936,18 @@ class BuildEnvironment:
|
|||||||
def get_toctree_for(self, docname, builder, collapse):
|
def get_toctree_for(self, docname, builder, collapse):
|
||||||
"""Return the global TOC nodetree."""
|
"""Return the global TOC nodetree."""
|
||||||
doctree = self.get_doctree(self.config.master_doc)
|
doctree = self.get_doctree(self.config.master_doc)
|
||||||
|
toctrees = []
|
||||||
for toctreenode in doctree.traverse(addnodes.toctree):
|
for toctreenode in doctree.traverse(addnodes.toctree):
|
||||||
result = self.resolve_toctree(docname, builder, toctreenode,
|
toctree = self.resolve_toctree(docname, builder, toctreenode,
|
||||||
prune=True, collapse=collapse)
|
prune=True, collapse=collapse,
|
||||||
if result is not None:
|
includehidden=True)
|
||||||
return result
|
toctrees.append(toctree)
|
||||||
|
if not toctrees:
|
||||||
|
return None
|
||||||
|
result = toctrees[0]
|
||||||
|
for toctree in toctrees[1:]:
|
||||||
|
result.extend(toctree.children)
|
||||||
|
return result
|
||||||
|
|
||||||
# -------
|
# -------
|
||||||
# these are called from docutils directives and therefore use self.docname
|
# these are called from docutils directives and therefore use self.docname
|
||||||
@ -1011,7 +1018,7 @@ class BuildEnvironment:
|
|||||||
return doctree
|
return doctree
|
||||||
|
|
||||||
def resolve_toctree(self, docname, builder, toctree, prune=True, maxdepth=0,
|
def resolve_toctree(self, docname, builder, toctree, prune=True, maxdepth=0,
|
||||||
titles_only=False, collapse=False):
|
titles_only=False, collapse=False, includehidden=False):
|
||||||
"""
|
"""
|
||||||
Resolve a *toctree* node into individual bullet lists with titles
|
Resolve a *toctree* node into individual bullet lists with titles
|
||||||
as items, returning None (if no containing titles are found) or
|
as items, returning None (if no containing titles are found) or
|
||||||
@ -1024,7 +1031,7 @@ class BuildEnvironment:
|
|||||||
If *collapse* is True, all branches not containing docname will
|
If *collapse* is True, all branches not containing docname will
|
||||||
be collapsed.
|
be collapsed.
|
||||||
"""
|
"""
|
||||||
if toctree.get('hidden', False):
|
if toctree.get('hidden', False) and not includehidden:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _walk_depth(node, depth, maxdepth):
|
def _walk_depth(node, depth, maxdepth):
|
||||||
|
Loading…
Reference in New Issue
Block a user