Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add parameters navigation_startdepth and toc_caption_maxdepth #1241

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Improve compatibility with older versions of Sphinx
Use `_traverse_or_findall` function instead of assuming `findall` is present.
SimenZhor committed Mar 18, 2023
commit f160219a4dc23c63cfc59d44475bb6bc3421a4e0
8 changes: 4 additions & 4 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -939,7 +939,7 @@ def _entries_from_toctree(toctreenode: addnodes.toctree, parents: List[str],
process_only_nodes(toc, builder.tags)
if title and toc.children and len(toc.children) == 1:
child = toc.children[0]
for refnode in child.findall(nodes.reference):
for refnode in _traverse_or_findall(child, nodes.reference):
if refnode['refuri'] == ref and \
not refnode['anchorname']:
refnode.children = [nodes.Text(title)]
@@ -973,13 +973,13 @@ def _entries_from_toctree(toctreenode: addnodes.toctree, parents: List[str],
for toplevel in children:
# nodes with length 1 don't have any children anyway
if len(toplevel) > 1:
subtrees = list(toplevel.findall(addnodes.toctree))
subtrees = list(_traverse_or_findall(toplevel, addnodes.toctree))
if subtrees:
toplevel[1][:] = subtrees # type: ignore
else:
toplevel.pop(1)
# resolve all sub-toctrees
for subtocnode in list(toc.findall(addnodes.toctree)):
for subtocnode in list(_traverse_or_findall(toc, addnodes.toctree)):
if not (subtocnode.get('hidden', False) and
not includehidden):

@@ -1065,7 +1065,7 @@ def _add_toctree_captions(

# set the target paths in the toctrees (they are not known at TOC
# generation time)
for refnode in newnode.findall(nodes.reference):
for refnode in _traverse_or_findall(newnode, nodes.reference):
if not url_re.match(refnode['refuri']):
refnode['refuri'] = builder.get_relative_uri(
docname, refnode['refuri']) + refnode['anchorname']