Skip to content

Commit 2f378ee

Browse files
authored
Merge branch 'doc/new-tutorials-section' into doc/tutorials_allow_version_requirement
2 parents 8cc0f1e + de12b37 commit 2f378ee

File tree

5 files changed

+58
-41
lines changed

5 files changed

+58
-41
lines changed

.github/workflows/docs.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,41 @@ jobs:
117117
run: |
118118
choco install pandoc
119119
120+
- name: "Restore doc build cache"
121+
id: cache-doc-build-restore
122+
uses: actions/cache/restore@v4
123+
with:
124+
path: |
125+
doc/source/examples
126+
# Cache key is composed of branch name, ansys version, hash of requirements_doc,
127+
# and run_id to work around immutability
128+
# We should also track version of pandoc, of graphviz, of packages installed by headless-display, and even of pydpf-core?
129+
key: doc-build-${{ github.ref_name }}-DPF_${{inputs.ANSYS_VERSION}}${{inputs.standalone_suffix}}-${{hashfiles('requirements/requirements_docs.txt')}}-${{ github.run_id }}
130+
restore-keys: |
131+
doc-build-${{ github.ref_name }}-DPF_${{inputs.ANSYS_VERSION}}${{inputs.standalone_suffix}}-${{hashfiles('requirements/requirements_docs.txt')}}-
132+
doc-build-master-DPF_${{inputs.ANSYS_VERSION}}${{inputs.standalone_suffix}}-${{hashfiles('requirements/requirements_docs.txt')}}-
133+
120134
- name: "Build HTML Documentation"
121135
shell: bash
122136
run: |
123137
tox -e doc-html --installpkg dist/${{ steps.wheel.outputs.wheel_name }} -x testenv:doc-html.setenv+='VIRTUALENV_SYSTEM_SITE_PACKAGES=true'
124138
125-
- name: "Retrieve package version"
126-
shell: bash
127-
run: |
128-
echo "VERSION=$(python -c "from ansys.dpf.${{env.MODULE}} import __version__; print(__version__)")" >> GITHUB_OUTPUT
129-
echo "${{env.PACKAGE_NAME}} version is: $(python -c "from ansys.dpf.${{env.MODULE}} import __version__; print(__version__)")"
130-
id: version
131-
if: always()
132-
133139
- name: "Upload Documentation Build log"
134140
uses: actions/upload-artifact@v4
135141
with:
136142
name: doc-${{env.PACKAGE_NAME}}-log
137143
path: doc/*.txt
138144
if: always()
139145

146+
- name: "Save doc-build cache"
147+
id: cache-doc-build-save
148+
uses: actions/cache/save@v4
149+
with:
150+
path: |
151+
doc/build
152+
doc/source/examples
153+
key: ${{ steps.cache-doc-build-restore.outputs.cache-primary-key }}
154+
140155
- name: "Zip HTML Documentation"
141156
shell: pwsh
142157
run: |

doc/source/conf.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
22
from glob import glob
33
import os
4+
import sys
45
from pathlib import Path
56
import subprocess
67

@@ -16,6 +17,9 @@
1617
from ansys.dpf.core import __version__, server, server_factory
1718
from ansys.dpf.core.examples import get_example_required_minimum_dpf_version
1819

20+
# Make sphinx_utilities modules importable
21+
sys.path.append(os.path.join(os.path.dirname(__file__), "../sphinx_utilities"))
22+
1923
# Manage errors
2024
pyvista.set_error_output_file("errors.txt")
2125
# Ensure that offscreen rendering is used for docs generation
@@ -78,7 +82,7 @@ def get_tutorial_version_requirements(tutorial_path: str) -> str:
7882

7983
# Build ignore pattern
8084
ignored_pattern = r"(ignore"
81-
for example in glob(r"../../examples/**/*.py"):
85+
for example in sorted(glob(r"../../examples/**/*.py")):
8286
minimum_version_str = get_example_required_minimum_dpf_version(example)
8387
if float(server_version) - float(minimum_version_str) < -0.05:
8488
example_name = example.split(os.path.sep)[-1]
@@ -152,8 +156,7 @@ def get_tutorial_version_requirements(tutorial_path: str) -> str:
152156
typehints_defaults = "comma"
153157
typehints_use_signature = True
154158
simplify_optional_unions = False
155-
suppress_warnings = ['autosectionlabel.*']
156-
159+
autosectionlabel_prefix_document = True
157160
# Intersphinx mapping
158161
intersphinx_mapping = {
159162
"pyvista": ("https://docs.pyvista.org/", None),
@@ -199,32 +202,6 @@ def get_tutorial_version_requirements(tutorial_path: str) -> str:
199202

200203

201204
# -- Sphinx Gallery Options
202-
from sphinx_gallery.sorting import FileNameSortKey
203-
204-
205-
def reset_servers(gallery_conf, fname, when):
206-
import gc
207-
208-
import psutil
209-
210-
from ansys.dpf.core import server
211-
212-
gc.collect()
213-
server.shutdown_all_session_servers()
214-
215-
proc_name = "Ans.Dpf.Grpc"
216-
nb_procs = 0
217-
for proc in psutil.process_iter():
218-
try:
219-
# check whether the process name matches
220-
if proc_name in proc.name():
221-
proc.kill()
222-
nb_procs += 1
223-
except psutil.NoSuchProcess:
224-
pass
225-
print(f"Counted {nb_procs} {proc_name} processes {when} example {fname}.")
226-
227-
228205
sphinx_gallery_conf = {
229206
# convert rst to md for ipynb
230207
"pypandoc": True,
@@ -241,15 +218,15 @@ def reset_servers(gallery_conf, fname, when):
241218
# Remove the "Download all examples" button from the top level gallery
242219
"download_all_examples": False,
243220
# Sort gallery example by file name instead of number of lines (default)
244-
"within_subsection_order": FileNameSortKey,
221+
"within_subsection_order": "FileNameSortKey",
245222
# directory where function granular galleries are stored
246223
"backreferences_dir": None,
247224
"image_scrapers": ("pyvista", "matplotlib"),
248225
# 'first_notebook_cell': ("%matplotlib inline\n"
249226
# "from pyvista import set_plot_theme\n"
250227
# "set_plot_theme('document')"),
251228
"reset_modules_order": 'both',
252-
"reset_modules": (reset_servers,),
229+
"reset_modules": ("reset_servers.reset_servers",),
253230
}
254231

255232

@@ -308,6 +285,9 @@ def reset_servers(gallery_conf, fname, when):
308285
"design.grid",
309286
"config.cache",
310287
"design.fa-build",
288+
"autosectionlabel.*",
289+
"ref.python",
290+
"toc.not_included"
311291
]
312292

