From c7958dac93a1f22ad274703e0408512ae6e6f936 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 26 Jul 2023 22:13:42 +0100 Subject: [PATCH] Rework based on suggested changes Sphinx 7.1 added the relevant functionality natively. --- python_docs_theme/__init__.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python_docs_theme/__init__.py b/python_docs_theme/__init__.py index 4b53467..0857b5f 100644 --- a/python_docs_theme/__init__.py +++ b/python_docs_theme/__init__.py @@ -4,7 +4,6 @@ from pathlib import Path from typing import Any, Dict, List -import sphinx import sphinx.application from sphinx.builders.html import StandaloneHTMLBuilder @@ -21,11 +20,6 @@ def _asset_hash(path: str) -> str: def _add_asset_hashes(static: List[str], add_digest_to: List[str]) -> None: - if sphinx.version_info >= (7, 1): - # https://github.com/sphinx-doc/sphinx/pull/11415 added the relevant - # functionality to Sphinx, so we don't need to do anything. - return - for asset in add_digest_to: index = static.index(asset) static[index].filename = _asset_hash(asset) # type: ignore @@ -43,7 +37,7 @@ def _html_page_context( assert isinstance(app.builder, StandaloneHTMLBuilder) - if sphinx.version_info >= (4,) and "css_files" in context: + if (4,) <= sphinx.version_info < (7, 1) and "css_files" in context: if "_static/pydoctheme.css" not in context["css_files"]: raise ValueError( "This documentation is not using `pydoctheme.css` as the stylesheet. "