MartinPdeS-docs 0.2.3__tar.gz → 0.3.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Martin Poinsinet de Sivry-Houle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,14 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MartinPdeS-docs
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
+ License-File: LICENSE
7
8
  Requires-Dist: sphinx>=7
8
9
  Requires-Dist: pydata-sphinx-theme>=0.15
9
10
  Requires-Dist: sphinx-design>=0.6
10
11
  Requires-Dist: sphinx-gallery>=0.16
12
+ Requires-Dist: numpydoc<2,>=1.8
11
13
  Requires-Dist: pytest>=7
14
+ Dynamic: license-file
12
15
 
13
16
  # MartinPdeS-docs
14
17
 
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  MartinPdeS_docs.egg-info/PKG-INFO
@@ -2,4 +2,5 @@ sphinx>=7
2
2
  pydata-sphinx-theme>=0.15
3
3
  sphinx-design>=0.6
4
4
  sphinx-gallery>=0.16
5
+ numpydoc<2,>=1.8
5
6
  pytest>=7
@@ -1,14 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MartinPdeS-docs
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
7
+ License-File: LICENSE
7
8
  Requires-Dist: sphinx>=7
8
9
  Requires-Dist: pydata-sphinx-theme>=0.15
9
10
  Requires-Dist: sphinx-design>=0.6
10
11
  Requires-Dist: sphinx-gallery>=0.16
12
+ Requires-Dist: numpydoc<2,>=1.8
11
13
  Requires-Dist: pytest>=7
14
+ Dynamic: license-file
12
15
 
13
16
  # MartinPdeS-docs
14
17
 
@@ -21,10 +21,27 @@ def _raster_thumbnail_path(logo: str, favicon: str) -> str | None:
21
21
  raster_suffixes = {".png", ".jpg", ".jpeg", ".gif"}
22
22
  for candidate in (logo, favicon):
23
23
  if Path(candidate).suffix.lower() in raster_suffixes:
24
- return candidate
24
+ return _resolve_doc_asset(candidate)
25
25
  return None
26
26
 
27
27
 
28
+ def _resolve_doc_asset(path: str) -> str:
29
+ """Resolve a documentation asset relative to common Sphinx build roots."""
30
+ candidate = Path(path)
31
+ if candidate.is_absolute():
32
+ return str(candidate)
33
+
34
+ roots = (
35
+ Path.cwd(),
36
+ Path.cwd() / "docs" / "source",
37
+ )
38
+ for root in roots:
39
+ resolved = root / candidate
40
+ if resolved.is_file():
41
+ return str(resolved)
42
+ return path
43
+
44
+
28
45
  def _resolve_version(package: str, version: str | None) -> str:
29
46
  """Resolve the documentation version without importing the package."""
30
47
  if version is not None:
