Skip to content

Commit ab2722e

Browse files
committed
Bump minimum Sphinx version to 7.1
This allows us to drop the manual cache busting procedure.
1 parent f8fa06b commit ab2722e

File tree

2 files changed

+1
-62
lines changed

2 files changed

+1
-62
lines changed

docs/conf.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import datetime
22
import subprocess
3-
from urllib.parse import urlsplit, urlunsplit
43

54
# -- Project information -----------------------------------------------------
65

@@ -32,61 +31,8 @@
3231
# This pattern also affects html_static_path and html_extra_path.
3332
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3433

35-
# General substitutions.
36-
try:
37-
SHA = subprocess.check_output(
38-
['git', 'rev-parse', 'HEAD']).decode('utf-8').strip()
39-
# Catch the case where git is not installed locally, and use the setuptools_scm
40-
# version number instead.
41-
except (subprocess.CalledProcessError, FileNotFoundError):
42-
import hashlib
43-
import matplotlib
44-
import mpl_sphinx_theme
45-
import pydata_sphinx_theme
46-
SHA = hashlib.sha256(
47-
(f'{matplotlib.__version__} '
48-
f'{mpl_sphinx_theme.__version__} '
49-
f'{pydata_sphinx_theme.__version__}').encode('utf-8')).hexdigest()
50-
SHA = SHA[:20]
51-
52-
5334
# -- Options for HTML output -------------------------------------------------
5435

55-
def add_html_cache_busting(app, pagename, templatename, context, doctree):
56-
"""
57-
Add cache busting query on CSS and JavaScript assets.
58-
59-
This adds the Matplotlib version as a query to the link reference in the
60-
HTML, if the path is not absolute (i.e., it comes from the `_static`
61-
directory) and doesn't already have a query.
62-
"""
63-
from sphinx.builders.html import Stylesheet, JavaScript
64-
65-
css_tag = context['css_tag']
66-
js_tag = context['js_tag']
67-
68-
def css_tag_with_cache_busting(css):
69-
if isinstance(css, Stylesheet) and css.filename is not None:
70-
url = urlsplit(css.filename)
71-
if not url.netloc and not url.query:
72-
url = url._replace(query=SHA)
73-
css = Stylesheet(urlunsplit(url), priority=css.priority,
74-
**css.attributes)
75-
return css_tag(css)
76-
77-
def js_tag_with_cache_busting(js):
78-
if isinstance(js, JavaScript) and js.filename is not None:
79-
url = urlsplit(js.filename)
80-
if not url.netloc and not url.query:
81-
url = url._replace(query=SHA)
82-
js = JavaScript(urlunsplit(url), priority=js.priority,
83-
**js.attributes)
84-
return js_tag(js)
85-
86-
context['css_tag'] = css_tag_with_cache_busting
87-
context['js_tag'] = js_tag_with_cache_busting
88-
89-
9036
html_css_files = ['css/normalize.css', 'css/landing.css']
9137
html_theme = "mpl_sphinx_theme"
9238
html_favicon = "_static/favicon.ico"
@@ -103,10 +49,3 @@ def js_tag_with_cache_busting(js):
10349

10450
# Prefix added to all the URLs generated in the 404 page.
10551
notfound_urls_prefix = '/'
106-
107-
108-
# -----------------------------------------------------------------------------
109-
# Sphinx setup
110-
# -----------------------------------------------------------------------------
111-
def setup(app):
112-
app.connect('html-page-context', add_html_cache_busting, priority=1000)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ jinja2>3
22
mpl-sphinx-theme~=3.7.1
33
pydata-sphinx-theme~=0.13.0
44
pygments>=2.7
5-
sphinx
5+
sphinx>=7.1
66
sphinx-notfound-page

0 commit comments

Comments
 (0)