Skip to content

Commit

Permalink
FIX: use parent when self is use in a toctree (#938)
Browse files Browse the repository at this point in the history
* FIX: use parent when self is use in a toctree

* typo in comments
  • Loading branch information
12rambau committed Sep 20, 2022
1 parent 9843963 commit d9b89c5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
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 using "self" use the correct link
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

0 comments on commit d9b89c5

Please sign in to comment.