Skip to content

Commit cb3c999

Browse files
committed
Fix autoapi detection of changed configuration
1 parent 9cd9511 commit cb3c999

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

doc/source/conf.py

Lines changed: 7 additions & 29 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
@@ -62,7 +66,7 @@
6266
ignored_pattern = r"(ignore"
6367
header_flag = "\"\"\""
6468
note_flag = r".. note::"
65-
for example in glob(r"../../examples/**/*.py"):
69+
for example in sorted(glob(r"../../examples/**/*.py")):
6670
minimum_version_str = get_example_required_minimum_dpf_version(example)
6771
if float(server_version) - float(minimum_version_str) < -0.05:
6872
example_name = example.split(os.path.sep)[-1]
@@ -164,32 +168,6 @@
164168

165169

166170
# -- Sphinx Gallery Options
167-
from sphinx_gallery.sorting import FileNameSortKey
168-
169-
170-
def reset_servers(gallery_conf, fname, when):
171-
import gc
172-
173-
import psutil
174-
175-
from ansys.dpf.core import server
176-
177-
gc.collect()
178-
server.shutdown_all_session_servers()
179-
180-
proc_name = "Ans.Dpf.Grpc"
181-
nb_procs = 0
182-
for proc in psutil.process_iter():
183-
try:
184-
# check whether the process name matches
185-
if proc_name in proc.name():
186-
proc.kill()
187-
nb_procs += 1
188-
except psutil.NoSuchProcess:
189-
pass
190-
print(f"Counted {nb_procs} {proc_name} processes {when} example {fname}.")
191-
192-
193171
sphinx_gallery_conf = {
194172
# convert rst to md for ipynb
195173
"pypandoc": True,
@@ -206,15 +184,15 @@ def reset_servers(gallery_conf, fname, when):
206184
# Remove the "Download all examples" button from the top level gallery
207185
"download_all_examples": False,
208186
# Sort gallery example by file name instead of number of lines (default)
209-
"within_subsection_order": FileNameSortKey,
187+
"within_subsection_order": "FileNameSortKey",
210188
# directory where function granular galleries are stored
211189
"backreferences_dir": None,
212190
"image_scrapers": ("pyvista", "matplotlib"),
213191
# 'first_notebook_cell': ("%matplotlib inline\n"
214192
# "from pyvista import set_plot_theme\n"
215193
# "set_plot_theme('document')"),
216194
"reset_modules_order": 'both',
217-
"reset_modules": (reset_servers,),
195+
"reset_modules": ("reset_servers.reset_servers",),
218196
}
219197

220198

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}.")

0 commit comments

Comments
 (0)