Skip to content

Commit 8ccb409

Browse files
updates
1 parent 588185f commit 8ccb409

File tree

2 files changed

+264
-23
lines changed

2 files changed

+264
-23
lines changed

doc/source/getting_started/write_doc/guide_lines_tutorials.rst

Lines changed: 218 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
.. _ref_guide_lines_tutorials:
22

3-
=============================
4-
Writing tutorials guide lines
5-
=============================
3+
============================
4+
Writing tutorials guidelines
5+
============================
66

7-
You can improve the Py-DPF-Core documentation by adding:
7+
You can improve the Py-DPF-Core documentation by adding a:
88

9-
- :ref:`New tutorials sections<ref_guide_lines_add_new_tutorial_section>`;
10-
- :ref:`New tutorials<ref_guide_lines_add_new_tutorial>`.
9+
- :ref:`New tutorials section<ref_guide_lines_add_new_tutorial_section>`;
10+
- :ref:`New tutorial<ref_guide_lines_add_new_tutorial>`.
1111

1212
To do so, you must follow the guide lines presented here.
1313
You also need to understand the structure of the ``doc`` directory on the PyDPF-Core library:
@@ -38,9 +38,9 @@ Adding a new tutorial section
3838

3939
.. note::
4040

41-
Avoid creating new folders unless absolutely necessary. If in doubt, its precise location can be advised
42-
on in the pull request. If you must create a new folder, make sure to add a ``index.rst`` file containing
43-
a reference, tue section title and a description of the section. Otherwise the new folder will be ignored by Sphinx.
41+
Avoid creating new folders unless it is absolutely necessary. If you are in doubt, its precise location can be
42+
advised on the pull request. If you must create a new folder, make sure to add a ``index.rst`` file containing
43+
a reference, a title and a description of the section. Otherwise the new folder will be ignored by Sphinx.
4444

4545
Location and naming
4646
-------------------
@@ -67,7 +67,38 @@ The new folder must contain at least a ``index.rst`` file. This file has:
6767
- Cards with the tutorial title, description and applicable solvers (the card must have a link to the tutorial file);
6868
- Toctree with the tutorials in the section.
6969

70-
You must also add the ``index.rst`` file. in the main user guide toctree. You can find it at the end of
70+
.. code-block::
71+
72+
.. _ref_tutorial_new_section_template:
73+
74+
=============
75+
Section title
76+
=============
77+
78+
These tutorials demonstrate how to ...
79+
80+
.. grid:: 1 1 3 3
81+
:gutter: 2
82+
:padding: 2
83+
:margin: 2
84+
85+
.. grid-item-card:: Tutorial title
86+
:link: ref
87+
:link-type: ref
88+
:text-align: center
89+
90+
This tutorial ...
91+
92+
+++
93+
:bdg-mapdl:`MAPDL` :bdg-lsdyna:`LS-DYNA` :bdg-fluent:`FLUENT` :bdg-cfx:`CFX`
94+
95+
.. toctree::
96+
:maxdepth: 2
97+
:hidden:
98+
99+
tutorial_file.rst
100+
101+
You must also add the ``index.rst`` file in the main user guide page toctree. You can find it at the end of
71102
``doc/source/user_guide/index.rst`` file.
72103

73104
.. rubric:: Templates
@@ -95,11 +126,11 @@ New tutorials must be added as ``.rst`` files to: ``doc/source/user_guide/tutori
95126
│ │ │ ├── section
96127
│ │ │ ├── new_tutorial.rst
97128
98-
You also have to add it to a card and the toctree on the section ``index.rst`` file. The card must have:
129+
You also have to add it to a card and the toctree on the tutorial section ``index.rst`` file. The card must have:
99130

100131
- Tutorial title;
101132
- Short description;
102-
- Applicable solvers;
133+
- Badges with the applicable solvers;
103134
- Link to the tutorial file;
104135

