Skip to content

Commit

Permalink
FIX: set bd-docs-nav as a class attribute instead of an id to restore…
Browse files Browse the repository at this point in the history
… compat with pydata-sphinx-theme JS (#754)
  • Loading branch information
ogrisel authored Oct 10, 2023
1 parent d613696 commit aca0f7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="bd-links" id="bd-docs-nav" aria-label="Main">
<nav class="bd-links bd-docs-nav" aria-label="Main">
<div class="bd-toc-item navbar-nav active">
{% if theme_home_page_in_toc == True %}
{#- This mimicks the pydata theme list style so we can append an extra item at the top #}
Expand Down
8 changes: 5 additions & 3 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_build_book(sphinx_build_factory, file_regression):
# Navigation entries
if sphinx_build.software_versions == ".sphinx4":
# Sphinx 4 adds some aria labeling that isn't in sphinx3, so just test sphinx4
sidebar = index_html.find(attrs={"id": "bd-docs-nav"})
sidebar = index_html.find(attrs={"class": "bd-docs-nav"})
file_regression.check(
sidebar.prettify(),
basename="build__sidebar-primary__nav",
Expand All @@ -101,7 +101,7 @@ def test_build_book(sphinx_build_factory, file_regression):

# Check navbar numbering
sidebar_ntbk = sphinx_build.html_tree("section1", "ntbk.html").find(
"nav", id="bd-docs-nav"
"nav", attrs={"class": "bd-docs-nav"}
)
# Pages and sub-pages should be numbered
assert "1. Page 1" in str(sidebar_ntbk)
Expand Down Expand Up @@ -146,7 +146,9 @@ def test_navbar_options_home_page_in_toc(sphinx_build_factory):
).build(
assert_pass=True
) # type: SphinxBuild
navbar = sphinx_build.html_tree("index.html").find("nav", id="bd-docs-nav")
navbar = sphinx_build.html_tree("index.html").find(
"nav", attrs={"class": "bd-docs-nav"}
)
# double checks if the master_doc has the current class
li = navbar.find("li", attrs={"class": "current"})
assert "Index with code in title" in str(li)
Expand Down

0 comments on commit aca0f7f

Please sign in to comment.