313293
# Add any paths that contain custom static files (such as style sheets) here,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
def reset_servers(gallery_conf, fname, when):
3+
import gc
4+
5+
import psutil
6+
7+
from ansys.dpf.core import server
8+
9+
gc.collect()
10+
server.shutdown_all_session_servers()
11+
12+
proc_name = "Ans.Dpf.Grpc"
13+
nb_procs = 0
14+
for proc in psutil.process_iter():
15+
try:
16+
# check whether the process name matches
17+
if proc_name in proc.name():
18+
proc.kill()
19+
nb_procs += 1
20+
except psutil.NoSuchProcess:
21+
pass
22+
print(f"Counted {nb_procs} {proc_name} processes {when} example {fname}.")

requirements/requirements_docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ansys-sphinx-theme[autoapi]==1.4.4
1+
ansys-sphinx-theme[autoapi]==1.5.3
22
enum-tools[sphinx]==0.13.0
33
graphviz==0.21
44
imageio==2.37.0

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ commands =
227227
# Remove previously rendered documentation
228228
clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}"
229229

230-
# Clean files from previous build
230+
# Clean examples from previous build
231231
clean: python -c "\
232232
clean: from os.path import exists; import shutil; \
233233
clean: [(shutil.rmtree(p) if exists(p) else None) for p in ['{env:SOURCE_DIR}/images/auto-generated']]; \

0 commit comments

Comments
 (0)