Skip to content

Commit

Permalink
enable pydata_sphinx_theme version banner (#13901)
Browse files Browse the repository at this point in the history
* enable pydata_sphinx_theme version banner

* add env var BOKEH_DOCS_VERSION to cons.py

* remove version 3.4.0 from switcher.json
  • Loading branch information
mosc9575 committed May 17, 2024
1 parent d08906b commit e8caa13
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 47 deletions.
1 change: 0 additions & 1 deletion docs/bokeh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ clean:
-rm -rf source/docs/gallery/*
-rm -rf source/docs/examples/*

# XXX -W was removed due to issue https://github.com/bokeh/bokeh/issues/13156
html:
@start=$$(date +%s) \
; sphinx-build -W -b html -d $(BUILDDIR)/doctrees $(SPHINXOPTS) source $(BUILDDIR)/html \
Expand Down
8 changes: 4 additions & 4 deletions docs/bokeh/docserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
python docserver.py
or more commonly via executing ``make serve`` in this directory. It is possible
to combine this usage with other make targets in a single invovation, e.g.
to combine this usage with other make targets in a single invocation, e.g.
make clean html serve
Expand All @@ -34,7 +34,7 @@
from pathlib import Path

import flask
from flask import redirect, url_for
from flask import redirect
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer
Expand All @@ -52,12 +52,12 @@

@app.route("/")
def root():
return redirect(url_for("en/latest/index.html"))
return redirect("en/latest/index.html")


@app.route("/switcher.json")
def switcher():
return flask.send_from_directory(SPHINX_TOP, "switcher.json")
return flask.send_from_directory(SPHINX_TOP / "build" / "html" / "_static", "switcher.json")


@app.route("/en/latest/<path:filename>")
Expand Down
18 changes: 0 additions & 18 deletions docs/bokeh/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,6 @@ img.image-border {
.bd-footer .btn-primary { filter: brightness(90%); background-color: #C02942; border-color: #C02942; }
.bd-footer .btn-primary:hover { filter: brightness(100%); background-color: #C02942; border-color: #C02942; }

/* CSS for our custom version warning banner */
.version-alert a {
text-decoration: underline;
color: #ddd;
}

#banner .version-alert {
background-color: #CF462A;
padding: 1em;
color: #fff;
font-weight: 600; font-size: 16px;
}

.version-alert a {
text-decoration: underline;
color: #ddd;
}

/* CSS for our custom gallery */
div.bk-gallery {
width: 100%;
Expand Down
18 changes: 0 additions & 18 deletions docs/bokeh/source/_static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,3 @@ window.addEventListener('DOMContentLoaded', function () {
});
}
})

// Display a version warning banner if necessary
$(document).ready(function () {
const randid = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
$.getJSON('/switcher.json?v=' + randid , function (data) {
// old versions have a unified latest/x.y.z, things are split starting with 3.0
if (BOKEH_CURRENT_VERSION != data[1].version) {
let msg
if (data.findIndex((elt) => elt.version == BOKEH_CURRENT_VERSION) < 0 ) {
msg = "DEVELOPMENT / PRE-RELEASE"
} else {
msg = "PREVIOUS RELEASE"
}
const content = $('<div class="version-alert">This page is documentation for a ' + msg + ' version. For the latest release, go to <a href="https://docs.bokeh.org/en/latest/">https://docs.bokeh.org/en/latest/</a></div>')
$('#banner').append(content);
}
})
})
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[
{
"name": "latest",
"url": "https://docs.bokeh.org/en/latest/"
},
{
"version": "3.4.0",
"url": "https://docs.bokeh.org/en/3.4.0/"
"version": "3.4.1",
"url": "https://docs.bokeh.org/en/latest/",
"preferred": true
},
{
"version": "3.3.0",
Expand All @@ -25,6 +23,7 @@
},
{
"name": "dev (3.5)",
"version": "dev-3.5",
"url": "https://docs.bokeh.org/en/dev-3.5/"
}
]
9 changes: 8 additions & 1 deletion docs/bokeh/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@

html_title = f"{project} {version} Documentation"

# avoid CORS error on local docs build for the switcher.json file
if "BOKEH_DOCS_VERSION" in os.environ:
json_url = "https://docs.bokeh.org/switcher.json"
else:
json_url = "_static/switcher.json"

# html_logo configured in navbar-logo.html

html_theme_options = {
Expand All @@ -189,10 +195,11 @@
"show_nav_level": 2,
"show_toc_level": 1,
"switcher": {
"json_url": "https://docs.bokeh.org/switcher.json",
"json_url": json_url,
"version_match": version,
},
"use_edit_page_button": False,
"show_version_warning_banner": True,
"header_links_before_dropdown": 8,
}

Expand Down

0 comments on commit e8caa13

Please sign in to comment.