MartinPdeS-docs 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MartinPdeS-docs
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MartinPdeS-docs
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -4,6 +4,20 @@ import os
4
4
  from pathlib import Path
5
5
 
6
6
 
7
+ def _raster_thumbnail_path(logo: str, favicon: str) -> str | None:
8
+ """Choose a Sphinx-Gallery-compatible fallback thumbnail.
9
+
10
+ Sphinx-Gallery requires a raster image for ``default_thumb_file``. SVG
11
+ files are valid theme logos and favicons, but are not accepted as gallery
12
+ thumbnail sources by all supported Sphinx-Gallery versions.
13
+ """
14
+ raster_suffixes = {".png", ".jpg", ".jpeg", ".gif"}
15
+ for candidate in (logo, favicon):
16
+ if Path(candidate).suffix.lower() in raster_suffixes:
17
+ return candidate
18
+ return None
19
+
20
+
7
21
  def configure(
8
22
  *,
9
23
  project: str,
@@ -97,6 +111,10 @@ def configure(
97
111
  "plot_gallery": True,
98
112
  "thumbnail_size": [600, 600],
99
113
  "download_all_examples": False,
114
+ # Use the project's favicon for examples that do not create a figure.
115
+ # The path is interpreted relative to the documentation source tree,
116
+ # just like ``html_favicon``.
117
+ "default_thumb_file": _raster_thumbnail_path(logo, favicon),
100
118
  "line_numbers": False,
101
119
  "remove_config_comments": True,
102
120
  "capture_repr": ("_repr_html_", "__repr__"),
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "MartinPdeS-docs"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "Shared Sphinx configuration for MartinPdeS scientific Python packages."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -14,6 +14,15 @@ def test_configuration_has_project_overrides():
14
14
  assert config["epub_exclude_files"] == ["search.html"]
15
15
  assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib",)
16
16
  assert config["sphinx_gallery_conf"]["thumbnail_size"] == [600, 600]
17
+ assert config["sphinx_gallery_conf"]["default_thumb_file"] is None
18
+
19
+ raster = configure(
20
+ project="Example",
21
+ package="example",
22
+ logo="../images/logo.png",
23
+ favicon="_static/favicon.svg",
24
+ )
25
+ assert raster["sphinx_gallery_conf"]["default_thumb_file"] == "../images/logo.png"
17
26
  assert "github_url" not in config["html_theme_options"]
18
27
  assert config["html_context"]["github_repo"] == "Example"
19
28