105136
.. card:: Tutorial title
@@ -120,17 +151,24 @@ Structure
120151

121152
The tutorial structure can be divided in two main parts:
122153

123-
- Basis;
154+
- Preamble;
124155
- Content.
125156

126-
Basis
127-
^^^^^
157+
Preamble
158+
^^^^^^^^
159+
160+
This first part is essential for clarity, organization and usability of the tutorial. It establishes the tutorials
161+
purpose, making it easy to understand what is going to be explained and reference it within the other parts of
162+
the documentation.
163+
164+
Components
165+
~~~~~~~~~~
128166

129-
This first part must have the following components:
167+
The preamble must have the following components:
130168

131169
- File reference name;
132170
- Tutorial title;
133-
- Substitution text for the PyDPF-Core library references;
171+
- Substitution text for the PyDPF-Core library references that will be used across the tutorial;
134172
- Short description (same phrase used in the tutorial card in the tutorial section ``index.rst`` file);
135173
- Introduction that explains the context of the tutorial;
136174
- Download script buttons;
@@ -156,22 +194,51 @@ This first part must have the following components:
156194
157195
:jupyter-download-script:`Download tutorial as Python script<file_name>` :jupyter-download-notebook:`Download tutorial as notebook<file_name>`
158196
197+
The main PyDPF-Core library references are available already defined in the ``doc/source/links_and_refs.rst`` file.
198+
To use it you use the include directive and use the substitution text as usual:
199+
200+
.. code-block::
201+
202+
.. _ref_tutorial_template:
203+
204+
205+
==============
206+
Tutorial title
207+
==============
208+
209+
.. include:: ../../../links_and_refs.rst
210+
211+
Here some text. Here we use the |MeshedRegion| substitution text
212+
213+
For more information on those references check the :download:`links and references file<../../links_and_refs.rst>`.
214+
159215
Content
160216
^^^^^^^
161217

162218
A tutorial goal is to explain how to perform a task step by step and understand the underlying concepts.
219+
Thus, its structure must prioritize clarity, simplicity, and logical flow.
163220

164221
Sections
165222
~~~~~~~~
166223

167-
A well-structured tutorial content should be divided by those steps. For example:
224+
A well-organized tutorial breaks down complex tasks into manageable steps, presenting information incrementally
225+
to avoid overwhelming the user. It combines concise explanations with actionable instructions, ensuring users
226+
can follow along easily while building their understanding.
227+
228+
Thus, the sections of the content are the steps themselves. Globally those steps looks like:
229+
230+
#. Get data, define DPF objects that contains the data;
231+
#. One or more steps where you manipulate, handles the data/ DPF objects;
232+
#. Conclusion, here is the final step where the tutorial goal is accomplished.
233+
234+
For example:
168235

169236
A tutorial goal is to explains how to plot a mesh using PyDPF-Core.
170237
The steps to achieve this task are:
171238

172-
- Import a result file;
173-
- Extract the mesh;
174-
- Plot the mesh.
239+
#. Import a result file;
240+
#. Extract the mesh;
241+
#. Plot the mesh.
175242

176243
To create those section, underline it with the appropriate characters (here: ``-``).
177244

