11from datetime import datetime
22from glob import glob
33import os
4+ import sys
45from pathlib import Path
56import subprocess
67
1617from ansys .dpf .core import __version__ , server , server_factory
1718from 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
2024pyvista .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
8084ignored_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:
152156typehints_defaults = "comma"
153157typehints_use_signature = True
154158simplify_optional_unions = False
155- suppress_warnings = ['autosectionlabel.*' ]
156-
159+ autosectionlabel_prefix_document = True
157160# Intersphinx mapping
158161intersphinx_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-
228205sphinx_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,
0 commit comments