Skip to content

Commit 0392388

Browse files
committed
add optipng compression to sphinx-gallery
1 parent eb3125e commit 0392388

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/doc.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
with:
2626
python-version: 3.9
2727
architecture: 'x64'
28+
- name: Install linux dependencies
29+
run: |
30+
sudo apt update
31+
sudo apt install optipng
2832
- name: Install package
2933
run: |
3034
python -m pip install --progress-bar off --upgrade pip setuptools

doc/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
import inspect
8+
import sys
89
from datetime import date
910
from importlib import import_module
1011
from typing import Dict, Optional
@@ -221,8 +222,18 @@ def linkcode_resolve(domain: str, info: Dict[str, str]) -> Optional[str]:
221222

222223

223224
# -- sphinx-gallery ----------------------------------------------------------
225+
if sys.platform.startswith("win"):
226+
try:
227+
subprocess.check_call(["optipng", "--version"])
228+
compress_images = ("images", "thumbnails")
229+
except Exception:
230+
compress_images = ("images", "thumbnails")
231+
else:
232+
compress_images = ("images", "thumbnails")
233+
224234
sphinx_gallery_conf = {
225235
"backreferences_dir": "generated/backreferences",
236+
"compress_images": compress_images,
226237
"doc_module": (f"{package}",),
227238
"examples_dirs": ["../tutorials"],
228239
"exclude_implicit_doc": {}, # set

0 commit comments

Comments
 (0)