diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2023-05-11 05:19:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 05:19:31 +0100 |
commit | ae206694e68bea074aca633ea0d32e9ed882a95f (patch) | |
tree | bb3ff9ac0e0cce4b6b31830d72c8af7f2c1a0452 /sphinx/ext/graphviz.py | |
parent | 706f5f9cc83f1d62829bb18ad40bfa5e784e202c (diff) | |
download | sphinx-git-ae206694e68bea074aca633ea0d32e9ed882a95f.tar.gz |
html builder: Append CRC32 checksum to asset URIs (#11415)
Diffstat (limited to 'sphinx/ext/graphviz.py')
-rw-r--r-- | sphinx/ext/graphviz.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index c0a99be08..37626e04f 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -8,7 +8,7 @@ import re import subprocess from os import path from subprocess import CalledProcessError -from typing import Any +from typing import TYPE_CHECKING, Any from docutils import nodes from docutils.nodes import Node @@ -20,7 +20,6 @@ from sphinx.errors import SphinxError from sphinx.locale import _, __ from sphinx.util import logging, sha1 from sphinx.util.docutils import SphinxDirective, SphinxTranslator -from sphinx.util.fileutil import copy_asset from sphinx.util.i18n import search_image_for_language from sphinx.util.nodes import set_source_info from sphinx.util.osutil import ensuredir @@ -31,6 +30,9 @@ from sphinx.writers.manpage import ManualPageTranslator from sphinx.writers.texinfo import TexinfoTranslator from sphinx.writers.text import TextTranslator +if TYPE_CHECKING: + from sphinx.config import Config + logger = logging.getLogger(__name__) @@ -391,11 +393,9 @@ def man_visit_graphviz(self: ManualPageTranslator, node: graphviz) -> None: raise nodes.SkipNode -def on_build_finished(app: Sphinx, exc: Exception) -> None: - if exc is None and app.builder.format == 'html': - src = path.join(sphinx.package_dir, 'templates', 'graphviz', 'graphviz.css') - dst = path.join(app.outdir, '_static') - copy_asset(src, dst) +def on_config_inited(_app: Sphinx, config: Config) -> None: + css_path = path.join(sphinx.package_dir, 'templates', 'graphviz', 'graphviz.css') + config.html_static_path.append(css_path) def setup(app: Sphinx) -> dict[str, Any]: @@ -412,5 +412,5 @@ def setup(app: Sphinx) -> dict[str, Any]: app.add_config_value('graphviz_dot_args', [], 'html') app.add_config_value('graphviz_output_format', 'png', 'html') app.add_css_file('graphviz.css') - app.connect('build-finished', on_build_finished) + app.connect('config-inited', on_config_inited) return {'version': sphinx.__display_version__, 'parallel_read_safe': True} |