Skip to content

Commit 404befa

Browse files
authored
feat: add documentation build environment to tox.ini (#2015)
* feat: changes implemented * feat: add clean and link environment * feat: server mgmt steps,syntax corrections * feat: modified environment description
1 parent c95bb99 commit 404befa

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

tox.ini

+60-1
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,69 @@ deps =
109109
commands =
110110
pytest {env:PYTEST_PYTHON_FILES} {env:DEBUG} {env:COVERAGE} {env:RERUNS} {env:JUNITXML}
111111

112+
[testenv:doc-{clean,links,html}]
113+
description = Environment for documentation generation
114+
115+
setenv =
116+
SOURCE_DIR = doc/source
117+
BUILD_DIR = doc/build
118+
BUILDER_OPTS = --color -j auto
119+
links: BUILDER = linkcheck
120+
html: BUILDER = html
121+
122+
skip_install =
123+
clean: True
124+
125+
deps =
126+
links,html: -r requirements/requirements_docs.txt
127+
128+
commands_pre =
129+
# Clear any running servers that may be locking resources
130+
html,links: python -c "import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \
131+
html,links: print(f'Killed \{nb_procs} \{proc_name} processes.')"
132+
133+
commands =
134+
# Remove previously rendered documentation
135+
clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}"
136+
137+
# Ensure vtk compatibility
138+
html: python -m pip uninstall --yes vtk
139+
html: python -m pip install --extra-index-url https://wheels.vtk.org vtk-osmesa==9.2.20230527.dev0
140+
141+
# Clean files from previous build
142+
html: python -c "\
143+
html: from os.path import exists; import shutil; \
144+
html: [(shutil.rmtree(p) if exists(p) else None) for p in ['{env:SOURCE_DIR}/images/auto-generated']]; \
145+
html: [(shutil.move(src, dst) if exists(src) else None) for src, dst in \
146+
html: [('{env:SOURCE_DIR}/examples/07-python-operators/plugins', '{env:SOURCE_DIR}/_temp/plugins'), \
147+
html: ('{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress', '{env:SOURCE_DIR}/_temp/04_advanced'), \
148+
html: ('{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results', '{env:SOURCE_DIR}/_temp/12_fluids')]]; \
149+
html: [shutil.rmtree(p) for p in ['{env:SOURCE_DIR}/examples'] if exists(p)]; \
150+
html: [(shutil.move(src, dst) if exists(src) else None) for src, dst in \
151+
html: [('{env:SOURCE_DIR}/_temp/plugins', '{env:SOURCE_DIR}/examples/07-python-operators/plugins'), \
152+
html: ('{env:SOURCE_DIR}/_temp/04_advanced', '{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress'), \
153+
html: ('{env:SOURCE_DIR}/_temp/12_fluids', '{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results')]]; \
154+
html: [shutil.rmtree(p) for p in ['{env:SOURCE_DIR}/_temp'] if exists(p)]"
155+
156+
# Build documentation
157+
html,links: sphinx-build -b {env:BUILDER} {env:SOURCE_DIR} {env:BUILD_DIR}/{env:BUILDER} {env:BUILDER_OPTS}
158+
159+
# Patch pyVista issue with elemental plots by copying necessary images
160+
html: python -c "\
161+
html: import os, shutil, glob; os.makedirs('build/html/_images', exist_ok=True); \
162+
html: [(shutil.copy(src, 'build/html/_images') if os.path.exists(src) else print(f'Source not found: {src}')) for src in \
163+
html: glob.glob('{env:SOURCE_DIR}/examples/04-advanced/02-volume_averaged_stress/*') + glob.glob('{env:SOURCE_DIR}/examples/12-fluids/02-fluids_results/*')]"
164+
165+
166+
commands_post =
167+
# Clear any running servers that may be locking resources
168+
html,links: python -c "import psutil; proc_name = 'Ans.Dpf.Grpc'; nb_procs = len([proc.kill() for proc in psutil.process_iter() if proc_name in proc.name()]); \
169+
html,links: print(f'Killed \{nb_procs} \{proc_name} processes.')"
170+
112171
[testenv:build-wheel]
113172
description = Environment for custom build of package wheels
114173

115174
skip_install = True
116175

117176
commands =
118-
python .ci/build_wheel.py -p {posargs:{on_platform}} -w
177+
python .ci/build_wheel.py -p {posargs:{on_platform}} -w

0 commit comments

Comments
 (0)