Skip to content

Commit 2acf82b

Browse files
authored
fix: convert "stable" to actual version number (#1512)
* convert "stable" to actual version number * fix tests re: navigation_with_keys * try bumping autoapi
1 parent 36847fc commit 2acf82b

File tree

7 files changed

+66
-16
lines changed

7 files changed

+66
-16
lines changed

docs/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,21 @@
9999

100100
# Define the version we use for matching in the version switcher.
101101
version_match = os.environ.get("READTHEDOCS_VERSION")
102+
release = pydata_sphinx_theme.__version__
102103
# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
103104
# If it is an integer, we're in a PR build and the version isn't correct.
104105
# If it's "latest" → change to "dev" (that's what we want the switcher to call it)
105106
if not version_match or version_match.isdigit() or version_match == "latest":
106107
# For local development, infer the version to match from the package.
107-
release = pydata_sphinx_theme.__version__
108108
if "dev" in release or "rc" in release:
109109
version_match = "dev"
110110
# We want to keep the relative reference if we are in dev mode
111111
# but we want the whole url if we are effectively in a released version
112112
json_url = "_static/switcher.json"
113113
else:
114-
version_match = "v" + release
114+
version_match = f"v{release}"
115+
elif version_match == "stable":
116+
version_match = f"v{release}"
115117

116118
html_theme_options = {
117119
"external_links": [
@@ -181,6 +183,7 @@
181183
"json_url": json_url,
182184
"version_match": version_match,
183185
},
186+
"navigation_with_keys": False,
184187
# "search_bar_position": "navbar", # TODO: Deprecated - remove in future version
185188
}
186189

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ doc = [
5757
"rich",
5858
"sphinxext-rediraffe",
5959
"sphinx-sitemap",
60-
"sphinx-autoapi",
60+
"sphinx-autoapi>=3.0.0",
6161
# For examples section
6262
"ablog>=0.11.0rc2",
6363
"jupyter_sphinx",

tests/sites/base/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
html_sourcelink_suffix = ""
2121

2222
# Base options, we can add other key/vals later
23-
html_theme_options = {}
23+
html_theme_options = {"navigation_with_keys": False}
2424

2525
html_sidebars = {"section1/index": ["sidebar-nav-bs.html"]}

tests/sites/sidebars/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
# -- General configuration ---------------------------------------------------
1212

1313
html_theme = "pydata_sphinx_theme"
14+
15+
html_theme_options = {"navigation_with_keys": False}

tests/sites/test_included_toc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
# -- Options for HTML output -------------------------------------------------
1414

1515
html_theme = "pydata_sphinx_theme"
16+
17+
html_theme_options = {"navigation_with_keys": False}

tests/sites/test_navbar_no_in_page_headers/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414

1515
html_copy_source = True
1616
html_sourcelink_suffix = ""
17+
18+
html_theme_options = {"navigation_with_keys": False}

tests/test_build.py

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def test_toc_visibility(sphinx_build_factory) -> None:
4545
"""Test that setting TOC level visibility works as expected."""
4646
confoverrides = {
4747
"html_theme_options.show_toc_level": 2,
48+
"html_theme_options.navigation_with_keys": False,
4849
}
4950
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
5051
index_html = sphinx_build.html_tree("index.html")
@@ -57,6 +58,7 @@ def test_toc_visibility(sphinx_build_factory) -> None:
5758
def test_icon_links(sphinx_build_factory, file_regression) -> None:
5859
"""Test that setting icon links are rendered in the documentation."""
5960
html_theme_options_icon_links = {
61+
"navigation_with_keys": False,
6062
"icon_links": [
6163
{
6264
"name": "FONTAWESOME",
@@ -103,7 +105,7 @@ def test_icon_links(sphinx_build_factory, file_regression) -> None:
103105
"class": "overridden classes",
104106
},
105107
},
106-
]
108+
],
107109
}
108110
confoverrides = {"html_theme_options": html_theme_options_icon_links}
109111

