MartinPdeS-docs 0.1.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,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: MartinPdeS-docs
3
+ Version: 0.1.0
4
+ Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: sphinx>=7
8
+ Requires-Dist: pydata-sphinx-theme>=0.15
9
+ Requires-Dist: sphinx-design>=0.6
10
+ Requires-Dist: sphinx-gallery>=0.16
11
+ Requires-Dist: pytest>=7
12
+
13
+ # MartinPdeS-docs
14
+
15
+ Shared Sphinx defaults for the MartinPdeS scientific Python repositories.
16
+
17
+ The package intentionally uses a flat layout. A project keeps its own
18
+ documentation content and assets, while this package supplies common Sphinx
19
+ extensions, theme defaults, responsive layout settings, and gallery behavior.
20
+ It also provides the shared author metadata, autodoc defaults, document
21
+ defaults, theme navigation, repository links, version switcher, and output
22
+ metadata used across the package family.
23
+
24
+ In a project's `docs/source/conf.py`:
25
+
26
+ ```python
27
+ from martinpdes_docs import configure
28
+
29
+ globals().update(
30
+ configure(
31
+ project="PackLab",
32
+ package="PackLab",
33
+ repository="MartinPdeS/PackLab",
34
+ logo="_static/logo.png",
35
+ favicon="_static/favicon.png",
36
+ )
37
+ )
38
+ ```
39
+
40
+ Project-specific values can be assigned below this call to override any
41
+ shared default.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ MartinPdeS_docs.egg-info/PKG-INFO
4
+ MartinPdeS_docs.egg-info/SOURCES.txt
5
+ MartinPdeS_docs.egg-info/dependency_links.txt
6
+ MartinPdeS_docs.egg-info/requires.txt
7
+ MartinPdeS_docs.egg-info/top_level.txt
8
+ martinpdes_docs/__init__.py
9
+ martinpdes_docs/sphinx.py
10
+ tests/test_configuration.py
@@ -0,0 +1,5 @@
1
+ sphinx>=7
2
+ pydata-sphinx-theme>=0.15
3
+ sphinx-design>=0.6
4
+ sphinx-gallery>=0.16
5
+ pytest>=7
@@ -0,0 +1 @@
1
+ martinpdes_docs
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: MartinPdeS-docs
3
+ Version: 0.1.0
4
+ Summary: Shared Sphinx configuration for MartinPdeS scientific Python packages.
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: sphinx>=7
8
+ Requires-Dist: pydata-sphinx-theme>=0.15
9
+ Requires-Dist: sphinx-design>=0.6
10
+ Requires-Dist: sphinx-gallery>=0.16
11
+ Requires-Dist: pytest>=7
12
+
13
+ # MartinPdeS-docs
14
+
15
+ Shared Sphinx defaults for the MartinPdeS scientific Python repositories.
16
+
17
+ The package intentionally uses a flat layout. A project keeps its own
18
+ documentation content and assets, while this package supplies common Sphinx
19
+ extensions, theme defaults, responsive layout settings, and gallery behavior.
20
+ It also provides the shared author metadata, autodoc defaults, document
21
+ defaults, theme navigation, repository links, version switcher, and output
22
+ metadata used across the package family.
23
+
24
+ In a project's `docs/source/conf.py`:
25
+
26
+ ```python
27
+ from martinpdes_docs import configure
28
+
29
+ globals().update(
30
+ configure(
31
+ project="PackLab",
32
+ package="PackLab",
33
+ repository="MartinPdeS/PackLab",
34
+ logo="_static/logo.png",
35
+ favicon="_static/favicon.png",
36
+ )
37
+ )
38
+ ```
39
+
40
+ Project-specific values can be assigned below this call to override any
41
+ shared default.
@@ -0,0 +1,29 @@
1
+ # MartinPdeS-docs
2
+
3
+ Shared Sphinx defaults for the MartinPdeS scientific Python repositories.
4
+
5
+ The package intentionally uses a flat layout. A project keeps its own
6
+ documentation content and assets, while this package supplies common Sphinx
7
+ extensions, theme defaults, responsive layout settings, and gallery behavior.
8
+ It also provides the shared author metadata, autodoc defaults, document
9
+ defaults, theme navigation, repository links, version switcher, and output
10
+ metadata used across the package family.
11
+
12
+ In a project's `docs/source/conf.py`:
13
+
14
+ ```python
15
+ from martinpdes_docs import configure
16
+
17
+ globals().update(
18
+ configure(
19
+ project="PackLab",
20
+ package="PackLab",
21
+ repository="MartinPdeS/PackLab",
22
+ logo="_static/logo.png",
23
+ favicon="_static/favicon.png",
24
+ )
25
+ )
26
+ ```
27
+
28
+ Project-specific values can be assigned below this call to override any
29
+ shared default.
@@ -0,0 +1,5 @@
1
+ """Shared Sphinx configuration for MartinPdeS projects."""
2
+
3
+ from .sphinx import configure
4
+
5
+ __all__ = ["configure"]
@@ -0,0 +1,155 @@
1
+ """Configurable defaults for the shared project documentation sites."""
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+
7
+ def configure(
8
+ *,
9
+ project: str,
10
+ package: str,
11
+ author: str = "Martin Poinsinet de Sivry-Houle",
12
+ logo: str = "_static/logo.svg",
13
+ favicon: str = "_static/favicon.svg",
14
+ repository: str | None = None,
15
+ extensions: list[str] | None = None,
16
+ html_theme_options: dict | None = None,
17
+ sphinx_gallery_conf: dict | None = None,
18
+ version: str = "latest",
19
+ source_suffix: str = ".rst",
20
+ master_doc: str = "index",
21
+ ) -> dict:
22
+ """Return a Sphinx configuration dictionary for a project.
23
+
24
+ In a project's ``conf.py`` use ``globals().update(configure(...))`` and
25
+ keep project-specific settings below that call so they remain easy to
26
+ override.
27
+ """
28
+ default_extensions = [
29
+ "sphinx.ext.autodoc",
30
+ "sphinx.ext.autosummary",
31
+ "sphinx.ext.intersphinx",
32
+ "sphinx.ext.napoleon",
33
+ "sphinx.ext.viewcode",
34
+ "sphinx.ext.todo",
35
+ "sphinx_design",
36
+ "sphinx_gallery.gen_gallery",
37
+ ]
38
+ options = {
39
+ "logo": {"text": project, "image": logo},
40
+ "navigation_with_keys": True,
41
+ "show_nav_level": 2,
42
+ "navbar_align": "content",
43
+ "show_toc_level": 2,
44
+ "navbar_end": ["version-switcher", "navbar-icon-links"],
45
+ "show_prev_next": False,
46
+ "show_version_warning_banner": True,
47
+ "footer_start": ["copyright"],
48
+ "footer_end": ["sphinx-version", "theme-version"],
49
+ "pygments_light_style": "default",
50
+ "pygments_dark_style": "github-dark",
51
+ "use_edit_page_button": bool(repository),
52
+ }
53
+ if repository:
54
+ owner, repo = repository.split("/", 1)
55
+ options["icon_links"] = [
56
+ {
57
+ "name": "GitHub",
58
+ "url": f"https://github.com/{repository}",
59
+ "icon": "fa-brands fa-github",
60
+ },
61
+ {
62
+ "name": "PyPI",
63
+ "url": f"https://pypi.org/project/{package}/",
64
+ "icon": "fa-solid fa-box",
65
+ },
66
+ {
67
+ "name": "Anaconda",
68
+ "url": f"https://anaconda.org/{repository.split('/')[0]}/{package}",
69
+ "icon": "fa-brands fa-python",
70
+ },
71
+ ]
72
+ options["switcher"] = {
73
+ "json_url": f"https://raw.githubusercontent.com/{repository}/documentation_page/version_switcher.json",
74
+ "version_match": version,
75
+ }
76
+
77
+ html_context = {}
78
+ if repository:
79
+ owner, repo = repository.split("/", 1)
80
+ ref_name = os.getenv("GITHUB_REF_NAME", "master")
81
+ html_context.update(
82
+ {
83
+ "github_user": owner,
84
+ "github_repo": repo,
85
+ "github_version": ref_name,
86
+ }
87
+ )
88
+ if html_theme_options:
89
+ options.update(html_theme_options)
90
+
91
+ gallery = {
92
+ "examples_dirs": "../examples/",
93
+ "gallery_dirs": "gallery/",
94
+ "image_scrapers": ("matplotlib",),
95
+ "ignore_pattern": "/__",
96
+ "filename_pattern": r".*\.py",
97
+ "plot_gallery": True,
98
+ "thumbnail_size": [600, 600],
99
+ "download_all_examples": False,
100
+ "line_numbers": False,
101
+ "remove_config_comments": True,
102
+ "capture_repr": ("_repr_html_", "__repr__"),
103
+ "nested_sections": True,
104
+ }
105
+ if sphinx_gallery_conf:
106
+ gallery.update(sphinx_gallery_conf)
107
+
108
+ return {
109
+ "project": project,
110
+ "package": package,
111
+ "author": author,
112
+ "copyright": author,
113
+ "extensions": extensions or default_extensions,
114
+ "exclude_patterns": ["_build", "Thumbs.db", ".DS_Store"],
115
+ "suppress_warnings": ["config.cache"],
116
+ "html_theme": "pydata_sphinx_theme",
117
+ "html_theme_options": options,
118
+ "html_context": html_context,
119
+ "html_logo": logo,
120
+ "html_favicon": favicon,
121
+ "html_static_path": ["_static"],
122
+ "templates_path": ["_templates"],
123
+ "html_css_files": ["default.css", "layout.css"],
124
+ "autodoc_typehints": "description",
125
+ "autodoc_default_options": {
126
+ "members": False,
127
+ "members-order": "bysource",
128
+ "undoc-members": False,
129
+ "show-inheritance": True,
130
+ },
131
+ "napoleon_google_docstring": False,
132
+ "napoleon_numpy_docstring": True,
133
+ "autosectionlabel_prefix_document": True,
134
+ "numpydoc_show_class_members": False,
135
+ "add_module_names": False,
136
+ "source_suffix": source_suffix,
137
+ "master_doc": master_doc,
138
+ "language": "en",
139
+ "highlight_language": "python3",
140
+ "exclude_trees": [],
141
+ "pygments_style": "sphinx",
142
+ "autosummary_generate": True,
143
+ "htmlhelp_basename": f"{package}doc",
144
+ "latex_elements": {},
145
+ "latex_documents": [(master_doc, f"{package}.tex", f"{package} Documentation", author, "manual")],
146
+ "man_pages": [(master_doc, package.lower(), f"{package} Documentation", [author], 1)],
147
+ "texinfo_documents": [
148
+ (master_doc, package, f"{package} Documentation", author, package,
149
+ f"Documentation for {package}.", "Miscellaneous")
150
+ ],
151
+ "epub_title": project,
152
+ "epub_exclude_files": ["search.html"],
153
+ "sphinx_gallery_conf": gallery,
154
+ "_martinpdes_package_root": str(Path(__file__).parent),
155
+ }
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "MartinPdeS-docs"
7
+ version = "0.1.0"
8
+ description = "Shared Sphinx configuration for MartinPdeS scientific Python packages."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "sphinx>=7",
13
+ "pydata-sphinx-theme>=0.15",
14
+ "sphinx-design>=0.6",
15
+ "sphinx-gallery>=0.16",
16
+ "pytest>=7",
17
+ ]
18
+
19
+ [tool.setuptools.packages.find]
20
+ include = ["martinpdes_docs*"]
21
+
22
+ [tool.pytest.ini_options]
23
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,29 @@
1
+ from martinpdes_docs import configure
2
+
3
+
4
+ def test_configuration_has_project_overrides():
5
+ config = configure(project="Example", package="example", repository="MartinPdeS/Example")
6
+
7
+ assert config["project"] == "Example"
8
+ assert config["package"] == "example"
9
+ assert config["html_logo"] == "_static/logo.svg"
10
+ assert config["html_static_path"] == ["_static"]
11
+ assert config["templates_path"] == ["_templates"]
12
+ assert config["html_css_files"] == ["default.css", "layout.css"]
13
+ assert config["epub_exclude_files"] == ["search.html"]
14
+ assert config["sphinx_gallery_conf"]["image_scrapers"] == ("matplotlib",)
15
+ assert config["sphinx_gallery_conf"]["thumbnail_size"] == [600, 600]
16
+ assert "github_url" not in config["html_theme_options"]
17
+ assert config["html_context"]["github_repo"] == "Example"
18
+
19
+
20
+ def test_custom_extensions_and_theme_options_are_preserved():
21
+ config = configure(
22
+ project="Example",
23
+ package="example",
24
+ extensions=["custom.extension"],
25
+ html_theme_options={"announcement": "Hello"},
26
+ )
27
+
28
+ assert config["extensions"] == ["custom.extension"]
29
+ assert config["html_theme_options"]["announcement"] == "Hello"