2
2
3
3
from datetime import datetime
4
4
import os
5
+ from pathlib import Path
6
+ from typing import List
5
7
6
8
from github import Github
9
+ import pyvista
10
+ import requests
7
11
from sphinx .builders .latex import LaTeXBuilder
8
12
9
- LaTeXBuilder .supported_image_types = ["image/png" , "image/pdf" , "image/svg+xml" ]
10
-
11
13
from ansys_sphinx_theme import (
12
14
__version__ ,
13
15
ansys_favicon ,
21
23
watermark ,
22
24
)
23
25
26
+ THIS_PATH = Path (__file__ ).parent .resolve ()
27
+ EXAMPLE_PATH = (THIS_PATH / "examples" / "sphinx_examples" ).resolve ()
28
+ API_TEMPLATES = (THIS_PATH / "examples" / "autoapi" ).resolve ()
29
+
24
30
# Project information
25
31
project = "ansys_sphinx_theme"
26
32
copyright = f"(c) { datetime .now ().year } ANSYS, Inc. All rights reserved"
29
35
cname = os .getenv ("DOCUMENTATION_CNAME" , "sphinxdocs.ansys.com" )
30
36
switcher_version = get_version_match (__version__ )
31
37
32
- # use the default ansys logo
38
+ # HTML configuration
33
39
html_logo = ansys_logo_black
40
+ html_favicon = ansys_favicon
34
41
html_theme = "ansys_sphinx_theme"
42
+ html_short_title = html_title = "Ansys Sphinx Theme"
43
+ # static path
44
+ html_static_path = ["_static" ]
45
+ # Add any paths that contain templates here, relative to this directory.
46
+ templates_path = ["_templates" ]
35
47
36
-
37
- # In the html_context dictionary in conf.py
38
48
html_context = {
39
49
"github_user" : "ansys" ,
40
50
"github_repo" : "ansys-sphinx-theme" ,
41
51
"github_version" : "main" ,
42
52
"doc_path" : "doc/source" ,
43
53
}
44
54
45
-
46
- # specify the location of your github repo
47
55
html_theme_options = {
48
56
"github_url" : "https://github.com/ansys/ansys-sphinx-theme" ,
49
57
"contact_mail" :
"[email protected] " ,
61
69
f"ansys-sphinx-theme-v{ convert_version_to_pymeilisearch (__version__ )} " : "ansys-sphinx-theme" , # noqa: E501
62
70
},
63
71
},
72
+ "ansys_sphinx_theme_autoapi" : {
73
+ "project" : project ,
74
+ "directory" : "src/ansys_sphinx_theme/examples" ,
75
+ "output" : "examples/" ,
76
+ "own_page_level" : "function" ,
77
+ },
64
78
}
65
79
66
- html_short_title = html_title = "Ansys Sphinx Theme"
67
-
68
80
# Sphinx extensions
69
81
extensions = [
82
+ "ansys_sphinx_theme.extension.autoapi" ,
83
+ "nbsphinx" ,
84
+ "numpydoc" ,
70
85
"sphinx.ext.autodoc" ,
71
86
"sphinx.ext.autosummary" ,
72
- "numpydoc" ,
73
87
"sphinx.ext.intersphinx" ,
74
- "notfound.extension " ,
88
+ "sphinx.ext.todo " ,
75
89
"sphinx_copybutton" ,
76
90
"sphinx_design" ,
91
+ "sphinx.ext.intersphinx" ,
92
+ "sphinx.ext.todo" ,
93
+ "sphinx_gallery.gen_gallery" ,
77
94
"sphinx_jinja" ,
95
+ "notfound.extension" ,
78
96
]
79
97
80
98
# Intersphinx mapping
86
104
# numpydoc configuration
87
105
numpydoc_show_class_members = False
88
106
numpydoc_xref_param_type = True
89
-
90
- # Consider enabling numpydoc validation. See:
91
- # https://numpydoc.readthedocs.io/en/latest/validation.html#
92
107
numpydoc_validate = True
93
108
numpydoc_validation_checks = {
94
109
"GL06" , # Found unknown section
95
110
"GL07" , # Sections are in the wrong order.
96
- "GL08" , # The object does not have a docstring
97
111
"GL09" , # Deprecation warning should precede extended summary
98
112
"GL10" , # reST directives {directives} must be followed by two colons
99
113
"SS01" , # No summary found
100
114
"SS02" , # Summary does not start with a capital letter
101
- # "SS03", # Summary does not end with a period
102
115
"SS04" , # Summary contains heading whitespaces
103
- # "SS05", # Summary must start with infinitive verb, not third person
104
- "RT02" , # The first line of the Returns section should contain only the
105
- # type, unless multiple values are being returned"
116
+ "RT02" , # The first line of the Returns section should contain only the type
106
117
}
107
118
108
- # Favicon
109
- html_favicon = ansys_favicon
110
-
111
- # static path
112
- html_static_path = ["_static" ]
113
-
114
- # Add any paths that contain templates here, relative to this directory.
115
- templates_path = ["_templates" ]
119
+ suppress_warnings = ["config.cache" ]
116
120
117
121
# The suffix(es) of source filenames.
118
122
source_suffix = ".rst"
121
125
master_doc = "index"
122
126
123
127
# additional logos for the latex coverpage
128
+ LaTeXBuilder .supported_image_types = ["image/png" , "image/pdf" , "image/svg+xml" ]
124
129
latex_additional_files = [watermark , ansys_logo_white , ansys_logo_white_cropped ]
125
-
126
- # change the preamble of latex with customized title page
127
- # variables are the title of pdf, watermark
128
130
latex_elements = {"preamble" : latex .generate_preamble (html_title )}
129
131
130
132
# Not found page
131
133
notfound_context = {
132
134
"body" : generate_404 (),
133
135
}
134
-
135
136
notfound_no_urls_prefix = True
136
137
137
138
# ONLY FOR ANSYS-SPHINX-THEME
139
+ exclude_patterns = [
140
+ "links.rst" ,
141
+ "examples/sphinx-gallery/README.rst" ,
142
+ "examples/gallery-examples/*.ipynb" ,
143
+ ]
144
+ rst_epilog = ""
145
+ with open ("links.rst" ) as f :
146
+ rst_epilog += f .read ()
147
+
148
+ sphinx_gallery_conf = {
149
+ # path to your examples scripts
150
+ "examples_dirs" : ["examples/sphinx-gallery" ],
151
+ # path where to save gallery generated examples
152
+ "gallery_dirs" : ["examples/gallery-examples" ],
153
+ # Pattern to search for example files
154
+ "filename_pattern" : r"sphinx_gallery\.py" ,
155
+ # Remove the "Download all examples" button from the top level gallery
156
+ "download_all_examples" : False ,
157
+ # Modules for which function level galleries are created. In
158
+ "image_scrapers" : ("pyvista" , "matplotlib" ),
159
+ "default_thumb_file" : "source/_static/pyansys_light_square.png" ,
160
+ }
161
+ nbsphinx_execute = "always"
162
+ nbsphinx_thumbnails = {
163
+ "examples/nbsphinx/jupyter-notebook" : "_static/pyansys_light_square.png" ,
164
+ }
138
165
139
- from pathlib import Path
140
- from typing import List
141
-
142
- import requests
143
-
144
- THIS_PATH = Path (__file__ ).parent .resolve ()
145
-
146
- EXAMPLE_PATH = (THIS_PATH / "examples" / "sphinx_examples" ).resolve ()
166
+ # Ensure that offscreen rendering is used for docs generation
167
+ # Preferred plotting style for documentation
168
+ pyvista .BUILDING_GALLERY = True
147
169
148
- linkcheck_ignore = []
170
+ linkcheck_ignore = ["https://sphinxdocs.ansys.com/version/dev/*" ]
149
171
if switcher_version != "dev" :
150
172
linkcheck_ignore .append (
151
173
f"https://github.com/ansys/ansys-sphinx-theme/releases/tag/v{ __version__ } "
152
174
)
153
175
154
176
155
177
def extract_example_links (
156
- repo_fullname : str , path_relative_to_root : str , exclude_files : List [str ]
178
+ repo_fullname : str , path_relative_to_root : str , exclude_files : List [str ] = []
157
179
) -> List [str ]:
158
180
"""
159
181
Extract example links from a specific GitHub repository.
@@ -175,7 +197,8 @@ def extract_example_links(
175
197
g = Github ()
176
198
repo = g .get_repo (repo_fullname )
177
199
contents = repo .get_contents (path_relative_to_root )
178
-
200
+ if not isinstance (contents , list ):
201
+ contents = [contents ]
179
202
example_links = []
180
203
for content in contents :
181
204
if content .type == "dir" :
@@ -225,4 +248,19 @@ def download_and_process_files(example_links: List[str]) -> List[str]:
225
248
)
226
249
file_names = download_and_process_files (example_links )
227
250
228
- jinja_contexts = {"examples" : {"inputs_examples" : file_names }}
251
+ admonitions_links = extract_example_links (
252
+ "pydata/pydata-sphinx-theme" ,
253
+ "docs/examples/kitchen-sink/admonitions.rst" ,
254
+ )
255
+
256
+ admonitions_links = download_and_process_files (admonitions_links )
257
+ todo_include_todos = True # admonition todo needs this to be True
258
+
259
+ jinja_contexts = {
260
+ "examples" : {"inputs_examples" : file_names },
261
+ "admonitions" : {"inputs_admonitions" : admonitions_links },
262
+ "install_guide" : {
263
+ "version" : f"v{ version } " if not version .endswith ("dev0" ) else "main" ,
264
+ },
265
+ "pdf_guide" : {"version" : get_version_match (__version__ )}, # noqa: E501
266
+ }
0 commit comments