rougail/docs/tutorial/preliminary.rst

384 lines
14 KiB
ReStructuredText
Raw Normal View History

2025-11-05 17:34:12 +01:00
Getting started
====================
2024-10-14 19:17:44 +02:00
2024-10-21 15:03:34 +02:00
.. objectives:: Objectives
2024-10-14 19:17:44 +02:00
2024-10-21 15:03:34 +02:00
We will learn how to:
2024-10-14 19:17:44 +02:00
2025-11-07 09:05:44 +01:00
- create a :term:`structure description file <structure file>`
- add a :term:`structure file <structure file>` format version in the structure file
- add a :term:`variable` in the structure file and set its default :term:`value`
2024-10-15 15:50:01 +02:00
.. prerequisites:: Prerequisites
2024-10-21 15:03:34 +02:00
2025-11-05 08:59:36 +01:00
- We assume that Rougail's library is :ref:`installed <installation>` on your computer.
2025-11-30 09:41:08 +01:00
2025-12-04 18:00:09 +01:00
- 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.
2025-11-30 09:41:08 +01:00
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.
2025-12-04 18:00:09 +01:00
If you want to follow this tutorial with the help of the corresponding :tutorial:`rougail-tutorials git repository <src/branch/1.1>`,
2025-11-30 10:02:03 +01:00
this workshop page corresponds to the tags :tutorial:`v1.1_000 <src/tag/v1.1_000>` to :tutorial:`v1.1_003 <src/tag/v1.1_003>`
in the repository:
2024-10-15 15:50:01 +02:00
2025-11-07 09:05:44 +01:00
::
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
2025-12-04 14:21:12 +01:00
git switch --detach v1.1_000
2025-11-07 09:05:44 +01:00
Creating a structure file
--------------------------
2025-02-04 16:38:07 +01:00
2025-06-26 17:17:06 +02:00
.. demo:: The folder structure
2024-10-15 15:50:01 +02:00
Here is the tree structure we want to have::
2024-10-15 15:50:01 +02:00
2025-11-07 09:05:44 +01:00
rougail-tutorials
└── firefox
2025-11-22 11:11:45 +01:00
└── 00-proxy.yml
2024-10-15 15:50:01 +02:00
2025-11-07 09:05:44 +01:00
- Let's make a :file:`rougail-tutorials` directory, with a :file:`firefox` subfolder.
2025-11-07 17:26:23 +01:00
- First, we will create a :term:`structure file <structure file>`, so let's create a :file:`00-proxy.yml` file
2025-02-04 16:38:07 +01:00
located in the :file:`firefox` subfolder.
2025-11-07 09:05:44 +01:00
This is an empty Rougail :term:`structure description file: <structure file>`
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_000/firefox/00-proxy.yml
:language: yaml
2025-12-04 18:00:09 +01:00
:caption: An empty Rougail structure file with only the YAML header and the version number
2025-02-09 11:20:36 +01:00
:name: RougailStructVersion
..
---
version: 1.1
2025-11-07 17:26:23 +01:00
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_000/firefox/00-proxy.yml>`
2025-12-04 18:00:09 +01:00
This `version` specification is just the Rougail YAML's format version specification.
By now, we have an empty structure file with the format specification in it.
2025-11-07 09:05:44 +01:00
Let's add our first variable
------------------------------
.. type-along:: For those who follow the tutorial with the help of the git repository
Now you need to checkout the `v1.1_001` version::
2025-12-04 14:21:12 +01:00
git switch --detach v1.1_001
- A variable is defined at a minimum by its name.
- A :term:`variable` lives in the :term:`structure description file <structure file>`.
2025-11-05 06:54:03 +01:00
Here we define a variable named `proxy_mode`:
2025-11-07 06:45:46 +01:00
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_001/firefox/00-proxy.yml
:language: yaml
:caption: A Rougail structure file with only one variable in it
:name: RougailDictionaryFirstVariableName
..
---
proxy_mode:
2024-10-15 15:50:01 +02:00
2025-11-07 17:26:23 +01:00
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_001/firefox/00-proxy.yml>`
2025-11-05 08:59:36 +01:00
Let's run the Rougail CLI utility command in a terminal:
2025-02-04 16:38:07 +01:00
2025-02-04 21:35:42 +01:00
.. code-block:: text
:class: terminal
2025-11-05 06:54:03 +01:00
rougail -m firefox/
2025-02-04 16:38:07 +01:00
Well, we notice that we have an error:
2025-02-04 16:38:07 +01:00
.. raw:: html
2025-11-07 06:45:46 +01:00
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_001/config/01/output_ro.html
2025-02-04 21:35:42 +01:00
:class: error-box
2025-02-04 16:38:07 +01:00
..
🛑 ERRORS
┣━━ The following variables are mandatory but have no value:
┗━━ - proxy_mode
It's because this first defined variable is :term:`mandatory` and needs to have a value set **but** there's no value yet.
2025-02-04 16:38:07 +01:00
2025-11-07 09:05:44 +01:00
We can therefore deduce the fact that:
.. admonition:: Fact
2025-02-05 07:18:50 +01:00
2025-11-07 09:05:44 +01:00
Once defined, an option configuration :term:`value` is :term:`mandatory`.
That is to say, it is absolutely necessary to assign a value to this variable.
2025-06-26 12:54:33 +02:00
2025-11-22 11:27:24 +01:00
Rougail expects the `proxy_mode` configuration option's value to be set.
2025-02-05 07:18:50 +01:00
.. glossary::
mandatory
2025-11-13 16:22:23 +01:00
A variable is mandatory when a value is required, that is, `None` **is not** a possible value.
2025-02-21 20:26:08 +01:00
It **must** have a defined value.
2025-11-07 09:05:44 +01:00
.. seealso:: To go further, have a look at the :tiramisu:`mandatory option <glossary.html#term-mandatory-option>`
according to the :xref:`Tiramisu <tiramisu>` underlyning consistency system.
You will learn that it is actually possible to disable the mandatory property behavior,
but you need to declare it explicitely.
Describe the variable
-------------------------
2025-12-04 18:00:09 +01:00
Let's add a variable's description, which is not mandatory but which is usually a good practice.
.. type-along:: For those who follow the tutorial with the help of the git repository
Now you need to checkout the `v1.1_002` version::
2025-12-04 14:21:12 +01:00
git switch --detach v1.1_002
2025-02-04 16:38:07 +01:00
2025-11-07 06:45:46 +01:00
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_002/firefox/00-proxy.yml
2025-02-04 16:38:07 +01:00
:language: yaml
:caption: A Rougail structure file with a variable and a description
2025-02-09 11:20:36 +01:00
:name: RougailStructFirstVariableDescription
2025-02-04 16:38:07 +01:00
..
---
2025-11-05 06:54:03 +01:00
proxy_mode: # Configure Proxy Access to the Internet
2025-02-04 16:38:07 +01:00
2025-11-07 17:26:23 +01:00
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_002/firefox/00-proxy.yml>`
You have two way to define a variable's description:
- the verbose way:
2025-06-26 12:54:33 +02:00
.. code-block:: yaml
proxy_mode:
description: Configure Proxy Access to the Internet
2025-11-24 16:00:54 +01:00
- or a short-hand way, setting the description using the "`#`" YAML comment notation:
.. code-block:: yaml
proxy_mode: # Configure Proxy Access to the Internet
Set a default value
---------------------
.. type-along:: For those who follow the tutorial with the help of the git repository
Now you need to checkout the `v1.1_003` version::
2025-12-04 14:21:12 +01:00
git switch --detach v1.1_003
We will learn different ways to set a value, the first way is setting a *default* value.
2025-02-04 16:38:07 +01:00
.. glossary::
2025-02-21 20:26:08 +01:00
default value
2025-02-04 16:38:07 +01:00
A default value is a variable value that is predefined, that's why this value is placed
2025-02-04 16:38:07 +01:00
right in the structure file.
2024-10-15 15:50:01 +02:00
Let's add a default value to this `proxy_mode` variable.
2024-10-15 15:50:01 +02:00
2025-11-07 06:45:46 +01:00
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_003/firefox/00-proxy.yml
2025-02-09 10:36:19 +01:00
:language: yaml
2025-12-04 18:00:09 +01:00
:caption: A Rougail structure file with a default value for the variable
2025-02-04 21:52:54 +01:00
:name: RougailDictionaryVariableDefault
2025-02-04 21:35:42 +01:00
2025-02-09 10:36:19 +01:00
..
2025-02-04 21:35:42 +01:00
---
2025-11-05 06:54:03 +01:00
proxy_mode: No proxy # Configure Proxy Access to the Internet
2025-02-04 21:35:42 +01:00
2025-11-07 17:26:23 +01:00
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_003/firefox/00-proxy.yml>`
2025-11-27 18:26:09 +01:00
The `proxy_mode` variable requires a value, that's why we have set a `No proxy` default value.
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_003/config/01/output_ro.html
:class: output
..
<pre>╭─────── Caption ────────╮
│ Variable <span style="color: #ffd700">Default value</span> │
╰────────────────────────╯
Variables:
<span style="color: #5c5cff">┗━━ </span>📓 Configure Proxy Access to the Internet: <span style="color: #ffd700">No proxy</span>
</pre>
As we have set the `proxy_mode`'s value as `No proxy` by default,
2025-12-04 18:00:09 +01:00
The chosen value is indicated in the Rougail's CLI output as the default choice.
2025-11-27 18:26:09 +01:00
2025-12-04 18:00:09 +01:00
- here is the short-hand default setting and description:
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
.. code-block:: yaml
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
proxy_mode: No proxy # Configure Proxy Access to the Internet
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
- here is the verbose way:
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
.. code-block:: yaml
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
proxy_mode:
default: No proxy
description: Configure Proxy Access to the Internet
2025-11-24 16:00:54 +01:00
2025-12-04 18:00:09 +01:00
There are some other :term:`short-hand ways <short-hand notation>` with Rougail that you may encounter
as you read the Rougail's documentation and tutorial.
2025-11-24 16:00:54 +01:00
.. admonition:: how to set a value -- the assignment
A default value has been set, great. This raises a question about what a normal value is.
2025-02-04 16:38:07 +01:00
Now then how can I assign a normal value to a variable?
2025-02-04 16:38:07 +01:00
2025-12-04 18:00:09 +01:00
.. type-along:: The different Rougail roles and setting a variable's value
2024-10-15 15:50:01 +02:00
2025-12-04 18:00:09 +01:00
So far we have only talked about the actor that writes the :term:`structure files <structure file>`\ .
2025-11-22 11:27:24 +01:00
The one who writes the structure file plays the *role* of the *integrator*.
2025-02-04 21:52:54 +01:00
2024-10-15 15:50:01 +02:00
.. glossary::
integrator
2025-06-26 12:54:33 +02:00
An integrator in the Rougail field is the person who writes the :term:`structure files <structure file>`\ .
2025-11-22 11:27:24 +01:00
He has the responsibility of the integration process, that is,
he defines the variables and the relationship between them, the variables that are allowed
2024-10-15 15:50:01 +02:00
(or not) to be set, and so on. His responsabilites are the **structuration** and the **consistency**
2025-11-24 16:00:54 +01:00
of the organisation of the variables between them.
2024-10-15 15:50:01 +02:00
2025-11-24 16:00:54 +01:00
Now we will talk about the one that defines the values. His role is called the operator role.
2024-10-15 15:50:01 +02:00
.. glossary::
operator
2025-06-26 12:54:33 +02:00
An operator in the Rougail field is the person who assigns :term:`value`\ s to the pre-defined variables,
2024-10-15 15:50:01 +02:00
his responsabilities are to set variable values correctly.
2025-11-22 11:27:24 +01:00
The user :term:`value`\ s, that is the values that have been set by the operator, are of course type validated.
The type validation is driven by the definitions in the :term:`structure file <structure file>`.
2024-10-15 15:50:01 +02:00
2025-05-05 21:39:32 +02:00
It is the operator's responsibility to set the user datas variables values.
2025-06-26 12:54:33 +02:00
The operator does not handle the structure files,
2025-11-22 11:27:24 +01:00
he is responsible of other files called the :term:`user data files <user data file>`.
2024-10-15 17:49:26 +02:00
2025-02-05 07:18:50 +01:00
.. glossary::
2024-10-15 17:49:26 +02:00
2025-05-05 21:39:32 +02:00
user datas
2025-06-26 12:54:33 +02:00
User datas, as opposed to structured datas, are datas that only concern the assignment of values
2025-11-24 16:00:54 +01:00
and not the consistency of the variables between them.
2025-06-26 12:54:33 +02:00
The variable's values are also called **user values**.
2025-11-22 11:27:24 +01:00
The consistency field is outside of the user datas scope.
2025-06-26 12:54:33 +02:00
The consistency is handled in the :term:`structured datas <structured data>`\ 's scope.
2024-10-21 15:03:34 +02:00
2025-12-04 18:00:09 +01:00
.. important:: For now, we don't know how to disable the default `mandatory` settings,
so if neither a default value nor a user value are set for a given variable, Rougail will raise an error.
2025-02-05 07:18:50 +01:00
.. exercise:: Folder structure update
2025-02-04 22:01:19 +01:00
2025-11-24 16:00:54 +01:00
Now we add a user data file named :file:`config/config.yml` in our project::
2024-10-21 19:50:26 +02:00
2025-11-07 17:26:23 +01:00
rougail-tutorials
2025-02-05 07:18:50 +01:00
├── firefox
2025-11-22 11:27:24 +01:00
│ ├── 00-proxy.yml
2025-02-05 07:18:50 +01:00
└── config
2025-11-22 11:27:24 +01:00
└── config.yml
2024-10-21 19:50:26 +02:00
2025-11-22 12:24:54 +01:00
.. type-along:: how to set a user data value
2024-10-21 19:50:26 +02:00
2025-11-22 12:24:54 +01:00
If the integrator has not set any default value in his structure file,
2025-11-22 11:27:24 +01:00
it's up to the operator to do the job in the `config.yml` file:
2024-10-21 19:50:26 +02:00
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_003/config/02/config.yml
2024-10-21 19:50:26 +02:00
:language: yaml
2025-11-22 12:24:54 +01:00
:caption: A Rougail user datas file :file:`config/config.yml`, with a value set.
2025-02-05 07:18:50 +01:00
:name: RougailConfigDefaultValue
2024-10-28 15:29:11 +01:00
2025-02-05 07:18:50 +01:00
..
2024-10-28 15:29:11 +01:00
---
2025-02-05 07:18:50 +01:00
proxy_mode: No proxy
2024-10-21 19:50:26 +02:00
2025-11-22 12:24:54 +01:00
:tutorial:`Download this file from the rougail-tutorials git repository <src/tag/v1.1_003/config/02/config.yml>`
2025-11-07 17:26:23 +01:00
2025-12-04 18:00:09 +01:00
The operator needs to add the `-u yaml -yf config/config.yml` options to the Rougail CLI:
2024-10-21 19:50:26 +02:00
2025-11-22 12:57:17 +01:00
.. raw:: html
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_003/config/02/cmd_ro.txt
2025-02-04 22:01:19 +01:00
:class: terminal
2025-11-07 17:26:23 +01:00
2025-11-22 12:57:17 +01:00
..
rougail -m firefox/ -u yaml -yf config/02/config.yml
2025-11-07 17:26:23 +01:00
which gives us this output:
2024-10-21 19:50:26 +02:00
2025-11-07 17:26:23 +01:00
.. raw:: html
2025-11-22 12:24:54 +01:00
:url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/tag/v1.1_003/config/02/output_ro.html
2025-11-07 17:26:23 +01:00
:class: output
..
<pre>╭──────── Caption ────────╮
│ Variable Modified value │
╰─────────────────────────╯
Variables:
2025-11-22 11:27:24 +01:00
<span style="color: #5c5cff">┗━━ </span>📓 proxy_mode: No proxy ◀ loaded from the YAML file "config/02/config.yml"
2025-11-07 17:26:23 +01:00
</pre>
2024-10-21 19:50:26 +02:00
2025-12-04 18:00:09 +01:00
Now the `proxy_mode`'s new `No proxy` value is the same as the default value but we see in the Rougail CLI output that the value
2025-11-22 12:24:54 +01:00
comes from the :file:`config/02/config.yml` user data file. From now on this `proxy_mode` variable's value
is a user data value and not a default value (even if it's actually the same value).
2024-10-28 21:08:22 +01:00
2025-11-22 12:24:54 +01:00
.. type-along:: structure values and user data values
2025-11-22 08:08:14 +01:00
2025-12-04 18:00:09 +01:00
We can see with the Rougail CLI utility where the values come from.
2025-11-22 12:24:54 +01:00
It can come from an integrator's setting or from an operator's setting.
2025-11-22 08:08:14 +01:00
2025-11-22 12:24:54 +01:00
.. admonition:: Reminder
2025-11-22 08:08:14 +01:00
2025-11-22 12:24:54 +01:00
- the integrator works on structure files, he can define default value for variables
- the operator works on user data files, he only can set user data values for variables
Most of the time, the integrator and the operator are one and the same person,
here we are talking about roles and not necessarily about people.
2024-10-28 21:08:22 +01:00
.. type-along:: user data files are where the user values live
We need to set the values in separate files, called `user data files`.
.. glossary::
user data file
A user data file is a file where only :term:`user datas` are set.
A user file is a file where there are only user datas in it, users can set values, called user values --
that is variable's values that have been set by an :term:`operator`\ .
see also :term:`user datas`
.. glossary::
configuration
We call configuration the whole system structure and user values,
and when we speak of consistency, it is in relation to this whole set.
2024-10-21 18:28:34 +02:00
.. keypoints:: Key points progress
**Keywords**
2025-02-09 11:20:36 +01:00
- :term:`structure file <structure file>`: structure description file
2024-10-21 18:28:34 +02:00
- :term:`variable`: an option's name which has a value
- a variable's description
2025-11-22 12:24:54 +01:00
- a variable's mandatory value
2024-10-21 18:28:34 +02:00
- a variable's default value
2025-11-22 12:24:54 +01:00
- a variable's user value
2024-10-21 18:28:34 +02:00
- the :term:`integrator` and :term:`operator` roles
- a :term:`configuration`
2024-10-21 15:03:34 +02:00