Skip to content

Commit eafc9ee

Browse files
authored
Build Examples in documentation automatically (#173)
1 parent eda3a41 commit eafc9ee

27 files changed

+237
-249
lines changed

.github/workflows/ci_cd.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,12 @@ jobs:
9696
sudo apt update
9797
sudo apt install latexmk texlive-latex-extra
9898
99-
- name: Generate the documentation with tox
100-
run: tox -e doc
101-
102-
- name: Upload HTML Documentation
103-
uses: actions/upload-artifact@v4
99+
- name: "Run Ansys documentation building action"
100+
uses: ansys/actions/doc-build@v8
104101
with:
105-
name: documentation-html
106-
path: doc/_build/html
107-
retention-days: 7
102+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
103+
check-links: false
104+
sphinxopts: "-j auto -W --color --keep-going"
108105

109106
smoke-tests:
110107
name: Build and Smoke tests

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ instance/
7575

7676
# Sphinx documentation
7777
doc/_build/
78+
doc/source/examples/*
79+
doc/**/sg_execution_times.rst
7880

7981
# PyBuilder
8082
.pybuilder/

CONTRIBUTORS.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Project Lead or Owner
44

55
* [Michal Pawlik](https://github.com/nezgrath)
6-
* [Oliver Koenig](https://github.com/ojkoenig)
76

87
## Individual Contributors
98

doc/source/api/client.rst

-51
This file was deleted.

doc/source/api/data_transfer.rst

-25
This file was deleted.

doc/source/api/exceptions.rst

-21
This file was deleted.

doc/source/api/index.rst

-14
This file was deleted.

doc/source/conf.py

+93-17
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,50 @@
4040

4141
# Sphinx extensions
4242
extensions = [
43-
"sphinx.ext.autodoc",
44-
"sphinx.ext.autosummary",
4543
"sphinx.ext.intersphinx",
4644
"sphinx_copybutton",
4745
"sphinx_design",
48-
"sphinx_tabs.tabs",
49-
"sphinxcontrib.autodoc_pydantic",
5046
"sphinx_jinja",
47+
"numpydoc",
48+
"ansys_sphinx_theme.extension.autoapi",
49+
"sphinx_gallery.gen_gallery",
5150
]
5251

5352
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
5453

54+
nbsphinx_execute = "always"
55+
sphinx_gallery_conf = {
56+
# path to your examples scripts
57+
"examples_dirs": ["../../examples"],
58+
# path where to save gallery generated examples
59+
"gallery_dirs": ["examples"],
60+
# Pattern to search for example files
61+
"filename_pattern": r".*\.py",
62+
"run_stale_examples": False, # Do not re-run examples
63+
"plot_gallery": False,
64+
# Remove the "Download all examples" button from the top level gallery
65+
"download_all_examples": False,
66+
# Sort gallery example by file name instead of number of lines (default)
67+
# directory where function granular galleries are stored
68+
"backreferences_dir": None,
69+
# Modules for which function level galleries are created in
70+
"doc_module": "ansys-hps-data-transfer-client",
71+
"ignore_pattern": "flycheck*",
72+
"thumbnail_size": (350, 350),
73+
"remove_config_comments": True,
74+
"show_signature": False,
75+
}
76+
77+
5578
# Intersphinx mapping
5679
intersphinx_mapping = {
5780
"python": ("https://docs.python.org/3", None),
58-
# kept here as an example
59-
# "scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
60-
# "numpy": ("https://numpy.org/devdocs", None),
61-
# "matplotlib": ("https://matplotlib.org/stable", None),
62-
# "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
63-
# "pyvista": ("https://docs.pyvista.org/", None),
64-
# "grpc": ("https://grpc.github.io/grpc/python/", None),
81+
#"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
82+
"numpy": ("https://numpy.org/devdocs", None),
83+
#"matplotlib": ("https://matplotlib.org/stable", None),
84+
#"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
85+
#"pyvista": ("https://docs.pyvista.org/", None),
86+
#"grpc": ("https://grpc.github.io/grpc/python/", None),
6587
}
6688

6789
# numpydoc configuration
@@ -74,22 +96,35 @@
7496
numpydoc_validation_checks = {
7597
"GL06", # Found unknown section
7698
"GL07", # Sections are in the wrong order.
77-
"GL08", # The object does not have a docstring
99+
#"GL08", # The object does not have a docstring
78100
"GL09", # Deprecation warning should precede extended summary
79101
"GL10", # reST directives {directives} must be followed by two colons
80102
"SS01", # No summary found
81-
"SS02", # Summary does not start with a capital letter
103+
# "SS02", # Summary does not start with a capital letter
82104
# "SS03", # Summary does not end with a period
83105
"SS04", # Summary contains heading whitespaces
84106
# "SS05", # Summary must start with infinitive verb, not third person
85107
"RT02", # The first line of the Returns section should contain only the
86108
# type, unless multiple values are being returned"
87109
}
88110

89-
# autodoc/autosummary flags
90-
autoclass_content = "both"
91-
# autodoc_default_flags = ["members"]
92-
autosummary_generate = True
111+
112+
autoapi_type = "python"
113+
autoapi_dirs = ["../../src"]
114+
autoapi_generate_api_docs = True
115+
autoapi_root = "api"
116+
117+
# Configuration for Sphinx autoapi
118+
suppress_warnings = [
119+
"autoapi.duplicate_object",
120+
"design.grid",
121+
"docutils",
122+
"toc.not_readable",
123+
"toc.not_included",
124+
"toc.excluded",
125+
"ref.python",
126+
"design.fa-build",
127+
]
93128

94129

95130
# static path
@@ -104,6 +139,7 @@
104139
# The master toctree document.
105140
master_doc = "index"
106141

142+
107143
# Keep these while the repository is private
108144
linkcheck_ignore = [
109145
"https://github.com/ansys-internal/hps-data-transfer-client//*",
@@ -115,3 +151,43 @@
115151
# available until the release is published.
116152
if switcher_version != "dev":
117153
linkcheck_ignore.append(f"https://github.com/ansys/ansys.hps.data_transfer_client/releases/tag/v{__version__}")
154+
155+
# Examples gallery customization
156+
nbsphinx_execute = "always"
157+
158+
# -- Declare the Jinja context -----------------------------------------------
159+
exclude_patterns = [
160+
"examples/**/*.txt",
161+
"api/client/client/index.rst",
162+
"api/client/index.rst",
163+
]
164+
165+
BUILD_API = True
166+
if not BUILD_API:
167+
exclude_patterns.append("autoapi")
168+
169+
BUILD_EXAMPLES = True
170+
if not BUILD_EXAMPLES:
171+
exclude_patterns.append("examples/**")
172+
exclude_patterns.append("examples.rst")
173+
174+
jinja_contexts = {
175+
"main_toctree": {
176+
"build_api": BUILD_API,
177+
"build_examples": BUILD_EXAMPLES,
178+
}
179+
}
180+
181+
182+
def prepare_jinja_env(jinja_env) -> None:
183+
"""Customize the jinja env.
184+
185+
Notes
186+
-----
187+
See https://jinja.palletsprojects.com/en/3.0.x/api/#jinja2.Environment
188+
189+
"""
190+
jinja_env.globals["project_name"] = project
191+
192+
193+
autoapi_prepare_jinja_env = prepare_jinja_env

doc/source/examples/ex_permissions.rst

-13
This file was deleted.

doc/source/examples/ex_run_async.rst

-13
This file was deleted.

doc/source/examples/ex_startup.rst

-13
This file was deleted.

doc/source/examples/ex_transfer_files.rst

-13
This file was deleted.

0 commit comments

Comments
 (0)