diff options
| author | Yuriy Andamasov <yuriy@vyos.io> | 2026-04-15 12:31:26 +0300 |
|---|---|---|
| committer | Yuriy Andamasov <yuriy@vyos.io> | 2026-04-15 12:31:26 +0300 |
| commit | 2ff3232cac2278f22624a0a2e8daf2280b14912c (patch) | |
| tree | c94bef3010b95822c877d54a2a24aec69a8ec3a4 /docs | |
| parent | 278fe418cf3cc5b9889bd1f9973a417a3560796f (diff) | |
| download | vyos-documentation-2ff3232cac2278f22624a0a2e8daf2280b14912c.tar.gz vyos-documentation-2ff3232cac2278f22624a0a2e8daf2280b14912c.zip | |
refactor: use builder-inited hook for WebP image type override
Replaces class-level patching of StandaloneHTMLBuilder/DirectoryHTMLBuilder
with a builder-inited event hook that only modifies html, dirhtml, and
readthedocs builders. This avoids unintentionally affecting EPUB or
HTMLHelp builders that inherit from StandaloneHTMLBuilder.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/conf.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/conf.py b/docs/conf.py index eacec2c7..dc24ba85 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -198,16 +198,17 @@ texinfo_documents = [ ] +def _prefer_webp(app): + """Add WebP to front of supported types for HTML/dirhtml builders only.""" + if app.builder.name in ('html', 'dirhtml', 'readthedocs'): + app.builder.supported_image_types = [ + 'image/webp', + 'image/svg+xml', + 'image/png', + 'image/gif', + 'image/jpeg', + ] + + def setup(app): - # Prefer WebP for HTML output; LaTeX keeps its default (PDF/PNG/JPEG) - webp_types = [ - 'image/webp', - 'image/svg+xml', - 'image/png', - 'image/gif', - 'image/jpeg', - ] - from sphinx.builders.html import StandaloneHTMLBuilder - StandaloneHTMLBuilder.supported_image_types = webp_types - from sphinx.builders.dirhtml import DirectoryHTMLBuilder - DirectoryHTMLBuilder.supported_image_types = webp_types
\ No newline at end of file + app.connect('builder-inited', _prefer_webp) |
