Skip to content

Commit 074f21f

Browse files
authored
👌 Remove duplicate CSS hashing for sphinx >= 7.1 (#193)
Since sphinx v7.1, a checksum is already added to the CSS file URL, so hashing the content is no longer necessary (see sphinx-doc/sphinx#11415)
1 parent be1b85d commit 074f21f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sphinx_design/extension.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from docutils import nodes
55
from docutils.parsers.rst import directives
6+
from sphinx import version_info as sphinx_version
67
from sphinx.application import Sphinx
78
from sphinx.environment import BuildEnvironment
89
from sphinx.transforms import SphinxTransform
@@ -67,9 +68,14 @@ def update_css_js(app: Sphinx):
6768
js_path.write_text(content)
6869
# Read the css content and hash it
6970
content = read_text(static_module, "style.min.css")
70-
hash = hashlib.md5(content.encode("utf8")).hexdigest()
7171
# Write the css file
72-
css_path = static_path / f"design-style.{hash}.min.css"
72+
if sphinx_version < (7, 1):
73+
hash = hashlib.md5(content.encode("utf8")).hexdigest()
74+
css_path = static_path / f"sphinx-design.{hash}.min.css"
75+
else:
76+
# since sphinx 7.1 a checksum is added to the css file URL, so there is no need to do it here
77+
# https://github.com/sphinx-doc/sphinx/pull/11415
78+
css_path = static_path / "sphinx-design.min.css"
7379
app.add_css_file(css_path.name)
7480
if css_path.exists():
7581
return

0 commit comments

Comments
 (0)