summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/conf.py25
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)