mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Don't swallow toc entries when resolving subtrees.
This commit is contained in:
parent
9fb011bd2a
commit
b016896c1c
5
CHANGES
5
CHANGES
@ -5,9 +5,14 @@ Changes in trunk
|
||||
It works like ``add_description_unit`` but the directive will only
|
||||
create a target and no output.
|
||||
|
||||
* sphinx.environment: Don't swallow TOC entries when resolving subtrees.
|
||||
|
||||
* sphinx.directives: Allow giving a different title to documents
|
||||
in the toctree.
|
||||
|
||||
* sphinx.builder, sphinx.environment: Gracefully handle some exception
|
||||
cases.
|
||||
|
||||
|
||||
Release 0.1.61950 (Mar 26, 2008)
|
||||
================================
|
||||
|
@ -7,7 +7,7 @@ Sphinx documentation contents
|
||||
:maxdepth: 2
|
||||
|
||||
intro
|
||||
Konzepte <concepts>
|
||||
concepts
|
||||
rest
|
||||
markup/index
|
||||
builders
|
||||
|
@ -703,7 +703,7 @@ class BuildEnvironment:
|
||||
self.resolve_references(doctree, docname, builder)
|
||||
|
||||
# now, resolve all toctree nodes
|
||||
def _entries_from_toctree(toctreenode):
|
||||
def _entries_from_toctree(toctreenode, separate=False):
|
||||
"""Return TOC entries for a toctree node."""
|
||||
includefiles = map(str, toctreenode['includefiles'])
|
||||
|
||||
@ -716,13 +716,18 @@ class BuildEnvironment:
|
||||
self.warn(docname, 'toctree contains ref to nonexisting '
|
||||
'file %r' % includefile)
|
||||
else:
|
||||
# resolve all sub-toctrees
|
||||
for toctreenode in toc.traverse(addnodes.toctree):
|
||||
toctreenode.parent.replace_self(
|
||||
_entries_from_toctree(toctreenode))
|
||||
entries.append(toc)
|
||||
if entries:
|
||||
return addnodes.compact_paragraph('', '', *entries)
|
||||
return []
|
||||
i = toctreenode.parent.index(toctreenode) + 1
|
||||
for item in _entries_from_toctree(toctreenode):
|
||||
toctreenode.parent.insert(i, item)
|
||||
i += 1
|
||||
toctreenode.parent.remove(toctreenode)
|
||||
if separate:
|
||||
entries.append(toc)
|
||||
else:
|
||||
entries.extend(toc.children)
|
||||
return entries
|
||||
|
||||
def _walk_depth(node, depth, maxdepth, titleoverrides):
|
||||
"""Utility: Cut a TOC at a specified depth."""
|
||||
@ -738,8 +743,9 @@ class BuildEnvironment:
|
||||
for toctreenode in doctree.traverse(addnodes.toctree):
|
||||
maxdepth = toctreenode.get('maxdepth', -1)
|
||||
titleoverrides = toctreenode.get('includetitles', {})
|
||||
newnode = _entries_from_toctree(toctreenode)
|
||||
if newnode is not None:
|
||||
tocentries = _entries_from_toctree(toctreenode, separate=True)
|
||||
if tocentries:
|
||||
newnode = addnodes.compact_paragraph('', '', *tocentries)
|
||||
# prune the tree to maxdepth and replace titles
|
||||
if maxdepth > 0:
|
||||
_walk_depth(newnode, 1, maxdepth, titleoverrides)
|
||||
|
Loading…
Reference in New Issue
Block a user