@@ -125,6 +127,10 @@ def test_icon_links(sphinx_build_factory, file_regression) -> None:
125127
)
126128
def test_logo_alt_text(sphinx_build_factory, confoverrides, expected_alt_text) -> None:
127129
"""Test our alt-text fallback mechanism."""
130+
confoverrides["html_theme_options"] = (
131+
confoverrides.get("html_theme_options", False) or dict()
132+
)
133+
confoverrides["html_theme_options"].update({"navigation_with_keys": False})
128134
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
129135
index_html = sphinx_build.html_tree("index.html")
130136
logo_image = index_html.select(".navbar-brand img")[0]
@@ -144,7 +150,10 @@ def test_logo_basic(sphinx_build_factory) -> None:
144150

145151
def test_logo_no_image(sphinx_build_factory) -> None:
146152
"""Test that the text is shown if no image specified."""
147-
confoverrides = {"html_logo": ""}
153+
confoverrides = {
154+
"html_logo": "",
155+
"html_theme_options.navigation_with_keys": False,
156+
}
148157
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
149158
index_html = sphinx_build.html_tree("index.html")
150159
assert "PyData Tests" in index_html.select(".navbar-brand")[0].text.strip()
@@ -156,10 +165,11 @@ def test_logo_two_images(sphinx_build_factory) -> None:
156165
# Test with a specified title and a dark logo
157166
confoverrides = {
158167
"html_theme_options": {
168+
"navigation_with_keys": False,
159169
"logo": {
160170
"text": "Foo Title",
161171
"image_dark": "_static/emptydarklogo.png",
162-
}
172+
},
163173
},
164174
}
165175
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
@@ -175,6 +185,7 @@ def test_primary_logo_is_light_when_no_default_mode(sphinx_build_factory) -> Non
175185
# Ensure no default mode is set
176186
confoverrides = {
177187
"html_context": {},
188+
"html_theme_options.navigation_with_keys": False,
178189
}
179190
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
180191
index_html = sphinx_build.html_tree("index.html")
@@ -190,6 +201,7 @@ def test_primary_logo_is_light_when_default_mode_is_set_to_auto(
190201
# Ensure no default mode is set
191202
confoverrides = {
192203
"html_context": {"default_mode": "auto"},
204+
"html_theme_options.navigation_with_keys": False,
193205
}
194206
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
195207
index_html = sphinx_build.html_tree("index.html")
@@ -203,6 +215,7 @@ def test_primary_logo_is_light_when_default_mode_is_light(sphinx_build_factory)
203215
# Ensure no default mode is set
204216
confoverrides = {
205217
"html_context": {"default_mode": "light"},
218+
"html_theme_options.navigation_with_keys": False,
206219
}
207220
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
208221
index_html = sphinx_build.html_tree("index.html")
@@ -216,6 +229,7 @@ def test_primary_logo_is_dark_when_default_mode_is_dark(sphinx_build_factory) ->
216229
# Ensure no default mode is set
217230
confoverrides = {
218231
"html_context": {"default_mode": "dark"},
232+
"html_theme_options.navigation_with_keys": False,
219233
}
220234
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
221235
index_html = sphinx_build.html_tree("index.html")
@@ -229,10 +243,11 @@ def test_logo_missing_image(sphinx_build_factory) -> None:
229243
# Test with a specified title and a dark logo
230244
confoverrides = {
231245
"html_theme_options": {
246+
"navigation_with_keys": False,
232247
"logo": {
233248
# The logo is actually in _static
234249
"image_dark": "emptydarklogo.png",
235-
}
250+
},
236251
},
237252
}
238253
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build(
@@ -247,9 +262,10 @@ def test_logo_external_link(sphinx_build_factory) -> None:
247262
test_url = "https://secure.example.com"
248263
confoverrides = {
249264
"html_theme_options": {
265+
"navigation_with_keys": False,
250266
"logo": {
251267
"link": test_url,
252-
}
268+
},
253269
},
254270
}
255271
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
@@ -264,9 +280,10 @@ def test_logo_external_image(sphinx_build_factory) -> None:
264280
test_url = "https://pydata.org/wp-content/uploads/2019/06/pydata-logo-final.png"
265281
confoverrides = {
266282
"html_theme_options": {
283+
"navigation_with_keys": False,
267284
"logo": {
268285
"image_dark": test_url,
269-
}
286+
},
270287
},
271288
}
272289
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
@@ -280,9 +297,10 @@ def test_logo_template_rejected(sphinx_build_factory) -> None:
280297
# Test with a specified external logo image source
281298
confoverrides = {
282299
"html_theme_options": {
300+
"navigation_with_keys": False,
283301
"logo": {
284302
"image_dark": "image_dark_t",
285-
}
303+
},
286304
},
287305
}
288306
with pytest.raises(sphinx.errors.ExtensionError, match="static logo image"):
@@ -299,7 +317,10 @@ def test_logo_template_rejected(sphinx_build_factory) -> None:
299317
)
300318
def test_navbar_align(align, klass, sphinx_build_factory) -> None:
301319
"""The navbar items align with the proper part of the page."""
302-
confoverrides = {"html_theme_options.navbar_align": align}
320+
confoverrides = {
321+
"html_theme_options.navbar_align": align,
322+
"html_theme_options.navigation_with_keys": False,
323+
}
303324
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
304325
index_html = sphinx_build.html_tree("index.html")
305326
if klass[0]:
@@ -329,6 +350,7 @@ def test_navbar_header_dropdown(sphinx_build_factory, n_links) -> None:
329350