@@ -194,8 +261,136 @@ To create those section, underline it with the appropriate characters (here: ``-
194261
195262
Finally, you plot ...
196263
197-
Code snippets
198-
~~~~~~~~~~~~~
264+
Tabs
265+
~~~~
266+
267+
You must use tabs in the case the tutorial is applicable fore more then one solver and the implementations are
268+
different for each of them.
269+
270+
These tabs looks like:
271+
272+
.. tab-set::
273+
274+
.. tab-item:: MAPDL
275+
276+
Explanation 1 ...
277+
278+
.. jupyter-execute::
279+
280+
# Code block 1
281+
282+
.. tab-item:: LSDYNA
283+
284+
Explanation 2 ...
285+
286+
.. jupyter-execute::
287+
288+
# Code block 2
289+
290+
.. tab-item:: Fluent
291+
292+
Explanation 3 ...
293+
294+
.. jupyter-execute::
295+
296+
# Code block 3
297+
298+
.. tab-item:: CFX
299+
300+
Explanation 4 ...
301+
302+
.. jupyter-execute::
303+
304+
# Code block 4
305+
306+
307+
You can also use tabs if you want to show different approaches to one step and it would be more clear
308+
to have the code blocks in different tabs. You can see an example of this case in the
309+
:ref:`ref_tutorials_animate_time` tutorial.
310+
311+
312+
Code blocks
313+
~~~~~~~~~~~
314+
315+
The tutorials must have code blocks where you show how you actually implement the coode.
316+
The guidelines for the code snippets are:
317+
318+
- Use the `jupyter sphinx<jupyter_sphinx_ext>`_ extension. Its executes embedded code in a Jupyter kernel,
319+
and embeds outputs of that code in the document:
320+
321+
.. code-block::
322+
323+
.. jupyter-execute::
324+
325+
# This is a executable code block
326+
from ansys.dpf import core as dpf
327+
328+
- You must split your code in several parts so you can make explanations between them:
329+
330+
First explanation
331+
332+
.. code-block::
333+
334+
# Code block 1
335+
336+
Second explanation
337+
338+
.. code-block::
339+
340+
# Code block 2
341+
342+
343+
- Every code implementation must be commented:
344+
345+
.. grid:: 2
346+
:gutter: 2
347+
:padding: 2
348+
:margin: 2
349+
350+
.. grid-item::
351+
352+
**Correct**
353+
354+
.. code-block::
355+
356+
# Define the model
357+
model = dpf.Model()
358+
# Get the stress results
359+
stress_fc = model.results.stress.eval()
360+
361+
.. grid-item::
362+
363+
**Incorrect**
364+
365+
.. code-block::
366+
367+
model = dpf.Model()
368+
stress_fc = model.results.stress.eval()
369+
370+
- When using a PyDPF-Core object or method you must use key arguments
371+
372+
.. grid:: 2
373+
:gutter: 2
374+
:padding: 2
375+
:margin: 2
376+
377+
.. grid-item::
378+
379+
**Correct**
380+
381+
.. code-block::
382+
383+
# Get the stress results
384+
stress_fc = model.results.stress(time_scoping=time_steps).eval()
385+
386+
.. grid-item::
387+
388+
**Incorrect**
389+
390+
.. code-block::
391+
392+
# Get the stress results
393+
stress_fc = model.results.stress(time_steps).eval()
199394
200395
Text formating
201396
~~~~~~~~~~~~~~

doc/source/getting_started/write_doc/tutorial_template.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,49 @@ This sentence resumes the goal of the tutorial
1111
Introduction to the tutorial
1212

1313
:jupyter-download-script:`Download tutorial as Python script<file_name>` :jupyter-download-notebook:`Download tutorial as notebook<file_name>`
14+
15+
First Step
16+
----------
17+
18+
Here you have to make an implementation but it is different for the different solvers
19+
20+
.. tab-set::
21+
22+
.. tab-item:: MAPDL
23+
24+
Explanation ...
25+
26+
.. jupyter-execute::
27+
28+
# Code block
29+
30+
.. tab-item:: LSDYNA
31+
32+
Explanation ...
33+
34+
.. jupyter-execute::
35+
36+
# Code block
37+
38+
.. tab-item:: Fluent
39+
40+
Explanation ...
41+
42+
.. jupyter-execute::
43+
44+
# Code block
45+
46+
.. tab-item:: CFX
47+
48+
Explanation ...
49+
50+
.. jupyter-execute::
51+
52+
# Code block
53+
54+
Second step
55+
-----------
56+
57+
Final Step
58+
----------
59+

0 commit comments

Comments
 (0)