custom types
This commit is contained in:
parent
c7156ea638
commit
cb425ed7f7
5 changed files with 86 additions and 19 deletions
|
|
@ -7,8 +7,9 @@ Synopsis
|
|||
.. glossary::
|
||||
|
||||
family
|
||||
|
||||
A family of variables is simply a collection of variables that refer to
|
||||
subfamily
|
||||
|
||||
A family (or a subnfamiliy) of variables is simply a collection of variables that refer to
|
||||
the same business model category. It's just a variables container.
|
||||
Think of it as a container as well as a namespace.
|
||||
|
||||
|
|
|
|||
|
|
@ -10,22 +10,21 @@ Rougail
|
|||
|
||||
.. todo:: définir les termes suivants
|
||||
|
||||
family.rst:25: WARNING: label non défini: 'convention on variable names'
|
||||
/family.rst:114: WARNING: term not in glossary: 'calculation'
|
||||
/variable.rst:39: WARNING: label non défini: 'convention on variable names'
|
||||
/variable.rst:83: WARNING: term not in glossary: 'leading'
|
||||
/variable.rst:100: WARNING: term not in glossary: 'required'
|
||||
/variable.rst:102: WARNING: term not in glossary: 'leader'
|
||||
/variable.rst:102: WARNING: term not in glossary: 'follower'
|
||||
/variable.rst:126: WARNING: term not in glossary: 'multiple'
|
||||
/variable.rst:126: WARNING: term not in glossary: 'multiple'
|
||||
/variable.rst:131: WARNING: term not in glossary: 'calculation'
|
||||
/variable.rst:143: WARNING: term not in glossary: 'calculation'
|
||||
/variable.rst:148: WARNING: term not in glossary: 'calculation'
|
||||
/variable.rst:153: WARNING: term not in glossary: 'calculation'
|
||||
/dictionary.rst:9: WARNING: term not in glossary: 'templates'
|
||||
/dictionary.rst:19: WARNING: term not in glossary: 'redefine'
|
||||
/dictionary.rst:24: WARNING: term not in glossary: 'variable_namespace'
|
||||
1 check.rst:9: WARNING: term not in glossary: 'validator'
|
||||
2 check.rst:56: WARNING: term not in glossary: 'follower'
|
||||
3 configuration.rst:43: WARNING: term not in glossary: 'multiple'
|
||||
4 family.rst:25: WARNING: label non défini: 'convention on variable names'
|
||||
5 structfile.rst:89: WARNING: term not in glossary: 'variable_namespace'
|
||||
6 tutorial/tutorial.rst:437: WARNING: term not in glossary: 'leadership'
|
||||
7 tutorial/tutorial.rst:546: WARNING: term not in glossary: 'leader'
|
||||
8 tutorial/tutorial.rst:547: WARNING: term not in glossary: 'follower'
|
||||
9 variable.rst:38: WARNING: label non défini: 'convention on variable names'
|
||||
10 variable.rst:137: WARNING: term not in glossary: 'leading'
|
||||
11 variable.rst:154: WARNING: term not in glossary: 'required'
|
||||
12 variable.rst:156: WARNING: term not in glossary: 'leader'
|
||||
13 variable.rst:156: WARNING: term not in glossary: 'follower'
|
||||
14 variable.rst:186: WARNING: term not in glossary: 'multiple'
|
||||
15 variable.rst:186: WARNING: term not in glossary: 'multiple'
|
||||
|
||||
|
||||
.. image:: images/logo.png
|
||||
|
|
|
|||
48
docs/tutorial/customtype.rst
Normal file
48
docs/tutorial/customtype.rst
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
Custom type
|
||||
============
|
||||
|
||||
.. objectives:: Objectives
|
||||
|
||||
We are going to learn how to create custom types.
|
||||
In short, a custom type is nothing more than a kind of family template.
|
||||
|
||||
.. prerequisites:: Prerequisites
|
||||
|
||||
- We assume that Rougail's library is :ref:`installed <installation>` on your computer.
|
||||
|
||||
- It is possible to retrieve the current state of the various Rougail files manipulated in this tutorial step
|
||||
by checking out the corresponding tag of the `rougail-tutorials` git repository.
|
||||
Each tag corresponds to a stage of progress in the tutorial.
|
||||
Of course, you can also decide to copy/paste or download the tutorial files contents while following the tutorial steps.
|
||||
|
||||
If you want to follow this tutorial with the help of the corresponding :tutorial:`rougail-tutorials git repository <src/branch/1.1>`,
|
||||
this workshop page corresponds to the tags :tutorial:`v1.1_070 <src/tag/v1.1_080>` to :tutorial:`v1.1_072 <src/tag/v1.1_081>`
|
||||
in the repository.
|
||||
|
||||
::
|
||||
|
||||
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
|
||||
git switch --detach v1.1_080
|
||||
|
||||
HTTP Proxy with "proxy" type
|
||||
--------------------------------
|
||||
|
||||
In this section we will look at the possibilities for adding types.
|
||||
This feature is essential for having a truly adaptable tool.
|
||||
|
||||
It's possible to add basic types, but that involves modifying
|
||||
the tiramisu recipe itself.
|
||||
More simply, it's possible to create custom types, much like defining families.
|
||||
|
||||
Our structural folder will be expanded a bit:
|
||||
|
||||
.. raw:: html
|
||||
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/tree.html
|
||||
|
||||
Notice that we have now a :file:`types` folder with a :file:`proxy` subfolder.
|
||||
This is where we will define our new type.
|
||||
|
||||
And we also have a new structure file named :file:`00-proxy.yml`.
|
||||
Let's examine them more closely.
|
||||
|
||||
|
||||
|
|
@ -55,4 +55,5 @@ Let's dive into this **configuration options validation** use case.
|
|||
properties
|
||||
dynfam
|
||||
jinja
|
||||
|
||||
customtype
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@ Playing with Jinja
|
|||
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
|
||||
git switch --detach v1.1_070
|
||||
|
||||
|
||||
.. glossary::
|
||||
|
||||
calculation
|
||||
|
||||
A calculation is the act of calculating the value of a variable or a property of a variable.
|
||||
This calculation can be a redirection of the value of an existing variable (or property),
|
||||
or it can be a custom calculation using the Jinja templating language.
|
||||
|
||||
.. type-along:: Why the Jinja templating engine ?
|
||||
|
||||
We are going to embed some `Jinja templating code <https://jinja.palletsprojects.com/en/stable/>`_ in our structure file.
|
||||
|
|
@ -575,6 +584,15 @@ we add a `return_type` parameter in the `hiden` property:
|
|||
when: HTTPS
|
||||
...
|
||||
|
||||
|
||||
.. questions:: What about the error message?
|
||||
|
||||
If no text is returned by the Jinja calculation, what about the error message (in case of an error)?
|
||||
|
||||
In case of an error, it is the jinja's description that will appear.
|
||||
|
||||
In our example: `in HTTPS case if "_.use_for_https" is set to "true"`
|
||||
|
||||
.. keypoints:: Key points
|
||||
|
||||
We have seen that the `disabled` or `hidden` properties could be calculated.
|
||||
|
|
|
|||
Loading…
Reference in a new issue