MartinPdeS-docs 0.2.0__tar.gz → 0.2.3__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.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/PKG-INFO +27 -1
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/PKG-INFO +27 -1
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/README.md +26 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/martinpdes_docs/sphinx.py +90 -42
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/pyproject.toml +1 -1
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/tests/test_configuration.py +46 -3
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/SOURCES.txt +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/dependency_links.txt +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/requires.txt +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/top_level.txt +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/martinpdes_docs/__init__.py +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/martinpdes_docs/static/martinpdes_layout.css +0 -0
- {martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/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.3
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -57,3 +57,29 @@ globals().update(
|
|
|
57
57
|
|
|
58
58
|
Use `gallery_options` for project-specific Sphinx-Gallery settings such as an
|
|
59
59
|
additional image scraper or an example error policy.
|
|
60
|
+
|
|
61
|
+
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
62
|
+
documentation builds import the installed wheel instead of the source
|
|
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.3
|
|
4
4
|
Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -57,3 +57,29 @@ globals().update(
|
|
|
57
57
|
|
|
58
58
|
Use `gallery_options` for project-specific Sphinx-Gallery settings such as an
|
|
59
59
|
additional image scraper or an example error policy.
|
|
60
|
+
|
|
61
|
+
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
62
|
+
documentation builds import the installed wheel instead of the source
|
|
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.
|
|
@@ -45,3 +45,29 @@ globals().update(
|
|
|
45
45
|
|
|
46
46
|
Use `gallery_options` for project-specific Sphinx-Gallery settings such as an
|
|
47
47
|
additional image scraper or an example error policy.
|
|
48
|
+
|
|
49
|
+
For packages with compiled extensions, set `prefer_installed_package=True` so
|
|
50
|
+
documentation builds import the installed wheel instead of the source
|
|
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.
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
from collections.abc import Mapping, Sequence
|
|
5
|
-
|
|
5
|
+
import sys
|
|
6
|
+
from importlib.metadata import (
|
|
7
|
+
PackageNotFoundError,
|
|
8
|
+
distribution,
|
|
9
|
+
version as distribution_version,
|
|
10
|
+
)
|
|
6
11
|
from pathlib import Path
|
|
7
12
|
|
|
8
13
|
|
|
@@ -35,6 +40,17 @@ def _resolve_version(package: str, version: str | None) -> str:
|
|
|
35
40
|
return "latest"
|
|
36
41
|
|
|
37
42
|
|
|
43
|
+
def _prefer_installed_package(package: str) -> None:
|
|
44
|
+
"""Put an installed distribution before the documentation checkout."""
|
|
45
|
+
try:
|
|
46
|
+
installed_site = str(distribution(package).locate_file(""))
|
|
47
|
+
except PackageNotFoundError:
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
sys.path[:] = [entry for entry in sys.path if entry != installed_site]
|
|
51
|
+
sys.path.insert(0, installed_site)
|
|
52
|
+
|
|
53
|
+
|
|
38
54
|
def configure(
|
|
39
55
|
*,
|
|
40
56
|
project: str,
|
|
@@ -43,12 +59,20 @@ def configure(
|
|
|
43
59
|
logo: str = "_static/logo.svg",
|
|
44
60
|
favicon: str = "_static/favicon.svg",
|
|
45
61
|
repository: str | None = None,
|
|
46
|
-
extensions:
|
|
62
|
+
extensions: Sequence[str] | None = None,
|
|
63
|
+
extension_additions: Sequence[str] | None = None,
|
|
47
64
|
html_theme_options: dict | None = None,
|
|
65
|
+
logo_text: str | None = None,
|
|
66
|
+
logo_alt_text: str | None = None,
|
|
67
|
+
html_context: Mapping[str, object] | None = None,
|
|
68
|
+
html_css_files: Sequence[str] | None = None,
|
|
69
|
+
autodoc_default_options: Mapping[str, object] | None = None,
|
|
48
70
|
sphinx_gallery_conf: dict | None = None,
|
|
49
71
|
gallery_sections: Sequence[str] | None = None,
|
|
50
72
|
gallery_default_thumb: str | None = None,
|
|
51
73
|
gallery_options: Mapping[str, object] | None = None,
|
|
74
|
+
prefer_installed_package: bool = False,
|
|
75
|
+
include_gallery: bool = True,
|
|
52
76
|
version: str | None = None,
|
|
53
77
|
source_suffix: str = ".rst",
|
|
54
78
|
master_doc: str = "index",
|
|
@@ -59,25 +83,17 @@ def configure(
|
|
|
59
83
|
keep project-specific settings below that call so they remain easy to
|
|
60
84
|
override. Pass ``gallery_sections`` when examples are split into named
|
|
61
85
|
directories; use ``gallery_default_thumb`` for a project-specific raster
|
|
62
|
-
fallback;
|
|
63
|
-
|
|
86
|
+
fallback; use ``gallery_options`` for less common Sphinx-Gallery settings;
|
|
87
|
+
and set ``prefer_installed_package`` for projects whose documentation must
|
|
88
|
+
import a built wheel instead of the source checkout.
|
|
64
89
|
"""
|
|
90
|
+
if prefer_installed_package:
|
|
91
|
+
_prefer_installed_package(package)
|
|
92
|
+
|
|
65
93
|
resolved_version = _resolve_version(package, version)
|
|
66
94
|
|
|
67
|
-
default_extensions = [
|
|
68
|
-
"sphinx.ext.autodoc",
|
|
69
|
-
"sphinx.ext.autosummary",
|
|
70
|
-
"sphinx.ext.intersphinx",
|
|
71
|
-
"sphinx.ext.mathjax",
|
|
72
|
-
"sphinx.ext.napoleon",
|
|
73
|
-
"sphinx.ext.autosectionlabel",
|
|
74
|
-
"sphinx.ext.viewcode",
|
|
75
|
-
"sphinx.ext.todo",
|
|
76
|
-
"sphinx_design",
|
|
77
|
-
"sphinx_gallery.gen_gallery",
|
|
78
|
-
]
|
|
79
95
|
options = {
|
|
80
|
-
"logo": {"text": project, "image": logo},
|
|
96
|
+
"logo": {"text": project if logo_text is None else logo_text, "image": logo},
|
|
81
97
|
"navigation_with_keys": True,
|
|
82
98
|
"show_nav_level": 2,
|
|
83
99
|
"navbar_align": "content",
|
|
@@ -91,6 +107,8 @@ def configure(
|
|
|
91
107
|
"pygments_dark_style": "github-dark",
|
|
92
108
|
"use_edit_page_button": bool(repository),
|
|
93
109
|
}
|
|
110
|
+
if logo_alt_text is not None:
|
|
111
|
+
options["logo"]["alt_text"] = logo_alt_text
|
|
94
112
|
if repository:
|
|
95
113
|
owner, repo = repository.split("/", 1)
|
|
96
114
|
options["icon_links"] = [
|
|
@@ -115,20 +133,43 @@ def configure(
|
|
|
115
133
|
"version_match": resolved_version,
|
|
116
134
|
}
|
|
117
135
|
|
|
118
|
-
|
|
136
|
+
context = {
|
|
137
|
+
"doc_path": "docs/source",
|
|
138
|
+
"default_mode": "dark",
|
|
139
|
+
}
|
|
119
140
|
if repository:
|
|
120
141
|
owner, repo = repository.split("/", 1)
|
|
121
142
|
ref_name = os.getenv("GITHUB_REF_NAME", "master")
|
|
122
|
-
|
|
143
|
+
context.update(
|
|
123
144
|
{
|
|
124
145
|
"github_user": owner,
|
|
125
146
|
"github_repo": repo,
|
|
126
147
|
"github_version": ref_name,
|
|
127
148
|
}
|
|
128
149
|
)
|
|
150
|
+
if html_context:
|
|
151
|
+
context.update(html_context)
|
|
129
152
|
if html_theme_options:
|
|
130
153
|
options.update(html_theme_options)
|
|
131
154
|
|
|
155
|
+
default_extensions = [
|
|
156
|
+
"sphinx.ext.autodoc",
|
|
157
|
+
"sphinx.ext.autosummary",
|
|
158
|
+
"sphinx.ext.intersphinx",
|
|
159
|
+
"sphinx.ext.mathjax",
|
|
160
|
+
"sphinx.ext.napoleon",
|
|
161
|
+
"sphinx.ext.autosectionlabel",
|
|
162
|
+
"sphinx.ext.viewcode",
|
|
163
|
+
"sphinx.ext.todo",
|
|
164
|
+
"sphinx_design",
|
|
165
|
+
]
|
|
166
|
+
if include_gallery:
|
|
167
|
+
default_extensions.append("sphinx_gallery.gen_gallery")
|
|
168
|
+
if extensions is None:
|
|
169
|
+
configured_extensions = default_extensions + list(extension_additions or ())
|
|
170
|
+
else:
|
|
171
|
+
configured_extensions = list(extensions)
|
|
172
|
+
|
|
132
173
|
gallery = {
|
|
133
174
|
"examples_dirs": "../examples/",
|
|
134
175
|
"gallery_dirs": "gallery/",
|
|
@@ -149,40 +190,48 @@ def configure(
|
|
|
149
190
|
"capture_repr": ("_repr_html_", "__repr__"),
|
|
150
191
|
"nested_sections": True,
|
|
151
192
|
}
|
|
152
|
-
if
|
|
193
|
+
if not include_gallery:
|
|
194
|
+
gallery = None
|
|
195
|
+
elif gallery_sections:
|
|
153
196
|
sections = list(gallery_sections)
|
|
154
197
|
gallery["examples_dirs"] = [f"../examples/{section}" for section in sections]
|
|
155
198
|
gallery["gallery_dirs"] = [f"gallery/{section}" for section in sections]
|
|
156
|
-
if
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
199
|
+
if gallery is not None:
|
|
200
|
+
if gallery_default_thumb is not None:
|
|
201
|
+
gallery["default_thumb_file"] = gallery_default_thumb
|
|
202
|
+
if gallery_options:
|
|
203
|
+
gallery.update(gallery_options)
|
|
204
|
+
if sphinx_gallery_conf:
|
|
205
|
+
gallery.update(sphinx_gallery_conf)
|
|
206
|
+
|
|
207
|
+
css_files = ["default.css", "martinpdes_layout.css"]
|
|
208
|
+
css_files.extend(html_css_files or ())
|
|
209
|
+
autodoc_options = {
|
|
210
|
+
"members": False,
|
|
211
|
+
"members-order": "bysource",
|
|
212
|
+
"undoc-members": False,
|
|
213
|
+
"show-inheritance": True,
|
|
214
|
+
}
|
|
215
|
+
autodoc_options.update(autodoc_default_options or {})
|
|
216
|
+
|
|
217
|
+
configuration = {
|
|
164
218
|
"project": project,
|
|
165
219
|
"package": package,
|
|
166
220
|
"author": author,
|
|
167
221
|
"copyright": author,
|
|
168
|
-
"extensions":
|
|
222
|
+
"extensions": configured_extensions,
|
|
169
223
|
"exclude_patterns": ["_build", "Thumbs.db", ".DS_Store"],
|
|
170
224
|
"suppress_warnings": ["config.cache"],
|
|
171
225
|
"html_theme": "pydata_sphinx_theme",
|
|
172
226
|
"html_theme_options": options,
|
|
173
|
-
"html_context":
|
|
227
|
+
"html_context": context,
|
|
174
228
|
"html_logo": logo,
|
|
175
229
|
"html_favicon": favicon,
|
|
176
230
|
"html_static_path": ["_static", str(Path(__file__).parent / "static")],
|
|
177
231
|
"templates_path": ["_templates"],
|
|
178
|
-
"html_css_files":
|
|
232
|
+
"html_css_files": css_files,
|
|
179
233
|
"autodoc_typehints": "description",
|
|
180
|
-
"autodoc_default_options":
|
|
181
|
-
"members": False,
|
|
182
|
-
"members-order": "bysource",
|
|
183
|
-
"undoc-members": False,
|
|
184
|
-
"show-inheritance": True,
|
|
185
|
-
},
|
|
234
|
+
"autodoc_default_options": autodoc_options,
|
|
186
235
|
"napoleon_google_docstring": False,
|
|
187
236
|
"napoleon_numpy_docstring": True,
|
|
188
237
|
"autosectionlabel_prefix_document": True,
|
|
@@ -199,12 +248,11 @@ def configure(
|
|
|
199
248
|
"latex_elements": {},
|
|
200
249
|
"latex_documents": [(master_doc, f"{package}.tex", f"{package} Documentation", author, "manual")],
|
|
201
250
|
"man_pages": [(master_doc, package.lower(), f"{package} Documentation", [author], 1)],
|
|
202
|
-
"texinfo_documents": [
|
|
203
|
-
(master_doc, package, f"{package} Documentation", author, package,
|
|
204
|
-
f"Documentation for {package}.", "Miscellaneous")
|
|
205
|
-
],
|
|
251
|
+
"texinfo_documents": [(master_doc, package, f"{package} Documentation", author, package, f"Documentation for {package}.", "Miscellaneous")],
|
|
206
252
|
"epub_title": project,
|
|
207
253
|
"epub_exclude_files": ["search.html"],
|
|
208
|
-
"sphinx_gallery_conf": gallery,
|
|
209
254
|
"_martinpdes_package_root": str(Path(__file__).parent),
|
|
210
255
|
}
|
|
256
|
+
if gallery is not None:
|
|
257
|
+
configuration["sphinx_gallery_conf"] = gallery
|
|
258
|
+
return configuration
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
from importlib.metadata import distribution
|
|
2
|
+
import sys
|
|
3
|
+
|
|
1
4
|
from martinpdes_docs import configure
|
|
2
5
|
|
|
3
6
|
|
|
@@ -11,6 +14,8 @@ def test_configuration_has_project_overrides():
|
|
|
11
14
|
assert config["html_static_path"][1].endswith("martinpdes_docs/static")
|
|
12
15
|
assert config["templates_path"] == ["_templates"]
|
|
13
16
|
assert config["html_css_files"] == ["default.css", "martinpdes_layout.css"]
|
|
17
|
+
assert config["html_context"]["doc_path"] == "docs/source"
|
|
18
|
+
assert config["html_context"]["default_mode"] == "dark"
|
|
14
19
|
assert config["epub_exclude_files"] == ["search.html"]
|
|
15
20
|
assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib",)
|
|
16
21
|
assert config["sphinx_gallery_conf"]["thumbnail_size"] == [600, 600]
|
|
@@ -32,9 +37,7 @@ def test_configuration_has_project_overrides():
|
|
|
32
37
|
"gallery/tutorials",
|
|
33
38
|
"gallery/validation",
|
|
34
39
|
]
|
|
35
|
-
assert sections["sphinx_gallery_conf"]["default_thumb_file"] == (
|
|
36
|
-
"_static/gallery-default.png"
|
|
37
|
-
)
|
|
40
|
+
assert sections["sphinx_gallery_conf"]["default_thumb_file"] == ("_static/gallery-default.png")
|
|
38
41
|
|
|
39
42
|
raster = configure(
|
|
40
43
|
project="Example",
|
|
@@ -58,6 +61,32 @@ def test_custom_extensions_and_theme_options_are_preserved():
|
|
|
58
61
|
assert config["extensions"] == ["custom.extension"]
|
|
59
62
|
assert config["html_theme_options"]["announcement"] == "Hello"
|
|
60
63
|
|
|
64
|
+
additions = configure(
|
|
65
|
+
project="Example",
|
|
66
|
+
package="example",
|
|
67
|
+
extension_additions=["pyvista.ext.plot_directive"],
|
|
68
|
+
html_css_files=["layout.css"],
|
|
69
|
+
logo_text="",
|
|
70
|
+
logo_alt_text="Example logo",
|
|
71
|
+
autodoc_default_options={"members": True},
|
|
72
|
+
)
|
|
73
|
+
assert "pyvista.ext.plot_directive" in additions["extensions"]
|
|
74
|
+
assert additions["html_css_files"][-1] == "layout.css"
|
|
75
|
+
assert additions["html_theme_options"]["logo"] == {
|
|
76
|
+
"text": "",
|
|
77
|
+
"image": "_static/logo.svg",
|
|
78
|
+
"alt_text": "Example logo",
|
|
79
|
+
}
|
|
80
|
+
assert additions["autodoc_default_options"]["members"] is True
|
|
81
|
+
|
|
82
|
+
no_gallery = configure(
|
|
83
|
+
project="Example",
|
|
84
|
+
package="example",
|
|
85
|
+
include_gallery=False,
|
|
86
|
+
)
|
|
87
|
+
assert "sphinx_gallery.gen_gallery" not in no_gallery["extensions"]
|
|
88
|
+
assert "sphinx_gallery_conf" not in no_gallery
|
|
89
|
+
|
|
61
90
|
|
|
62
91
|
def test_gallery_options_override_shared_defaults():
|
|
63
92
|
config = configure(
|
|
@@ -79,3 +108,17 @@ def test_version_can_be_resolved_from_the_environment(monkeypatch):
|
|
|
79
108
|
)
|
|
80
109
|
|
|
81
110
|
assert config["html_theme_options"]["switcher"]["version_match"] == "v2.3.4"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_installed_package_can_be_preferred(monkeypatch):
|
|
114
|
+
installed_site = str(distribution("MartinPdeS-docs").locate_file(""))
|
|
115
|
+
monkeypatch.setattr(sys, "path", ["checkout", installed_site, "other"])
|
|
116
|
+
|
|
117
|
+
configure(
|
|
118
|
+
project="Example",
|
|
119
|
+
package="MartinPdeS-docs",
|
|
120
|
+
prefer_installed_package=True,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
assert sys.path[0] == installed_site
|
|
124
|
+
assert sys.path.count(installed_site) == 1
|
|
File without changes
|
{martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/MartinPdeS_docs.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{martinpdes_docs-0.2.0 → martinpdes_docs-0.2.3}/martinpdes_docs/static/martinpdes_layout.css
RENAMED
|
File without changes
|
|
File without changes
|