Skip to content

Commit 66a826c

Browse files
authored
Fix version warning banner message (#1394)
* don't rely on presence of DOCUMENTATION_OPTIONS.VERSION * fix grammar
1 parent 9915a01 commit 66a826c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/pydata_sphinx_theme/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ def _remove_empty_templates(tname):
253253

254254
# Add variables to our JavaScript for re-use in our main JS script
255255
js = f"""
256+
DOCUMENTATION_OPTIONS.theme_version = '{__version__}';
256257
DOCUMENTATION_OPTIONS.theme_switcher_json_url = '{json_url}';
257258
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '{version_match}';
258259
DOCUMENTATION_OPTIONS.show_version_warning_banner = {str(context["theme_show_version_warning_banner"]).lower()};

src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ function populateVersionSwitcher(data, versionSwitcherBtns) {
415415
* @param {Array} data The version data used to populate the switcher menu.
416416
*/
417417
function showVersionWarningBanner(data) {
418-
const version = DOCUMENTATION_OPTIONS.VERSION;
418+
const version = DOCUMENTATION_OPTIONS.theme_version;
419419
// figure out what latest stable version is
420420
var preferredEntries = data.filter((entry) => entry.preferred);
421421
if (preferredEntries.length !== 1) {
@@ -447,17 +447,17 @@ function showVersionWarningBanner(data) {
447447
button.innerText = "Switch to stable version";
448448
button.onclick = checkPageExistsAndRedirect;
449449
// add the version-dependent text
450-
inner.innerText = "This is documentation for an ";
450+
inner.innerText = "This is documentation for ";
451451
const isDev =
452452
version.includes("dev") ||
453453
version.includes("rc") ||
454454
version.includes("pre");
455455
const newerThanPreferred =
456456
versionsAreComparable && compare(version, preferredVersion, ">");
457457
if (isDev || newerThanPreferred) {
458-
bold.innerText = "unstable development version";
458+
bold.innerText = "an unstable development version";
459459
} else if (versionsAreComparable && compare(version, preferredVersion, "<")) {
460-
bold.innerText = `old version (${version})`;
460+
bold.innerText = `an old version (${version})`;
461461
} else {
462462
bold.innerText = `version ${version}`;
463463
}

0 commit comments

Comments
 (0)