Skip to content

Commit e3ef253

Browse files
authored
Merge pull request #127 from AA-Turner/sphinx-5-fixup
2 parents aaca238 + d39c311 commit e3ef253

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

python_docs_theme/static/sidebar.js python_docs_theme/static/sidebar.js_t

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ const initialiseSidebar = () => {
3636
return
3737
}
3838

39+
{# Check if we need to dynamically insert the sidebar button.
40+
# We prefer the ``sphinx_version_tuple`` variable, and if it is undefined we
41+
# know we are running a Sphinx version older than 4.2.
42+
#
43+
# See: https://www.sphinx-doc.org/en/master/development/templating.html#sphinx_version_tuple
44+
#}
45+
{% if sphinx_version_tuple is defined and sphinx_version_tuple[0] >= 5 %}
46+
const sidebarButton = document.getElementById("sidebarbutton")
47+
const sidebarArrow = sidebarButton.querySelector('span')
48+
{% else %}
3949
// create the sidebar button element
4050
const sidebarButton = document.createElement("div")
4151
sidebarButton.id = "sidebarbutton"
@@ -44,6 +54,7 @@ const initialiseSidebar = () => {
4454
sidebarArrow.innerText = "«"
4555
sidebarButton.appendChild(sidebarArrow)
4656
sidebar.appendChild(sidebarButton)
57+
{% endif %}
4758

4859
const collapse_sidebar = () => {
4960
bodyWrapper.style.marginLeft = ".8em"

0 commit comments

Comments
 (0)