Skip to content

Commit def994c

Browse files
committed
feat: facilitating example contribution
1 parent 35e5790 commit def994c

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

doc/source/how-to/documenting.rst

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,4 +913,61 @@ files for inclusion in the documentation.
913913
| examples/02-HFSS/HFSS_Spiral.py | examples-design-and-simulation-of-spiral-inductors.py |
914914
+-------------------------------------------------+-------------------------------------------------------+
915915

916-
If you have questions about SEO, email the `PyAnsy Core team <pyansys_core_email_>`_.
916+
If you have questions about SEO, email the `PyAnsys Core team <pyansys_core_email_>`_.
917+
918+
Facilitating contributions in the form of examples
919+
--------------------------------------------------
920+
921+
One of the main challenges we face inside our libraries is the lack of examples. Examples are
922+
critical for users to understand how to use the library and present new functionality. They are also
923+
a great mechanism to educate users on the best practices of using it.
924+
925+
When users want to contribute examples, we need to make it as easy as possible for them to do so. This
926+
means that we need to provide a clear structure for them to follow. We also need to make sure that the
927+
build process is as simple as possible.
928+
929+
2 best practices for examples are:
930+
931+
- **Providing a template**: This is a great way to ensure that users follow the same structure. It also makes it easy for
932+
them to get started. The template should include all the necessary information, such as the name of the
933+
example, a description, and the code itself.
934+
- **Verifying the example**: This is a great way to ensure that the example works as expected. It also helps to catch any
935+
errors before they are submitted. The verification process should include running the example and checking
936+
the output. If the example fails, it should be easy for the user to fix it.
937+
938+
Providing a template
939+
~~~~~~~~~~~~~~~~~~~~
940+
941+
Here is an example of how to promote the use of templates for examples:
942+
943+
- `PyAnsys Geometry examples template <PyAnsys_geometry_examples_template_>`_
944+
- `PyPrimeMesh examples template <PyPrimemesh_examples_template_>`_
945+
946+
These templates are also referred to in the contributing guidelines:
947+
948+
- `PyAnsys Geometry example contribution guidelines <PyAnsys_geometry_examples_contribution_>`_
949+
950+
Verifying examples
951+
~~~~~~~~~~~~~~~~~~
952+
953+
The verification process will depend on each library and the tools used for generating the examples. Within
954+
our ecosystem, we are using Sphinx Gallery and NBSphinx to generate the examples, and the build process
955+
is slightly different for each library.
956+
957+
However, the following approach could be useful for all libraries:
958+
959+
- Create a Makefile target that only runs a specific example.
960+
961+
This target should be used to run the example and check the output. If the example fails, it should be easy for the user to fix it.
962+
An example of this is the ``make`` target in PyAnsys Geometry:
963+
964+
.. code-block:: console
965+
966+
./make.bat single-example examples/01_getting_started/01_math.mystnb
967+
968+
.. code-block:: console
969+
970+
make single-example examples/01_getting_started/01_math.mystnb
971+
972+
The pull request in which this was added is: `PyAnsys Geometry PR #1893 <PyAnsys_geometry_pull_1893_>`_
973+
This implementation is specific for NB Sphinx, but the idea is to create a target that runs a specific example and checks the output.

doc/source/links.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
.. _Links_for_pymapdl: https://github.com/ansys/pymapdl/blob/main/doc/source/links.rst
5252
.. _PyAEDT: https://github.com/ansys/pyaedt
5353
.. _PyAnsys_geometry_Docker_containers: https://geometry.docs.pyansys.com/version/stable/getting_started/docker/index.html
54+
.. _PyAnsys_geometry_examples_template: https://geometry.docs.pyansys.com/version/stable/examples/99_misc/template.html
55+
.. _PyAnsys_geometry_examples_contribution: https://geometry.docs.pyansys.com/version/stable/contributing.html#adding-examples
56+
.. _PyAnsys_geometry_pull_1893 : https://github.com/ansys/pyansys-geometry/pull/1893
57+
.. _PyPrimemesh_examples_template: https://prime.docs.pyansys.com/version/stable/examples/gallery_examples/misc/example_template.html#sphx-glr-examples-gallery-examples-misc-example-template-py
5458
.. _PyAnsys: https://docs.pyansys.com/version/stable/
5559
.. _PyAnsys Bot: https://github.com/apps/pyansys-bot
5660
.. _pyansys_proto_generator: https://github.com/ansys/pyansys-protos-generator

0 commit comments

Comments
 (0)