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

FIX: use parent when self is use in a toctree #938

Merged
merged 3 commits into from Sep 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/pydata_sphinx_theme/__init__.py
Expand Up @@ -247,9 +247,14 @@ def generate_header_nav_html(n_links_before_dropdown=5):
meth = "findall" if hasattr(root, "findall") else "traverse"
for toc in getattr(root, meth)(toctree_node):
for title, page in toc.attributes["entries"]:
# if the page is self use the coorect link
12rambau marked this conversation as resolved.
Show resolved Hide resolved
page = toc.attributes["parent"] if page == "self" else page

# If this is the active ancestor page, add a class so we highlight it
current = " current active" if page == active_header_page else ""
title = title if title else app.env.titles[page].astext()

# create the html output
links_html.append(
f"""
<li class="nav-item{current}">
Expand Down