Skip to content

Commit

Permalink
Fix version warning banner message (#1394)
Browse files Browse the repository at this point in the history
* don't rely on presence of DOCUMENTATION_OPTIONS.VERSION

* fix grammar
  • Loading branch information
drammock authored Jul 27, 2023
1 parent 9915a01 commit 66a826c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/pydata_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def _remove_empty_templates(tname):

# Add variables to our JavaScript for re-use in our main JS script
js = f"""
DOCUMENTATION_OPTIONS.theme_version = '{__version__}';
DOCUMENTATION_OPTIONS.theme_switcher_json_url = '{json_url}';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '{version_match}';
DOCUMENTATION_OPTIONS.show_version_warning_banner = {str(context["theme_show_version_warning_banner"]).lower()};
Expand Down
8 changes: 4 additions & 4 deletions src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function populateVersionSwitcher(data, versionSwitcherBtns) {
* @param {Array} data The version data used to populate the switcher menu.
*/
function showVersionWarningBanner(data) {
const version = DOCUMENTATION_OPTIONS.VERSION;
const version = DOCUMENTATION_OPTIONS.theme_version;
// figure out what latest stable version is
var preferredEntries = data.filter((entry) => entry.preferred);
if (preferredEntries.length !== 1) {
Expand Down Expand Up @@ -447,17 +447,17 @@ function showVersionWarningBanner(data) {
button.innerText = "Switch to stable version";
button.onclick = checkPageExistsAndRedirect;
// add the version-dependent text
inner.innerText = "This is documentation for an ";
inner.innerText = "This is documentation for ";
const isDev =
version.includes("dev") ||
version.includes("rc") ||
version.includes("pre");
const newerThanPreferred =
versionsAreComparable && compare(version, preferredVersion, ">");
if (isDev || newerThanPreferred) {
bold.innerText = "unstable development version";
bold.innerText = "an unstable development version";
} else if (versionsAreComparable && compare(version, preferredVersion, "<")) {
bold.innerText = `old version (${version})`;
bold.innerText = `an old version (${version})`;
} else {
bold.innerText = `version ${version}`;
}
Expand Down

0 comments on commit 66a826c

Please sign in to comment.