From 397af18fc2344caa186df709085759f1a5f575db Mon Sep 17 00:00:00 2001 From: "Putnam, Kevin" Date: Tue, 3 Jun 2025 09:04:06 -0700 Subject: [PATCH 1/3] Limit copying _sphinx_design_static to HTML based builders Signed-off-by: Putnam, Kevin --- sphinx_design/extension.py | 60 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index 9dd5f28..3d79328 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -80,35 +80,37 @@ def update_css_js(app: Sphinx): """Copy the CSS to the build directory.""" # reset changed identifier app.env.sphinx_design_css_changed = False - # setup up new static path in output dir - static_path = (Path(app.outdir) / "_sphinx_design_static").absolute() - static_existed = static_path.exists() - static_path.mkdir(exist_ok=True) - app.config.html_static_path.append(str(static_path)) - # Copy JS to the build directory. - js_path = static_path / "design-tabs.js" - app.add_js_file(js_path.name) - if not js_path.exists(): - content = read_text(static_module, "sd_tabs.js") - js_path.write_text(content) - # Read the css content and hash it - content = read_text(static_module, "style.min.css") - # Write the css file - if sphinx_version < (7, 1): - hash = hashlib.md5(content.encode("utf8"), usedforsecurity=False).hexdigest() - css_path = static_path / f"sphinx-design.{hash}.min.css" - else: - # since sphinx 7.1 a checksum is added to the css file URL, so there is no need to do it here - # https://github.com/sphinx-doc/sphinx/pull/11415 - css_path = static_path / "sphinx-design.min.css" - app.add_css_file(css_path.name) - if css_path.exists(): - return - if static_existed: - app.env.sphinx_design_css_changed = True - for path in static_path.glob("*.css"): - path.unlink() - css_path.write_text(content, encoding="utf8") + # only do this for html builders + if 'html' in app.builder.name: + # setup up new static path in output dir + static_path = (Path(app.outdir) / "_sphinx_design_static").absolute() + static_existed = static_path.exists() + static_path.mkdir(exist_ok=True) + app.config.html_static_path.append(str(static_path)) + # Copy JS to the build directory. + js_path = static_path / "design-tabs.js" + app.add_js_file(js_path.name) + if not js_path.exists(): + content = read_text(static_module, "sd_tabs.js") + js_path.write_text(content) + # Read the css content and hash it + content = read_text(static_module, "style.min.css") + # Write the css file + if sphinx_version < (7, 1): + hash = hashlib.md5(content.encode("utf8"), usedforsecurity=False).hexdigest() + css_path = static_path / f"sphinx-design.{hash}.min.css" + else: + # since sphinx 7.1 a checksum is added to the css file URL, so there is no need to do it here + # https://github.com/sphinx-doc/sphinx/pull/11415 + css_path = static_path / "sphinx-design.min.css" + app.add_css_file(css_path.name) + if css_path.exists(): + return + if static_existed: + app.env.sphinx_design_css_changed = True + for path in static_path.glob("*.css"): + path.unlink() + css_path.write_text(content, encoding="utf8") def update_css_links(app: Sphinx, env: BuildEnvironment): From fc935afab242610a805921e4feff51c884435690 Mon Sep 17 00:00:00 2001 From: "Putnam, Kevin" Date: Tue, 3 Jun 2025 09:24:43 -0700 Subject: [PATCH 2/3] Fixes missing required RTD configuration key per PR #237 Signed-off-by: Putnam, Kevin --- .readthedocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.readthedocs.yml b/.readthedocs.yml index 929b95b..1495af7 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -13,5 +13,6 @@ python: - rtd sphinx: + configuration: docs/conf.py builder: html fail_on_warning: true From ba85f2745cb7d4d1ae465686145a59fc6f4b0d32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 16:34:01 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sphinx_design/extension.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sphinx_design/extension.py b/sphinx_design/extension.py index 3d79328..8598b3b 100644 --- a/sphinx_design/extension.py +++ b/sphinx_design/extension.py @@ -81,7 +81,7 @@ def update_css_js(app: Sphinx): # reset changed identifier app.env.sphinx_design_css_changed = False # only do this for html builders - if 'html' in app.builder.name: + if "html" in app.builder.name: # setup up new static path in output dir static_path = (Path(app.outdir) / "_sphinx_design_static").absolute() static_existed = static_path.exists() @@ -97,7 +97,9 @@ def update_css_js(app: Sphinx): content = read_text(static_module, "style.min.css") # Write the css file if sphinx_version < (7, 1): - hash = hashlib.md5(content.encode("utf8"), usedforsecurity=False).hexdigest() + hash = hashlib.md5( + content.encode("utf8"), usedforsecurity=False + ).hexdigest() css_path = static_path / f"sphinx-design.{hash}.min.css" else: # since sphinx 7.1 a checksum is added to the css file URL, so there is no need to do it here