MartinPdeS-docs 0.2.1__tar.gz → 0.2.5__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.
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/PKG-INFO +23 -1
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/PKG-INFO +23 -1
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/README.md +22 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/martinpdes_docs/sphinx.py +84 -40
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/pyproject.toml +1 -1
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/tests/test_configuration.py +49 -4
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/SOURCES.txt +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/dependency_links.txt +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/requires.txt +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/top_level.txt +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/martinpdes_docs/__init__.py +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/martinpdes_docs/static/martinpdes_layout.css +0 -0
- {martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MartinPdeS-docs
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -61,3 +61,25 @@ additional image scraper or an example error policy.
|
|
|
61
61
|
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
62
62
|
documentation builds import the installed wheel instead of the source
|
|
63
63
|
checkout.
|
|
64
|
+
|
|
65
|
+
The shared configuration also owns the common dark-mode context, CSS files,
|
|
66
|
+
autodoc defaults, and navigation metadata. Add only project-specific values in
|
|
67
|
+
`conf.py`, for example:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
globals().update(
|
|
71
|
+
configure(
|
|
72
|
+
project="SuPyMode",
|
|
73
|
+
package="SuPyMode",
|
|
74
|
+
repository="MartinPdeS/SuPyMode",
|
|
75
|
+
extension_additions=["pyvista.ext.plot_directive"],
|
|
76
|
+
html_css_files=["layout.css"],
|
|
77
|
+
autodoc_default_options={"members": True},
|
|
78
|
+
logo_text="",
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Use `include_gallery=False` for documentation sites without executable
|
|
84
|
+
examples. The default theme, context, CSS, and extension set then remain
|
|
85
|
+
centralized in this package.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MartinPdeS-docs
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -61,3 +61,25 @@ additional image scraper or an example error policy.
|
|
|
61
61
|
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
62
62
|
documentation builds import the installed wheel instead of the source
|
|
63
63
|
checkout.
|
|
64
|
+
|
|
65
|
+
The shared configuration also owns the common dark-mode context, CSS files,
|
|
66
|
+
autodoc defaults, and navigation metadata. Add only project-specific values in
|
|
67
|
+
`conf.py`, for example:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
globals().update(
|
|
71
|
+
configure(
|
|
72
|
+
project="SuPyMode",
|
|
73
|
+
package="SuPyMode",
|
|
74
|
+
repository="MartinPdeS/SuPyMode",
|
|
75
|
+
extension_additions=["pyvista.ext.plot_directive"],
|
|
76
|
+
html_css_files=["layout.css"],
|
|
77
|
+
autodoc_default_options={"members": True},
|
|
78
|
+
logo_text="",
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Use `include_gallery=False` for documentation sites without executable
|
|
84
|
+
examples. The default theme, context, CSS, and extension set then remain
|
|
85
|
+
centralized in this package.
|
|
@@ -49,3 +49,25 @@ additional image scraper or an example error policy.
|
|
|
49
49
|
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
50
50
|
documentation builds import the installed wheel instead of the source
|
|
51
51
|
checkout.
|
|
52
|
+
|
|
53
|
+
The shared configuration also owns the common dark-mode context, CSS files,
|
|
54
|
+
autodoc defaults, and navigation metadata. Add only project-specific values in
|
|
55
|
+
`conf.py`, for example:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
globals().update(
|
|
59
|
+
configure(
|
|
60
|
+
project="SuPyMode",
|
|
61
|
+
package="SuPyMode",
|
|
62
|
+
repository="MartinPdeS/SuPyMode",
|
|
63
|
+
extension_additions=["pyvista.ext.plot_directive"],
|
|
64
|
+
html_css_files=["layout.css"],
|
|
65
|
+
autodoc_default_options={"members": True},
|
|
66
|
+
logo_text="",
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Use `include_gallery=False` for documentation sites without executable
|
|
72
|
+
examples. The default theme, context, CSS, and extension set then remain
|
|
73
|
+
centralized in this package.
|
|
@@ -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:
|
|
@@ -59,13 +76,20 @@ def configure(
|
|
|
59
76
|
logo: str = "_static/logo.svg",
|
|
60
77
|
favicon: str = "_static/favicon.svg",
|
|
61
78
|
repository: str | None = None,
|
|
62
|
-
extensions:
|
|
79
|
+
extensions: Sequence[str] | None = None,
|
|
80
|
+
extension_additions: Sequence[str] | None = None,
|
|
63
81
|
html_theme_options: dict | None = None,
|
|
82
|
+
logo_text: str | None = None,
|
|
83
|
+
logo_alt_text: str | None = None,
|
|
84
|
+
html_context: Mapping[str, object] | None = None,
|
|
85
|
+
html_css_files: Sequence[str] | None = None,
|
|
86
|
+
autodoc_default_options: Mapping[str, object] | None = None,
|
|
64
87
|
sphinx_gallery_conf: dict | None = None,
|
|
65
88
|
gallery_sections: Sequence[str] | None = None,
|
|
66
89
|
gallery_default_thumb: str | None = None,
|
|
67
90
|
gallery_options: Mapping[str, object] | None = None,
|
|
68
91
|
prefer_installed_package: bool = False,
|
|
92
|
+
include_gallery: bool = True,
|
|
69
93
|
version: str | None = None,
|
|
70
94
|
source_suffix: str = ".rst",
|
|
71
95
|
master_doc: str = "index",
|
|
@@ -85,20 +109,8 @@ def configure(
|
|
|
85
109
|
|
|
86
110
|
resolved_version = _resolve_version(package, version)
|
|
87
111
|
|
|
88
|
-
default_extensions = [
|
|
89
|
-
"sphinx.ext.autodoc",
|
|
90
|
-
"sphinx.ext.autosummary",
|
|
91
|
-
"sphinx.ext.intersphinx",
|
|
92
|
-
"sphinx.ext.mathjax",
|
|
93
|
-
"sphinx.ext.napoleon",
|
|
94
|
-
"sphinx.ext.autosectionlabel",
|
|
95
|
-
"sphinx.ext.viewcode",
|
|
96
|
-
"sphinx.ext.todo",
|
|
97
|
-
"sphinx_design",
|
|
98
|
-
"sphinx_gallery.gen_gallery",
|
|
99
|
-
]
|
|
100
112
|
options = {
|
|
101
|
-
"logo": {"text": project, "image": logo},
|
|
113
|
+
"logo": {"text": project if logo_text is None else logo_text, "image": logo},
|
|
102
114
|
"navigation_with_keys": True,
|
|
103
115
|
"show_nav_level": 2,
|
|
104
116
|
"navbar_align": "content",
|
|
@@ -112,6 +124,8 @@ def configure(
|
|
|
112
124
|
"pygments_dark_style": "github-dark",
|
|
113
125
|
"use_edit_page_button": bool(repository),
|
|
114
126
|
}
|
|
127
|
+
if logo_alt_text is not None:
|
|
128
|
+
options["logo"]["alt_text"] = logo_alt_text
|
|
115
129
|
if repository:
|
|
116
130
|
owner, repo = repository.split("/", 1)
|
|
117
131
|
options["icon_links"] = [
|
|
@@ -136,20 +150,43 @@ def configure(
|
|
|
136
150
|
"version_match": resolved_version,
|
|
137
151
|
}
|
|
138
152
|
|
|
139
|
-
|
|
153
|
+
context = {
|
|
154
|
+
"doc_path": "docs/source",
|
|
155
|
+
"default_mode": "dark",
|
|
156
|
+
}
|
|
140
157
|
if repository:
|
|
141
158
|
owner, repo = repository.split("/", 1)
|
|
142
159
|
ref_name = os.getenv("GITHUB_REF_NAME", "master")
|
|
143
|
-
|
|
160
|
+
context.update(
|
|
144
161
|
{
|
|
145
162
|
"github_user": owner,
|
|
146
163
|
"github_repo": repo,
|
|
147
164
|
"github_version": ref_name,
|
|
148
165
|
}
|
|
149
166
|
)
|
|
167
|
+
if html_context:
|
|
168
|
+
context.update(html_context)
|
|
150
169
|
if html_theme_options:
|
|
151
170
|
options.update(html_theme_options)
|
|
152
171
|
|
|
172
|
+
default_extensions = [
|
|
173
|
+
"sphinx.ext.autodoc",
|
|
174
|
+
"sphinx.ext.autosummary",
|
|
175
|
+
"sphinx.ext.intersphinx",
|
|
176
|
+
"sphinx.ext.mathjax",
|
|
177
|
+
"sphinx.ext.napoleon",
|
|
178
|
+
"sphinx.ext.autosectionlabel",
|
|
179
|
+
"sphinx.ext.viewcode",
|
|
180
|
+
"sphinx.ext.todo",
|
|
181
|
+
"sphinx_design",
|
|
182
|
+
]
|
|
183
|
+
if include_gallery:
|
|
184
|
+
default_extensions.append("sphinx_gallery.gen_gallery")
|
|
185
|
+
if extensions is None:
|
|
186
|
+
configured_extensions = default_extensions + list(extension_additions or ())
|
|
187
|
+
else:
|
|
188
|
+
configured_extensions = list(extensions)
|
|
189
|
+
|
|
153
190
|
gallery = {
|
|
154
191
|
"examples_dirs": "../examples/",
|
|
155
192
|
"gallery_dirs": "gallery/",
|
|
@@ -170,40 +207,48 @@ def configure(
|
|
|
170
207
|
"capture_repr": ("_repr_html_", "__repr__"),
|
|
171
208
|
"nested_sections": True,
|
|
172
209
|
}
|
|
173
|
-
if
|
|
210
|
+
if not include_gallery:
|
|
211
|
+
gallery = None
|
|
212
|
+
elif gallery_sections:
|
|
174
213
|
sections = list(gallery_sections)
|
|
175
214
|
gallery["examples_dirs"] = [f"../examples/{section}" for section in sections]
|
|
176
215
|
gallery["gallery_dirs"] = [f"gallery/{section}" for section in sections]
|
|
177
|
-
if
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
216
|
+
if gallery is not None:
|
|
217
|
+
if gallery_default_thumb is not None:
|
|
218
|
+
gallery["default_thumb_file"] = _resolve_doc_asset(gallery_default_thumb)
|
|
219
|
+
if gallery_options:
|
|
220
|
+
gallery.update(gallery_options)
|
|
221
|
+
if sphinx_gallery_conf:
|
|
222
|
+
gallery.update(sphinx_gallery_conf)
|
|
223
|
+
|
|
224
|
+
css_files = ["default.css", "martinpdes_layout.css"]
|
|
225
|
+
css_files.extend(html_css_files or ())
|
|
226
|
+
autodoc_options = {
|
|
227
|
+
"members": False,
|
|
228
|
+
"members-order": "bysource",
|
|
229
|
+
"undoc-members": False,
|
|
230
|
+
"show-inheritance": True,
|
|
231
|
+
}
|
|
232
|
+
autodoc_options.update(autodoc_default_options or {})
|
|
233
|
+
|
|
234
|
+
configuration = {
|
|
185
235
|
"project": project,
|
|
186
236
|
"package": package,
|
|
187
237
|
"author": author,
|
|
188
238
|
"copyright": author,
|
|
189
|
-
"extensions":
|
|
239
|
+
"extensions": configured_extensions,
|
|
190
240
|
"exclude_patterns": ["_build", "Thumbs.db", ".DS_Store"],
|
|
191
241
|
"suppress_warnings": ["config.cache"],
|
|
192
242
|
"html_theme": "pydata_sphinx_theme",
|
|
193
243
|
"html_theme_options": options,
|
|
194
|
-
"html_context":
|
|
244
|
+
"html_context": context,
|
|
195
245
|
"html_logo": logo,
|
|
196
246
|
"html_favicon": favicon,
|
|
197
247
|
"html_static_path": ["_static", str(Path(__file__).parent / "static")],
|
|
198
248
|
"templates_path": ["_templates"],
|
|
199
|
-
"html_css_files":
|
|
249
|
+
"html_css_files": css_files,
|
|
200
250
|
"autodoc_typehints": "description",
|
|
201
|
-
"autodoc_default_options":
|
|
202
|
-
"members": False,
|
|
203
|
-
"members-order": "bysource",
|
|
204
|
-
"undoc-members": False,
|
|
205
|
-
"show-inheritance": True,
|
|
206
|
-
},
|
|
251
|
+
"autodoc_default_options": autodoc_options,
|
|
207
252
|
"napoleon_google_docstring": False,
|
|
208
253
|
"napoleon_numpy_docstring": True,
|
|
209
254
|
"autosectionlabel_prefix_document": True,
|
|
@@ -220,12 +265,11 @@ def configure(
|
|
|
220
265
|
"latex_elements": {},
|
|
221
266
|
"latex_documents": [(master_doc, f"{package}.tex", f"{package} Documentation", author, "manual")],
|
|
222
267
|
"man_pages": [(master_doc, package.lower(), f"{package} Documentation", [author], 1)],
|
|
223
|
-
"texinfo_documents": [
|
|
224
|
-
(master_doc, package, f"{package} Documentation", author, package,
|
|
225
|
-
f"Documentation for {package}.", "Miscellaneous")
|
|
226
|
-
],
|
|
268
|
+
"texinfo_documents": [(master_doc, package, f"{package} Documentation", author, package, f"Documentation for {package}.", "Miscellaneous")],
|
|
227
269
|
"epub_title": project,
|
|
228
270
|
"epub_exclude_files": ["search.html"],
|
|
229
|
-
"sphinx_gallery_conf": gallery,
|
|
230
271
|
"_martinpdes_package_root": str(Path(__file__).parent),
|
|
231
272
|
}
|
|
273
|
+
if gallery is not None:
|
|
274
|
+
configuration["sphinx_gallery_conf"] = gallery
|
|
275
|
+
return configuration
|
|
@@ -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
|
|
@@ -14,6 +15,8 @@ def test_configuration_has_project_overrides():
|
|
|
14
15
|
assert config["html_static_path"][1].endswith("martinpdes_docs/static")
|
|
15
16
|
assert config["templates_path"] == ["_templates"]
|
|
16
17
|
assert config["html_css_files"] == ["default.css", "martinpdes_layout.css"]
|
|
18
|
+
assert config["html_context"]["doc_path"] == "docs/source"
|
|
19
|
+
assert config["html_context"]["default_mode"] == "dark"
|
|
17
20
|
assert config["epub_exclude_files"] == ["search.html"]
|
|
18
21
|
assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib",)
|
|
19
22
|
assert config["sphinx_gallery_conf"]["thumbnail_size"] == [600, 600]
|
|
@@ -35,9 +38,10 @@ def test_configuration_has_project_overrides():
|
|
|
35
38
|
"gallery/tutorials",
|
|
36
39
|
"gallery/validation",
|
|
37
40
|
]
|
|
38
|
-
assert sections["sphinx_gallery_conf"]["default_thumb_file"]
|
|
39
|
-
"_static/gallery-default.png"
|
|
40
|
-
|
|
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"]
|
|
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
|
|
|
@@ -61,6 +65,32 @@ def test_custom_extensions_and_theme_options_are_preserved():
|
|
|
61
65
|
assert config["extensions"] == ["custom.extension"]
|
|
62
66
|
assert config["html_theme_options"]["announcement"] == "Hello"
|
|
63
67
|
|
|
68
|
+
additions = configure(
|
|
69
|
+
project="Example",
|
|
70
|
+
package="example",
|
|
71
|
+
extension_additions=["pyvista.ext.plot_directive"],
|
|
72
|
+
html_css_files=["layout.css"],
|
|
73
|
+
logo_text="",
|
|
74
|
+
logo_alt_text="Example logo",
|
|
75
|
+
autodoc_default_options={"members": True},
|
|
76
|
+
)
|
|
77
|
+
assert "pyvista.ext.plot_directive" in additions["extensions"]
|
|
78
|
+
assert additions["html_css_files"][-1] == "layout.css"
|
|
79
|
+
assert additions["html_theme_options"]["logo"] == {
|
|
80
|
+
"text": "",
|
|
81
|
+
"image": "_static/logo.svg",
|
|
82
|
+
"alt_text": "Example logo",
|
|
83
|
+
}
|
|
84
|
+
assert additions["autodoc_default_options"]["members"] is True
|
|
85
|
+
|
|
86
|
+
no_gallery = configure(
|
|
87
|
+
project="Example",
|
|
88
|
+
package="example",
|
|
89
|
+
include_gallery=False,
|
|
90
|
+
)
|
|
91
|
+
assert "sphinx_gallery.gen_gallery" not in no_gallery["extensions"]
|
|
92
|
+
assert "sphinx_gallery_conf" not in no_gallery
|
|
93
|
+
|
|
64
94
|
|
|
65
95
|
def test_gallery_options_override_shared_defaults():
|
|
66
96
|
config = configure(
|
|
@@ -72,6 +102,21 @@ def test_gallery_options_override_shared_defaults():
|
|
|
72
102
|
assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib", "pyvista")
|
|
73
103
|
|
|
74
104
|
|
|
105
|
+
def test_gallery_thumbnail_paths_are_resolved_from_docs_source(tmp_path, monkeypatch):
|
|
106
|
+
asset = tmp_path / "docs" / "source" / "_static" / "gallery-default.png"
|
|
107
|
+
asset.parent.mkdir(parents=True)
|
|
108
|
+
asset.write_bytes(b"png")
|
|
109
|
+
monkeypatch.chdir(tmp_path)
|
|
110
|
+
|
|
111
|
+
config = configure(
|
|
112
|
+
project="Example",
|
|
113
|
+
package="example",
|
|
114
|
+
gallery_default_thumb="_static/gallery-default.png",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
assert config["sphinx_gallery_conf"]["default_thumb_file"] == str(asset)
|
|
118
|
+
|
|
119
|
+
|
|
75
120
|
def test_version_can_be_resolved_from_the_environment(monkeypatch):
|
|
76
121
|
monkeypatch.setenv("tag", "v2.3.4")
|
|
77
122
|
|
|
File without changes
|
{martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/MartinPdeS_docs.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{martinpdes_docs-0.2.1 → martinpdes_docs-0.2.5}/martinpdes_docs/static/martinpdes_layout.css
RENAMED
|
File without changes
|
|
File without changes
|