330351
confoverrides = {
331352
"html_theme_options": {
353+
"navigation_with_keys": False,
332354
"external_links": extra_links,
333355
"header_links_before_dropdown": n_links,
334356
}
@@ -355,13 +377,15 @@ def test_navbar_header_dropdown_button(sphinx_build_factory, dropdown_text) -> N
355377
if dropdown_text:
356378
confoverrides = {
357379
"html_theme_options": {
380+
"navigation_with_keys": False,
358381
"header_links_before_dropdown": 2,
359382
"header_dropdown_text": dropdown_text,
360383
}
361384
}
362385
else:
363386
confoverrides = {
364387
"html_theme_options": {
388+
"navigation_with_keys": False,
365389
"header_links_before_dropdown": 2,
366390
}
367391
}
@@ -401,7 +425,10 @@ def test_sidebars_nested_page(sphinx_build_factory, file_regression) -> None:
401425

402426
def test_sidebars_level2(sphinx_build_factory, file_regression) -> None:
403427
"""Test sidebars in a second-level page w/ children."""
404-
confoverrides = {"templates_path": ["_templates_sidebar_level2"]}
428+
confoverrides = {
429+
"templates_path": ["_templates_sidebar_level2"],
430+
"html_theme_options.navigation_with_keys": False,
431+
}
405432
sphinx_build = sphinx_build_factory("sidebars", confoverrides=confoverrides).build()
406433

407434
subindex_html = sphinx_build.html_tree("section1/subsection1/index.html")
@@ -416,7 +443,10 @@ def test_sidebars_show_nav_level0(sphinx_build_factory) -> None:
416443
417444
Testing both home page and a subsection page for correct elements.
418445
"""
419-
confoverrides = {"html_theme_options.show_nav_level": 0}
446+
confoverrides = {
447+
"html_theme_options.show_nav_level": 0,
448+
"html_theme_options.navigation_with_keys": False,
449+
}
420450
sphinx_build = sphinx_build_factory("sidebars", confoverrides=confoverrides).build()
421451

422452
# 1. Home Page
@@ -611,6 +641,7 @@ def test_footer(sphinx_build_factory) -> None:
611641
def test_edit_page_url(sphinx_build_factory, html_context, edit_text_and_url) -> None:
612642
"""Test the edit this page generated link."""
613643
confoverrides = {
644+
"html_theme_options.navigation_with_keys": False,
614645
"html_theme_options.use_edit_page_button": True,
615646
"html_context": html_context,
616647
}
@@ -659,6 +690,7 @@ def test_edit_page_url(sphinx_build_factory, html_context, edit_text_and_url) ->
659690
def test_analytics(sphinx_build_factory, provider, tags) -> None:
660691
"""Check the Google analytics."""
661692
confoverrides = provider
693+
confoverrides.update({"html_theme_options.navigation_with_keys": False})
662694
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides)
663695
sphinx_build.build()
664696
index_html = sphinx_build.html_tree("index.html")
@@ -674,10 +706,11 @@ def test_analytics(sphinx_build_factory, provider, tags) -> None:
674706
def test_plausible(sphinx_build_factory) -> None:
675707
"""Test the Plausible analytics."""
676708
provider = {
709+
"html_theme_options.navigation_with_keys": False,
677710
"html_theme_options.analytics": {
678711
"plausible_analytics_domain": "toto",
679712
"plausible_analytics_url": "http://.../script.js",
680-
}
713+
},
681714
}
682715
confoverrides = provider
683716
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides)
@@ -694,7 +727,10 @@ def test_plausible(sphinx_build_factory) -> None:
694727

695728
def test_show_nav_level(sphinx_build_factory) -> None:
696729
"""The navbar items align with the proper part of the page."""
697-
confoverrides = {"html_theme_options.show_nav_level": 2}
730+
confoverrides = {
731+
"html_theme_options.navigation_with_keys": False,
732+
"html_theme_options.show_nav_level": 2,
733+
}
698734
sphinx_build = sphinx_build_factory("sidebars", confoverrides=confoverrides).build()
699735

700736
# Both the column alignment and the margin should be changed
@@ -722,6 +758,7 @@ def test_version_switcher_error_states(
722758
"""
723759
confoverrides = {
724760
"html_theme_options": {
761+
"navigation_with_keys": False,
725762
"navbar_end": ["version-switcher"],
726763
"switcher": {
727764
"json_url": url,
@@ -799,6 +836,7 @@ def test_pygments_fallbacks(sphinx_build_factory, style_names, keyword_colors) -
799836
"""
800837
confoverrides = {
801838
"html_theme_options": {
839+
"navigation_with_keys": False,
802840
"pygment_light_style": style_names[0],
803841
"pygment_dark_style": style_names[1],
804842
},
@@ -845,6 +883,7 @@ def test_deprecated_build_html(sphinx_build_factory, file_regression) -> None:
845883
warnings = sphinx_build.warnings.strip("\n").split("\n")
846884
warnings = [w.lstrip("\x1b[91m").rstrip("\x1b[39;49;00m\n") for w in warnings]
847885
expected_warnings = (
886+
"The default value for `navigation_with_keys` will change",
848887
"The configuration `logo_text` is deprecated",
849888
"The configuration `favicons` is deprecated.",
850889
"`footer_items` is deprecated",
@@ -881,6 +920,7 @@ def test_empty_templates(sphinx_build_factory) -> None:
881920
# When configured to be gone, the template should be removed w/ its parent.
882921
# ABlog needs to be added so we can test that template rendering works w/ it.
883922
confoverrides = {
923+
"html_theme_options.navigation_with_keys": False,
884924
"html_show_sourcelink": False,
885925
}
886926
sphinx_build = sphinx_build_factory("base", confoverrides=confoverrides).build()
@@ -910,6 +950,7 @@ def test_translations(sphinx_build_factory) -> None:
910950
"github_version": "main",
911951
},
912952
"html_theme_options": {
953+
"navigation_with_keys": False,
913954
"use_edit_page_button": True,
914955
},
915956
}

0 commit comments

Comments
 (0)