@@ -933,6 +933,9 @@ Two best practices for examples are:
933
933
- **Verifying the example **: Ensures that the example works as expected and helps catch
934
934
errors before submission. The verification process should involve running the example
935
935
and checking the output. If the example fails, it should be easy to identify and fix the issue.
936
+ - **Making the example usable in multiple contexts **: Ensures that the example can be
937
+ usable by a user reading the documentation, an application engineer using the library
938
+ through a Notebook, or a developer including the example to the documentation.
936
939
937
940
Providing a template
938
941
~~~~~~~~~~~~~~~~~~~~
@@ -972,3 +975,52 @@ includes a ``make`` target for this purpose:
972
975
The pull request introducing this feature is: `PyAnsys Geometry PR #1893 <PyAnsys_geometry_pull_1893 _>`_
973
976
This implementation is specific to NB Sphinx, but the concept of creating a target to run a specific
974
977
example and verify its output can be adapted to other libraries.
978
+
979
+ Making the example usable in multiple contexts
980
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
981
+
982
+ A core objective when designing examples is to ensure they can be used seamlessly across multiple
983
+ contexts: whether it's by end users exploring them interactively, by documentation tools rendering
984
+ them for the web, or by engineers verifying their correctness and updating them. Achieving this
985
+ flexibility requires a careful balance between accessibility, structure, and maintainability.
986
+
987
+ To support this goal, we recommend a workflow where examples are authored and maintained as plain
988
+ Python scripts, but using `Jupytext <https://jupytext.readthedocs.io/en/latest/ >`_ to treat those
989
+ scripts as notebooks when needed. Formatting your examples using the
990
+ `light format <https://jupytext.readthedocs.io/en/latest/formats-scripts.html#the-light-format >`_
991
+ makes them makes them fully compatible with JupyterLab, where they can be opened, edited, and
992
+ executed just like traditional notebooks - all without needing a IPYNB file. Here is an example
993
+ of a Jupytext light format script:
994
+
995
+ .. code-block :: python
996
+
997
+ # # Dipole antenna
998
+ #
999
+ # Keywords: **HFSS**, **antenna**, **3D component**, **far field**.
1000
+ #
1001
+ # ## Prerequisites
1002
+ #
1003
+ # ### Perform imports
1004
+ #
1005
+ # Import the packages required to run this example.
1006
+
1007
+ # +
1008
+ import os
1009
+ import tempfile
1010
+ import time
1011
+
1012
+ from ansys.aedt.core import Hfss
1013
+
1014
+ # -
1015
+
1016
+ # ### Define constants
1017
+ # Constants help ensure consistency and avoid repetition throughout the example.
1018
+
1019
+ AEDT_VERSION = " 2025.1"
1020
+ NUM_CORES = 4
1021
+ NG_MODE = False # Open AEDT UI when it is launched.
1022
+
1023
+ Here are examples of PyAnsys projects using this approach:
1024
+
1025
+ - `PyAEDT examples repository <PyAEDT-examples _>`_
1026
+ - `PySpeos repository <PySpeos _>`_
0 commit comments