Skip to content

Commit

Permalink
ENH: Make hidden toctrees append their content after everything else …
Browse files Browse the repository at this point in the history
…in their section

This fixes the problem reported at:
http://stackoverflow.com/q/25276415/102441
http://stackoverflow.com/q/39110429/102441
  • Loading branch information
eric-wieser committed Feb 23, 2020
1 parent 26fc526 commit ac2571c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sphinx/environment/adapters/toctree.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,14 @@ def _entries_from_toctree(toctreenode: addnodes.toctree, parents: List[str],
toplevel.pop(1)
# resolve all sub-toctrees
for subtocnode in toc.traverse(addnodes.toctree):
if not (subtocnode.get('hidden', False) and
not includehidden):
i = subtocnode.parent.index(subtocnode) + 1
is_hidden = subtocnode.get('hidden', False)
if includehidden or not is_hidden:
if is_hidden:
# hidden entries always go last
i = len(subtocnode.parent)
else:
# visible entries go after the toctree
i = subtocnode.parent.index(subtocnode) + 1
for entry in _entries_from_toctree(
subtocnode, [refdoc] + parents,
subtree=True):
Expand Down

0 comments on commit ac2571c

Please sign in to comment.