docs(132-practice-url-error): and validators continuation
This commit is contained in:
parent
3372d45abc
commit
441260bea3
3 changed files with 26 additions and 11 deletions
|
|
@ -38,8 +38,8 @@ Example:
|
||||||
|
|
||||||
Do **not** skip levels (e.g. going from a level 1 title directly to a level 3 heading).
|
Do **not** skip levels (e.g. going from a level 1 title directly to a level 3 heading).
|
||||||
|
|
||||||
Handling TODOs
|
Handling TODOs and FIXMEs
|
||||||
-------------------
|
------------------------------
|
||||||
|
|
||||||
We use two complementary mechanisms to track pending work:
|
We use two complementary mechanisms to track pending work:
|
||||||
|
|
||||||
|
|
@ -47,6 +47,7 @@ We use two complementary mechanisms to track pending work:
|
||||||
- **``.. todo::`` directive** – for things that need to be **done** (missing sections, improvements, new features)
|
- **``.. todo::`` directive** – for things that need to be **done** (missing sections, improvements, new features)
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: rst
|
.. code-block:: rst
|
||||||
|
|
||||||
FIXME: The example below uses a deprecated function.
|
FIXME: The example below uses a deprecated function.
|
||||||
|
|
@ -175,7 +176,6 @@ Explanation of options:
|
||||||
- **``:language: yaml``** – enables YAML syntax highlighting in the rendered output
|
- **``:language: yaml``** – enables YAML syntax highlighting in the rendered output
|
||||||
- **``:caption: <text>``** – adds a descriptive caption below the code block
|
- **``:caption: <text>``** – adds a descriptive caption below the code block
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Displaying terminal commands
|
Displaying terminal commands
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
@ -189,7 +189,6 @@ To include and display a text file containing bash commands or terminal output,
|
||||||
|
|
||||||
This fetches the remote text file and renders it with terminal-style formatting (typically a dark background, monospaced font, and command-line appearance).
|
This fetches the remote text file and renders it with terminal-style formatting (typically a dark background, monospaced font, and command-line appearance).
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Displaying HTML output
|
Displaying HTML output
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
@ -203,7 +202,6 @@ To include and display an HTML file from the remote forge, use the ``raw`` direc
|
||||||
|
|
||||||
This fetches the remote HTML file and embeds it directly into the generated documentation page.
|
This fetches the remote HTML file and embeds it directly into the generated documentation page.
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Summary
|
Summary
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,15 +110,15 @@ Our solution
|
||||||
|
|
||||||
.. type-along:: For those who follow the tutorial with the help of the git repository
|
.. type-along:: For those who follow the tutorial with the help of the git repository
|
||||||
|
|
||||||
Now you need to checkout the :tutorial:`v1.1_131 <src/tag/v1.1_131/README.md>` version::
|
Now you need to checkout the :tutorial:`v1.1_132 <src/tag/v1.1_132/README.md>` version::
|
||||||
|
|
||||||
git switch --detach v1.1_131
|
git switch --detach v1.1_132
|
||||||
|
|
||||||
Please unroll the "Solution" widget to see our solution:
|
Please unroll the "Solution" widget to see our solution:
|
||||||
|
|
||||||
.. solution:: Solution
|
.. solution:: Solution
|
||||||
|
|
||||||
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_131/firefox/55-proxy_dns_socks5.yml
|
.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_132/firefox/55-proxy_dns_socks5.yml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
:caption: The :file:`firefox/55-proxy_dns_socks5.yml` a Jinja conditional disabled boolean variable
|
:caption: The :file:`firefox/55-proxy_dns_socks5.yml` a Jinja conditional disabled boolean variable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,32 @@ Validating a variable's value
|
||||||
A variable with custom validation
|
A variable with custom validation
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
Now, we would like the :term:`operator` to remember not to forget the http protocol, that is to put `http://` at the beginning of our `web_address` variable's value. What if he has forgotten the http protocol? We can add a reminder in case he has forgotten.
|
First, we would like the :term:`operator` to remember not to forget the http protocol, that is to put `http://` at the beginning of our `web_address` variable's value.
|
||||||
|
Actually the `web_address`\ 's type requires that the address include the HTTP protocol, namely:
|
||||||
|
|
||||||
We call it a validator.
|
::
|
||||||
|
|
||||||
|
http(s)://<domain_name><directory>
|
||||||
|
|
||||||
|
|
||||||
|
However, in our use case, we want *to force* the HTTPS protocol.
|
||||||
|
We don't want `http://`, only `https://`.
|
||||||
|
|
||||||
|
.. note:: This URL is for DNS over HTTPS, providing greater privacy than using the ISP's DNS,
|
||||||
|
which can filter traffic. If it uses `http://`, it doesn't make sense.
|
||||||
|
|
||||||
|
But there's no existing type for this specific use case (forcing HTTPS).
|
||||||
|
|
||||||
|
We just said that a valid value must start with `https://` instead of `http://`.
|
||||||
|
It is possible, instead of creating a new type, to add custom validation of the variable's value.
|
||||||
|
|
||||||
|
We call it a :term:`validator`.
|
||||||
|
|
||||||
.. glossary::
|
.. glossary::
|
||||||
|
|
||||||
validator
|
validator
|
||||||
|
|
||||||
A validator is a jinja code that parses a variable's value and checks
|
A validator is a Jinja code that parses a variable's value and checks
|
||||||
that this value corresponds to some stated criteria.
|
that this value corresponds to some stated criteria.
|
||||||
This is a `validator` parameter of our variable, and another `jinja` sub-parameter
|
This is a `validator` parameter of our variable, and another `jinja` sub-parameter
|
||||||
contains validation code for the variable's value.
|
contains validation code for the variable's value.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue