Skip to content

Commit 3852478

Browse files
authored
doc(tutorials): allow version requirement for tutorials (#2463)
1 parent de12b37 commit 3852478

File tree

7 files changed

+166
-112
lines changed

7 files changed

+166
-112
lines changed

doc/source/_static/custom.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
.sd-bg-text-fluent{color: Black}
1515
.sd-bg-cfx{background-color: LightSeaGreen}
1616
.sd-bg-text-cfx{color: Black}
17+
.sd-hide-link-text{height: 0}

doc/source/conf.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# Make sphinx_utilities modules importable
2121
sys.path.append(os.path.join(os.path.dirname(__file__), "../sphinx_utilities"))
22+
from version_filtering import get_tutorial_version_requirements
2223

2324
# Manage errors
2425
pyvista.set_error_output_file("errors.txt")
@@ -59,13 +60,12 @@
5960
)
6061
server_version = server_instance.version
6162
server.shutdown_all_session_servers()
62-
print(f"DPF version: {server_version}")
63-
print(f"DPF install: {server_instance.ansys_path}")
63+
print("".rjust(40, '*'))
64+
print(f"Doc built for DPF server version {server_version} at:\n{server_instance.ansys_path}")
65+
print("".rjust(40, '*'))
6466

6567
# Build ignore pattern
6668
ignored_pattern = r"(ignore"
67-
header_flag = "\"\"\""
68-
note_flag = r".. note::"
6969
for example in sorted(glob(r"../../examples/**/*.py")):
7070
minimum_version_str = get_example_required_minimum_dpf_version(example)
7171
if float(server_version) - float(minimum_version_str) < -0.05:
@@ -76,6 +76,15 @@
7676
ignored_pattern += "|06-distributed_stress_averaging.py"
7777
ignored_pattern += r")"
7878

79+
exclude_patterns = []
80+
for tutorial_file in glob(str(Path("user_guide")/"tutorials"/"**"/"*.rst")):
81+
if Path(tutorial_file).name == "index.rst":
82+
continue
83+
minimum_version_str = get_tutorial_version_requirements(tutorial_file)
84+
if float(server_version) - float(minimum_version_str) < -0.05:
85+
print(f"Tutorial {Path(tutorial_file).name} skipped as it requires DPF {minimum_version_str}.")
86+
exclude_patterns.append(tutorial_file.replace("\\", "/"))
87+
7988
# Autoapi ignore pattern
8089
autoapi_ignore_list = [
8190
"*/log.py",
@@ -118,7 +127,6 @@
118127
"sphinx_design",
119128
"sphinx_jinja",
120129
'sphinx_reredirects',
121-
"ansys_sphinx_theme.extension.autoapi",
122130
"jupyter_sphinx",
123131
]
124132

@@ -163,7 +171,7 @@
163171
# List of patterns, relative to source directory, that match files and
164172
# directories to ignore when looking for source files.
165173
# This pattern also affects html_static_path and html_extra_path.
166-
exclude_patterns = ["links_and_refs.rst"]
174+
exclude_patterns.extend(["links_and_refs.rst"])
167175

168176
# make rst_epilog a variable, so you can add other epilog parts to it
169177
rst_epilog = ""
@@ -411,3 +419,5 @@ def setup(app):
411419
BUILD_EXAMPLES = True if os.environ.get("BUILD_EXAMPLES", "true") == "true" else False
412420
if BUILD_EXAMPLES:
413421
extensions.extend(["sphinx_gallery.gen_gallery"])
422+
423+
print(f"{extensions=}")

doc/source/user_guide/tutorials/custom_operators_and_plugins/custom_operators.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
Custom operators
55
================
66

7+
.. note::
8+
9+
This tutorial requires DPF 11.0 or above.
10+
711
This tutorial shows the basics of creating a custom operator in Python and loading it ont a server for use.
812

9-
.. note:
13+
.. note::
14+
1015
You can create custom operators in CPython using PyDPF-Core for use with DPF in Ansys 2023 R1 and later.
1116

