Commits

michaeljones  committed f4cdcca

Respect "includehidden" for sub-toctrees as well

Previously, the includehidden method argument was only being taken into account
for top level toctrees. This meant that hidden subtree toctrees were still
being resolved if they exists below a non-hidden toctree.

  • Participants
  • Parent commits 47a94f7
  • Branches hiddentocs

Comments (0)

Files changed (1)

File sphinx/environment.py

                                 toplevel[1][:] = subtrees
                     # resolve all sub-toctrees
                     for toctreenode in toc.traverse(addnodes.toctree):
-                        i = toctreenode.parent.index(toctreenode) + 1
-                        for item in _entries_from_toctree(toctreenode,
-                                                          subtree=True):
-                            toctreenode.parent.insert(i, item)
-                            i += 1
-                        toctreenode.parent.remove(toctreenode)
+                        if not ( toctreenode.get('hidden', False) and not includehidden ):
+                            i = toctreenode.parent.index(toctreenode) + 1
+                            for item in _entries_from_toctree(toctreenode,
+                                                              subtree=True):
+                                toctreenode.parent.insert(i, item)
+                                i += 1
+                            toctreenode.parent.remove(toctreenode)
                     if separate:
                         entries.append(toc)
                     else:
                 if 'orphan' in self.metadata[docname]:
                     continue
                 self.warn(docname, 'document isn\'t included in any toctree')
+