mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Move comment out of _walk_depth and add comment why the function was split
This commit is contained in:
parent
567671f4d8
commit
12baf34000
@ -1311,23 +1311,26 @@ class BuildEnvironment:
|
|||||||
if toctree.get('hidden', False) and not includehidden:
|
if toctree.get('hidden', False) and not includehidden:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# For reading the following two helper function, it is useful to keep
|
||||||
|
# in mind the node structure of a toctree (using HTML-like node names
|
||||||
|
# for brevity):
|
||||||
|
#
|
||||||
|
# <ul>
|
||||||
|
# <li>
|
||||||
|
# <p><a></p>
|
||||||
|
# <p><a></p>
|
||||||
|
# ...
|
||||||
|
# <ul>
|
||||||
|
# ...
|
||||||
|
# </ul>
|
||||||
|
# </li>
|
||||||
|
# </ul>
|
||||||
|
#
|
||||||
|
# The transformation is made in two passes in order to avoid
|
||||||
|
# interactions between marking and pruning the tree (see bug #1046).
|
||||||
|
|
||||||
def _walk_depth(node, depth, maxdepth):
|
def _walk_depth(node, depth, maxdepth):
|
||||||
"""Utility: Cut a TOC at a specified depth."""
|
"""Utility: Cut a TOC at a specified depth."""
|
||||||
|
|
||||||
# For reading this function, it is useful to keep in mind the node
|
|
||||||
# structure of a toctree (using HTML-like node names for brevity):
|
|
||||||
#
|
|
||||||
# <ul>
|
|
||||||
# <li>
|
|
||||||
# <p><a></p>
|
|
||||||
# <p><a></p>
|
|
||||||
# ...
|
|
||||||
# <ul>
|
|
||||||
# ...
|
|
||||||
# </ul>
|
|
||||||
# </li>
|
|
||||||
# </ul>
|
|
||||||
|
|
||||||
for subnode in node.children[:]:
|
for subnode in node.children[:]:
|
||||||
if isinstance(subnode, (addnodes.compact_paragraph,
|
if isinstance(subnode, (addnodes.compact_paragraph,
|
||||||
nodes.list_item)):
|
nodes.list_item)):
|
||||||
@ -1335,7 +1338,6 @@ class BuildEnvironment:
|
|||||||
# recurse to children
|
# recurse to children
|
||||||
subnode['classes'].append('toctree-l%d' % (depth-1))
|
subnode['classes'].append('toctree-l%d' % (depth-1))
|
||||||
_walk_depth(subnode, depth, maxdepth)
|
_walk_depth(subnode, depth, maxdepth)
|
||||||
|
|
||||||
elif isinstance(subnode, nodes.bullet_list):
|
elif isinstance(subnode, nodes.bullet_list):
|
||||||
# for <ul>, determine if the depth is too large or if the
|
# for <ul>, determine if the depth is too large or if the
|
||||||
# entry is to be collapsed
|
# entry is to be collapsed
|
||||||
|
Loading…
Reference in New Issue
Block a user