1217
It first presents how to :ref:`create a custom DPF operator<tutorials_custom_operators_and_plugins_custom_operator_create_custom_operator>`
@@ -19,7 +24,8 @@ The next step is to :ref:`load the plugin on the server<tutorials_custom_operato
1924

2025
The final step is to instantiate the custom operator from the client API and :ref:`use it<tutorials_custom_operators_and_plugins_custom_operator_use_the_custom_operator>`.
2126

22-
.. note:
27+
.. note::
28+
2329
In this tutorial the DPF client API used is PyDPF-Core but, once recorded on the server,
2430
you can call the operators of the plugin using any of the DPF client APIs
2531
(C++, CPython, IronPython), as you would any other operator.

doc/source/user_guide/tutorials/custom_operators_and_plugins/index.rst

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ With support for custom operators, PyDPF-Core becomes a development tool offerin
2323
The only prerequisite for creating custom operators is to be familiar with native operators.
2424
For more information, see :ref:`ref_user_guide_operators`.
2525

26-
.. note:
26+
.. note::
27+
2728
You can create custom operators in CPython using PyDPF-Core for use with DPF in Ansys 2023 R1 and later.
2829

2930
The following tutorials demonstrate how to develop such plugins using PyDPF-Core (CPython based) and how to use them.
@@ -36,44 +37,48 @@ For comprehensive examples on writing operator plugins, see :ref:`python_operato
3637
:margin: 2
3738

3839
.. grid-item-card:: Create a DPF plugin with a single operator
39-
:link: tutorials_custom_operators_and_plugins_custom_operator
40-
:link-type: ref
41-
:text-align: center
40+
:link: tutorials_custom_operators_and_plugins_custom_operator
41+
:link-type: ref
42+
:text-align: center
43+
:class-header: sd-bg-light sd-text-dark
44+
:class-footer: sd-bg-light sd-text-dark
4245

43-
This tutorial shows how to create, load, and use a custom plugin containing a single custom operator.
46+
This tutorial shows how to create, load, and use a custom plugin containing a single custom operator.
4447

45-
.. grid-item-card:: Create a DPF plugin with multiple operators
46-
:text-align: center
47-
:class-card: sd-bg-light
48-
:class-header: sd-bg-light
48+
+++
49+
Requires DPF 11.0 or above
4950

50-
Coming soon
51-
^^^
51+
.. grid-item-card:: Create a DPF plugin with multiple operators
52+
:text-align: center
53+
:class-header: sd-bg-light sd-text-dark
54+
:class-footer: sd-bg-light sd-text-dark
5255

56+
This tutorial shows how to create, load, and use a custom plugin with multiple operators or with complex routines.
5357

54-
This tutorial shows how to create, load, and use a custom plugin with multiple operators or with complex routines.
58+
+++
59+
Coming soon
5560

5661
.. grid-item-card:: Create a custom DPF plugin with third-party dependencies using Python
57-
:text-align: center
58-
:class-card: sd-bg-light
59-
:class-header: sd-bg-light
62+
:text-align: center
63+
:class-header: sd-bg-light sd-text-dark
64+
:class-footer: sd-bg-light sd-text-dark
6065

61-
Coming soon
62-
^^^
66+
This tutorial shows how to create a Python plug-in package with third-party dependencies.
6367

64-
This tutorial shows how to create a Python plug-in package with third-party dependencies.
68+
+++
69+
Coming soon
6570

6671
.. grid-item-card:: Update PyDPF-Core in the DPF installation
6772
:text-align: center
6873
:class-card: sd-bg-light
69-
:class-header: sd-bg-light
70-
71-
Coming soon
72-
^^^
73-
74+
:class-header: sd-bg-light sd-text-dark
75+
:class-footer: sd-bg-light sd-text-dark
7476

7577
This tutorial shows how to update PyDPF-Core in your DPF installation.
7678

79+
+++
80+
Coming soon
81+
7782
.. toctree::
7883
:maxdepth: 2
7984
:hidden:

0 commit comments

Comments
 (0)