Skip to content

Commit bd177cb

Browse files
luisaFelixSallesPProfiziRevathyvenugopal162JennaPaikowskymoe-ad
authored
New tutorials section (#1876)
Co-authored-by: Paul Profizi <[email protected]> Co-authored-by: Revathy Venugopal <[email protected]> Co-authored-by: PProfizi <[email protected]> Co-authored-by: JennaPaikowsky <[email protected]> Co-authored-by: moe-ad <[email protected]> Co-authored-by: Camille Bellot <[email protected]> Co-authored-by: Muhammed Adedigba <[email protected]> Co-authored-by: Jorge Martínez <[email protected]>
1 parent 6ac50b3 commit bd177cb

File tree

77 files changed

+8660
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+8660
-573
lines changed

doc/source/_static/custom.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@
22
.wy-table-responsive table td, .wy-table-responsive table th {
33
white-space: normal;
44
}
5+
/* Check https://www.w3schools.com/cssref/css_colors.php for colors */
6+
/* Ansys gold for MAPDL with black text*/
7+
.sd-bg-mapdl{background-color: #FFB71B}
8+
.sd-bg-text-mapdl{color: Black}
9+
/* Ansys orange accent color for Fluent with black text*/
10+
.sd-bg-lsdyna{background-color: #FB471F}
11+
.sd-bg-text-lsdyna{color: Black}
12+
/* Ansys blue accent color #00629F for Fluent with black text*/
13+
.sd-bg-fluent{background-color: #0081D0}
14+
.sd-bg-text-fluent{color: Black}
15+
.sd-bg-cfx{background-color: LightSeaGreen}
16+
.sd-bg-text-cfx{color: Black}
17+
.sd-hide-link-text{height: 0}

doc/source/conf.py

Lines changed: 39 additions & 5 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,6 +127,7 @@
118127
"sphinx_design",
119128
"sphinx_jinja",
120129
'sphinx_reredirects',
130+
"jupyter_sphinx",
121131
]
122132

123133
redirects = {
@@ -137,6 +147,7 @@
137147

138148
autosummary_generate = False
139149

150+
autodoc_mock_imports = ["ansys.dpf.core.examples.python_plugins"]
140151

141152
# Add any paths that contain templates here, relative to this directory.
142153
# templates_path = ['_templates']
@@ -160,7 +171,14 @@
160171
# List of patterns, relative to source directory, that match files and
161172
# directories to ignore when looking for source files.
162173
# This pattern also affects html_static_path and html_extra_path.
163-
exclude_patterns = []
174+
exclude_patterns.extend(["links_and_refs.rst"])
175+
176+
# make rst_epilog a variable, so you can add other epilog parts to it
177+
rst_epilog = ""
178+
179+
# Read links and targets from file
180+
with open("links_and_refs.rst") as f:
181+
rst_epilog += f.read()
164182

165183
# The name of the Pygments (syntax highlighting) style to use.
166184
pygments_style = None
@@ -358,6 +376,20 @@
358376
# A list of files that should not be packed into the epub file.
359377
epub_exclude_files = ["search.html"]
360378

379+
# Define custom docutils roles for solver badges
380+
from sphinx_design.badges_buttons import BadgeRole
381+
382+
def setup(app):
383+
badge_roles = {
384+
"bdg-mapdl": "mapdl",
385+
"bdg-cfx": "cfx",
386+
"bdg-fluent": "fluent",
387+
"bdg-lsdyna": "lsdyna"
388+
}
389+
390+
for role_name, color in badge_roles.items():
391+
app.add_role(name=role_name, role=BadgeRole(color=color))
392+
361393
# Common content for every RST file such us links
362394
rst_epilog = ""
363395
links_filepath = Path(__file__).parent.absolute() / "links.rst"
@@ -387,3 +419,5 @@
387419
BUILD_EXAMPLES = True if os.environ.get("BUILD_EXAMPLES", "true") == "true" else False
388420
if BUILD_EXAMPLES:
389421
extensions.extend(["sphinx_gallery.gen_gallery"])
422+
423+
print(f"{extensions=}")

doc/source/getting_started/contribute/developer.rst

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
1+
.. _contributing_as_a_developer:
2+
13
Contributing as a developer
24
###########################
35

4-
.. grid:: 1 2 3 3
5-
:padding: 2 2 2 2
6-
7-
.. grid-item-card:: :fa:`download` Clone the repository
8-
:link: clone-the-repository
9-
:link-type: ref
10-
11-
Download your own copy in your local machine.
12-
13-
.. grid-item-card:: :fa:`download` Install for developers
14-
:link: install-for-developers
15-
:link-type: ref
16-
17-
Install the project in editable mode.
18-
19-
.. grid-item-card:: :fa:`vial-circle-check` Run the tests
20-
:link: run-tests
21-
:link-type: ref
22-
23-
Verify your changes by testing the project.
6+
You can contribute to PyDPF-Core by fixing bugs, adding new features, and improving the codebase.
7+
To do so, you must set up the repository on your local machine by following the steps below:
248

9+
- :ref:`clone-the-repository`
10+
- :ref:`install-for-developers`
11+
- :ref:`run-tests`
2512

2613
.. _clone-the-repository:
2714

@@ -44,9 +31,13 @@ Installing PyDPF-Core in development mode allows you to perform changes to the c
4431
and see the changes reflected in your environment without having to reinstall
4532
the library every time you make a change.
4633

34+
To do so, follow the steps below.
35+
4736
Virtual environment
4837
-------------------
4938

39+
First, set up a new virtual environment.
40+
5041
Start by navigating to the project's root directory by running:
5142

5243
.. code-block:: bash
@@ -117,7 +108,9 @@ Install Tox
117108
Once the project is installed, you can install `Tox`_. This is a cross-platform
118109
automation tool. The main advantage of Tox is that it eases routine tasks like project
119110
testing, documentation generation, and wheel building in separate and isolated Python
120-
virtual environments. To install Tox, run:
111+
virtual environments.
112+
113+
To install Tox, run:
121114

122115
.. code-block:: text
123116
@@ -154,10 +147,14 @@ Run the tests
154147
=============
155148

156149
Once you have made your changes, you can run the tests to verify that your
157-
modifications did not break the project. PyDPF-Core tests are organized into groups and require additional steps
150+
modifications did not break the project.
151+
152+
PyDPF-Core tests are organized into groups and require additional steps
158153
during execution to ensure tests run as expected without errors, therefore, PyDPF-Core tox configuration
159154
supports different markers to account for this. These markers are associated with a
160-
dedicated `Tox`_ environment. To also allow flexibity required during development, different DPF Server installation
155+
dedicated `Tox`_ environment.
156+
157+
To also allow flexibility required during development, a specific DPF Server installation
161158
can also be used as explained in the subsections that follow.
162159

163160
Unified DPF Server installation or specific DPF Server installation using ANSYS_DPF_PATH environment variable

doc/source/getting_started/contribute/documentarian.rst

Lines changed: 95 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
1-
Contributing as a documentarian
2-
###############################
1+
.. _contributing_documentation:
2+
3+
Contributing to the documentation
4+
#################################
5+
6+
.. note::
7+
8+
Overall guidance on contributing to the documentation of a PyAnsys repository appears in
9+
`Documenting`_ in the *PyAnsys Developer's Guide*.
10+
11+
You must also follow the `Documentation style`_ guide to
12+
ensure that all the documentation looks the same across the project.
13+
14+
To contribute on the documentation you must start by setting up the PyDPF-Core repository
15+
by following the steps in :ref:`contributing_as_a_developer` section.
16+
17+
In this page you can check how to :
318

419
.. grid:: 1 2 3 3
520
:padding: 2 2 2 2
621

7-
.. grid-item-card:: :fa:`pencil` Write documentation
8-
:link: write-documentation
22+
.. grid-item-card:: :fa:`th` Structure the documentation
23+
:link: structure-documentation
924
:link-type: ref
1025

11-
Explain how to get started, use, and contribute to the project.
26+
How the documentation is structured and where to locate files.
1227

13-
.. grid-item-card:: :fa:`laptop-code` Add a new example
14-
:link: write-examples
28+
.. grid-item-card:: :fa:`pencil` Write documentation
29+
:link: write-product-use-documentation
1530
:link-type: ref
1631

17-
Showcase the capabilities of PyDPF-Core by adding a new example.
32+
Explains and showcases the use of PyDPF-Core.
1833

1934
.. grid-item-card:: :fa:`book` Build the documentation
2035
:link: build-documentation
2136
:link-type: ref
2237

2338
Render the documentation to see your changes reflected.
2439

25-
.. _write-documentation:
40+
.. _structure-documentation:
2641

27-
Write documentation
28-
===================
42+
Structure the documentation
43+
===========================
2944

3045
The documentation generator used in PyDPF-Core is `Sphinx`_. Most of the documents
31-
are written in `reStructuredText`_. Some parts of the documentation, like the
32-
:ref:`examples <Examples>`, use a mix of `reStructuredText`_ and Python, thanks to `Sphinx-Gallery`_.
33-
If you are interested in writing examples, see the :ref:`writing examples <write-examples>`
34-
section.
46+
are written in `reStructuredText`_.
3547

3648
The documentation is located in the ``doc/source`` directory. The landing page
3749
is declared in the ``doc/source/index.rst`` file. The rest of the files contain
@@ -42,7 +54,7 @@ files.
4254
The layout of the ``doc/source`` directory is reflected in the slug of the
4355
online documentation. For example, the
4456
``doc/source/getting_started/contribute/documentarian.rst`` renders as
45-
``https://dpf.docs.pyansys.com/getting_started/contribute/documentarian.html``.
57+
``https://dpf.docs.pyansys.com/getting_started/contribute/documentarian.html``.
4658

4759
Thus, if you create a new file, it important to follow these rules:
4860

@@ -70,38 +82,75 @@ A table of contents can be declared using a directive like this:
7082
The path to the file is relative to the directory where the table of contents
7183
is declared.
7284

73-
.. _write-examples:
85+
.. _write-product-use-documentation:
7486

75-
Write a new example
87+
Write documentation
7688
===================
7789

78-
The :ref:`examples <Examples>` section of the documentation showcases different
79-
capabilities of PyDPF-Core. Each example (grouped into folders of related examples)
80-
is a standalone Python script. Despite being ``*.py`` files, they are written in a mix
81-
of `reStructuredText`_ and Python. This is possible thanks to the `Sphinx-Gallery`_
82-
Sphinx extension.
90+
Our documentation tries to follow a structure principle that respects four different functions of the documentation.
91+
Each of them fulfills a different need for people working with our tool at different times, in different circumstances.
92+
93+
Here is an overview of how our documentation is organized to help you know where you should include your contributions.
94+
Each section has their own guidelines that must be followed when creating new content.
95+
To check these specific guidelines click on the correspondent card below.
96+
97+
.. grid:: 1 1 2 2
98+
:gutter: 2
99+
:padding: 2
100+
:margin: 2
83101

84-
Documentarians writing new examples are encouraged to familiarize themselves with
85-
`structuring Python scripts for Sphinx-Gallery <https://sphinx-gallery.github.io/stable/syntax.html>`_.
86-
Once the ``.py`` file for a new example is properly set up, Sphinx-Gallery automatically
87-
generates `Sphinx`_ `reStructuredText`_ files from it. The rendering of the resulting reST will provide
88-
users with ``.ipynb`` (Jupyter notebook) and ``.py`` files of each example, which users can download.
102+
.. grid-item-card:: **TUTORIALS**
103+
:link: ref_guidelines_tutorials
104+
:link-type: ref
105+
:class-title: sd-text-center sd-bg-light
106+
:class-header: sd-text-center
89107

90-
Finally, here are some tips for writing examples:
108+
Learning oriented
109+
^^^^^^^^^^^^^^^^^
91110

92-
- Start the example with an explanation of the main topic. Try to use as many relevant
93-
keywords as possible in this section to optimize for Search Engine Optimization.
111+
**Function:** Teach how to get started and use PYDPF-core step by step
94112

95-
- Include an explanation with each code cell. The explanations should
96-
be included before, not after, the corresponding code.
113+
Teach how to perform a task and showcase the underlying concepts,
114+
providing detailed explanations at each stage. A tutorial is centered around a given feature.
97115

98-
- The examples are built with the documentation. As part of the build process,
99-
screenshots of rendered graphics are inserted in the document. You do not need
100-
to include the screenshots yourself.
116+
.. grid-item-card:: **EXAMPLES**
117+
:link: ref_guidelines_examples
118+
:link-type: ref
119+
:class-title: sd-text-center sd-bg-light
120+
:class-header: sd-text-center
101121

102-
- When creating a new folder where more than one related example will be included, ensure
103-
a ``README.txt`` file is also included. This file should contain reST to be used as the header
104-
for the index page corresponding to the subsection for these examples in the generated documentation.
122+
Use-cases oriented
123+
^^^^^^^^^^^^^^^^^^
124+
125+
**Function:** Show how to solve specifics key problems
126+
127+
Showcase a specific key problem or use-case with a complete PyDPF script. They are more advanced than
128+
tutorials as they present end-to-end engineering workflows and assume basic knowledge of PyDPF-Core.
129+
130+
.. grid-item-card:: **CONCEPTS**
131+
:class-title: sd-text-center sd-bg-light
132+
:class-header: sd-text-center
133+
134+
Understanding oriented
135+
^^^^^^^^^^^^^^^^^^^^^^
136+
137+
**Function:** Provide useful theoretical explanations for PyDPF-Core
138+
139+
Discuss and explain key DPF principles and concepts, for the reader to understand the spirit of the underlying tool.
140+
141+
142+
.. grid-item-card:: **API REFERENCE**
143+
:class-title: sd-text-center sd-bg-light
144+
:class-header: sd-text-center
145+
146+
Informing oriented
147+
^^^^^^^^^^^^^^^^^^
148+
149+
**Function:** Describe PyDPF-Core APIs
150+
151+
Provides technical reference on how PyDPF-Core works and how to use it but assume basic
152+
understanding of key DPF concepts. It is generated automatically along the documentation and
153+
is based on the source code.
105154

106155
.. _build-documentation:
107156

@@ -162,3 +211,10 @@ are modified.
162211
.. code-block:: text
163212
164213
python -m tox -e doc-html -x testenv:doc-html.setenv+="BUILD_API=false" -x testenv:doc-html.setenv+="BUILD_EXAMPLES=false"
214+
215+
.. toctree::
216+
:hidden:
217+
:maxdepth: 3
218+
219+
guidelines_tutorials
220+
guidelines_examples

0 commit comments

Comments
 (0)