-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconf.py
More file actions
236 lines (202 loc) · 7.09 KB
/
conf.py
File metadata and controls
236 lines (202 loc) · 7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
"""
Configuration file for the Sphinx documentation builder.
For the full list of built-in configuration values, see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""
from __future__ import annotations
import datetime
from importlib.metadata import version as get_version
import os
from pathlib import Path
import sys
# Add the package to the Python path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
# Mock imports for documentation building
autodoc_mock_imports = [
"gmsh",
"scooby",
"numpy",
"shapely",
"pyvista",
"numpy.typing",
"shapely.geometry",
"pyvista.plotting.utilities.sphinx_gallery",
]
# Try to import pyvista for gallery setup, but skip if not available
try:
import pyvista
from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper
pyvista.set_error_output_file("errors.txt")
pyvista.OFF_SCREEN = True # Not necessary - simply an insurance policy
pyvista.set_plot_theme("document")
pyvista.BUILDING_GALLERY = True
os.environ["PYVISTA_BUILDING_GALLERY"] = "true"
if os.environ.get("READTHEDOCS") or os.environ.get("CI"):
pyvista.start_xvfb()
has_pyvista = True
except ImportError:
# Create a mock DynamicScraper for when pyvista is not available
class DynamicScraper:
"""Mock DynamicScraper class for when pyvista is not available."""
has_pyvista = False
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "scikit-gmsh"
copyright_years = f"2024 - {datetime.datetime.now(datetime.UTC).year}"
copyright = "2024, Tetsuo Koyama" # noqa: A001
author = f"{project} Contributors"
on_rtd = os.environ.get("READTHEDOCS")
if on_rtd:
# https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#including-content-based-on-tags
# https://www.sphinx-doc.org/en/master/usage/configuration.html#conf-tags
tags.add("on_rtd") # noqa: F821
# The full version, including alpha/beta/rc tags
release = get_version("scikit-gmsh")
release = release.removesuffix("+dirty")
# docs src directory
src_dir = Path(__file__).absolute().parent
root_dir = src_dir.parents[1]
package_dir = root_dir / "src"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"myst_parser",
"sphinx_design",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
]
# Add pyvista extensions and gallery if available
if has_pyvista:
try:
import importlib.util
if importlib.util.find_spec("sphinx_gallery"):
extensions.extend(["pyvista.ext.plot_directive", "pyvista.ext.viewer_directive", "sphinx_gallery.gen_gallery"])
has_gallery = True
else:
has_gallery = False
except ImportError:
has_gallery = False
else:
has_gallery = False
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# -- Autodoc configuration --------------------------------------------------
autodoc_default_options = {
"members": True,
"member-order": "bysource",
"special-members": "__init__",
"undoc-members": True,
"exclude-members": "__weakref__",
}
autosummary_generate = True
autosummary_imported_members = True
# -- Napoleon settings -------------------------------------------------------
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
# -- Intersphinx configuration ----------------------------------------------
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"pyvista": ("https://docs.pyvista.org/", None),
"shapely": ("https://shapely.readthedocs.io/en/stable/", None),
}
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "sphinx_book_theme"
html_logo = "_static/small_logo.svg"
html_context = {
"github_url": "https://github.com",
"github_user": "pyvista",
"github_repo": "scikit-gmsh",
"github_version": "main",
"doc_path": "docs/src",
}
html_theme_options = {
"home_page_in_toc": True,
"icon_links": [
{
"name": "GitHub Discussions",
"url": "https://github.com/pyvista/scikit-gmsh/discussions",
"icon": "fa fa-comments fa-fw",
},
{
"name": "GitHub Issues",
"url": "https://github.com/pyvista/scikit-gmsh/issues",
"icon": "fa-brands fa-square-github fa-fw",
},
{
"name": "GitHub Pulls",
"url": "https://github.com/pyvista/scikit-gmsh/pulls",
"icon": "fa-brands fa-github-alt fa-fw",
},
],
"navigation_with_keys": False,
"path_to_docs": "docs/src",
"repository_branch": "main",
"repository_url": "https://github.com/pyvista/scikit-gmsh",
"show_prev_next": True,
"show_toc_level": 4,
"toc_title": "On this page",
"use_download_button": True,
"use_edit_page_button": False,
"use_fullscreen_button": True,
"use_issues_button": False,
"use_repository_button": True,
"use_sidenotes": True,
"use_source_button": False,
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [
"_static",
]
html_css_files = [
"style.css",
"theme_overrides.css",
]
# -- MyST settings -----------------------------------------------------------
myst_enable_extensions = [
"amsmath",
"attrs_block",
"attrs_inline",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]
# -- sphinx_gallery settings -------------------------------------------------
# Gallery configuration only if available
if has_gallery:
sphinx_gallery_conf = {
"backreferences_dir": None,
"doc_module": "pyvista",
"download_all_examples": False,
"examples_dirs": ["../examples/"],
"filename_pattern": r"\.py",
"first_notebook_cell": ("%matplotlib inline\nfrom pyvista import set_plot_theme\nset_plot_theme('document')\n"),
"gallery_dirs": ["./examples"],
"image_scrapers": (DynamicScraper(), "matplotlib"),
"pypandoc": True,
"remove_config_comments": True,
"reset_modules_order": "both",
}