@@ -95,14 +112,14 @@ def configure(
95
112
  options = {
96
113
  "logo": {"text": project if logo_text is None else logo_text, "image": logo},
97
114
  "navigation_with_keys": True,
98
- "show_nav_level": 2,
115
+ "show_nav_level": 1,
99
116
  "navbar_align": "content",
100
117
  "show_toc_level": 2,
101
- "navbar_end": ["version-switcher", "navbar-icon-links"],
102
- "show_prev_next": False,
118
+ "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"],
119
+ "show_prev_next": True,
103
120
  "show_version_warning_banner": True,
104
121
  "footer_start": ["copyright"],
105
- "footer_end": ["sphinx-version", "theme-version"],
122
+ "footer_end": [],
106
123
  "pygments_light_style": "default",
107
124
  "pygments_dark_style": "github-dark",
108
125
  "use_edit_page_button": bool(repository),
@@ -155,9 +172,9 @@ def configure(
155
172
  default_extensions = [
156
173
  "sphinx.ext.autodoc",
157
174
  "sphinx.ext.autosummary",
158
- "sphinx.ext.intersphinx",
159
175
  "sphinx.ext.mathjax",
160
176
  "sphinx.ext.napoleon",
177
+ "numpydoc",
161
178
  "sphinx.ext.autosectionlabel",
162
179
  "sphinx.ext.viewcode",
163
180
  "sphinx.ext.todo",
@@ -198,7 +215,7 @@ def configure(
198
215
  gallery["gallery_dirs"] = [f"gallery/{section}" for section in sections]
199
216
  if gallery is not None:
200
217
  if gallery_default_thumb is not None:
201
- gallery["default_thumb_file"] = gallery_default_thumb
218
+ gallery["default_thumb_file"] = _resolve_doc_asset(gallery_default_thumb)
202
219
  if gallery_options:
203
220
  gallery.update(gallery_options)
204
221
  if sphinx_gallery_conf:
@@ -234,6 +251,8 @@ def configure(
234
251
  "autodoc_default_options": autodoc_options,
235
252
  "napoleon_google_docstring": False,
236
253
  "napoleon_numpy_docstring": True,
254
+ "napoleon_use_ivar": True,
255
+ "show_authors": True,
237
256
  "autosectionlabel_prefix_document": True,
238
257
  "numpydoc_show_class_members": False,
239
258
  "add_module_names": False,
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "MartinPdeS-docs"
7
- version = "0.2.3"
7
+ version = "0.3.0"
8
8
  description = "Shared Sphinx configuration for MartinPdeS scientific Python packages."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -13,6 +13,7 @@ dependencies = [
13
13
  "pydata-sphinx-theme>=0.15",
14
14
  "sphinx-design>=0.6",
15
15
  "sphinx-gallery>=0.16",
16
+ "numpydoc>=1.8,<2",
16
17
  "pytest>=7",
17
18
  ]
18
19
 
@@ -1,4 +1,5 @@
1
1
  from importlib.metadata import distribution
2
+ from pathlib import Path
2
3
  import sys
3
4
 
4
5
  from martinpdes_docs import configure
@@ -37,7 +38,10 @@ def test_configuration_has_project_overrides():
37
38
  "gallery/tutorials",
38
39
  "gallery/validation",
39
40
  ]
40
- assert sections["sphinx_gallery_conf"]["default_thumb_file"] == ("_static/gallery-default.png")
41
+ assert sections["sphinx_gallery_conf"]["default_thumb_file"] in {
42
+ "_static/gallery-default.png",
43
+ str(Path.cwd() / "docs" / "source" / "_static" / "gallery-default.png"),
44
+ }
41
45
 
42
46
  raster = configure(
43
47
  project="Example",
@@ -45,7 +49,7 @@ def test_configuration_has_project_overrides():
45
49
  logo="../images/logo.png",
46
50
  favicon="_static/favicon.svg",
47
51
  )
48
- assert raster["sphinx_gallery_conf"]["default_thumb_file"] == "../images/logo.png"
52
+ assert raster["sphinx_gallery_conf"]["default_thumb_file"].endswith("images/logo.png")
49
53
  assert "github_url" not in config["html_theme_options"]
50
54
  assert config["html_context"]["github_repo"] == "Example"
51
55
 
@@ -59,6 +63,9 @@ def test_custom_extensions_and_theme_options_are_preserved():
59
63
  )
60
64
 
61
65
  assert config["extensions"] == ["custom.extension"]
66
+
67
+ defaults = configure(project="Example", package="example")
68
+ assert "numpydoc" in defaults["extensions"]
62
69
  assert config["html_theme_options"]["announcement"] == "Hello"
63
70
 
64
71
  additions = configure(
@@ -98,6 +105,21 @@ def test_gallery_options_override_shared_defaults():
98
105
  assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib", "pyvista")
99
106
 
100
107
 
108
+ def test_gallery_thumbnail_paths_are_resolved_from_docs_source(tmp_path, monkeypatch):
109
+ asset = tmp_path / "docs" / "source" / "_static" / "gallery-default.png"
110
+ asset.parent.mkdir(parents=True)
111
+ asset.write_bytes(b"png")
112
+ monkeypatch.chdir(tmp_path)
113
+
114
+ config = configure(
115
+ project="Example",
116
+ package="example",
117
+ gallery_default_thumb="_static/gallery-default.png",
118
+ )
119
+
120
+ assert config["sphinx_gallery_conf"]["default_thumb_file"] == str(asset)
121
+
122
+
101
123
  def test_version_can_be_resolved_from_the_environment(monkeypatch):
102
124
  monkeypatch.setenv("tag", "v2.3.4")
103
125