From 503906001213234b0d940a3b9d9d60b8217364e3 Mon Sep 17 00:00:00 2001 From: gwen Date: Sat, 21 Mar 2026 17:33:46 +0100 Subject: [PATCH] custom type update --- docs/tutorial/customtype.rst | 87 +++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 27 deletions(-) diff --git a/docs/tutorial/customtype.rst b/docs/tutorial/customtype.rst index f5f7b3f09..354f2e699 100644 --- a/docs/tutorial/customtype.rst +++ b/docs/tutorial/customtype.rst @@ -30,20 +30,20 @@ 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. +.. note:: It is actually possible to add static predefined types, + but that involves modifying the :term:`tiramisu` library itself. + +More simply, it's possible in Rougail to create custom types, much like defining families. -Our structural folder will be expanded a bit: +Our folder structure 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 new :file:`types` folder in our tree structure. -This is where we will define our new types. +This is where we place our new type definitions. -And we also have a new structure file named :file:`00-proxy.yml`. -Let's examine them more closely. +Let's examine them more closely this new structure file named :file:`types/proxy/00_type.yml`: .. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/types/proxy/00_type.yml :language: yaml @@ -70,6 +70,58 @@ Let's examine them more closely. default: variable: __.http_proxy.port ... + +Now a new type named `proxy` is declared. +It's more or less like a family except it will be used as a type definition, + + +.. questions:: How do we use a new type? + + Very simply. In the usual way. + + Here, we will declare that a family is of type `proxy` as follows: + +.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/firefox/10-manual.yml + :language: yaml + :caption: The :file:`firefox/10-manual.yml` structure file with less code due to the `proxy` type definition + +.. + %YAML 1.2 + --- + version: 1.1 + + manual: + description: Manual proxy configuration + disabled: + variable: _.proxy_mode + when_not: Manual proxy configuration + + http_proxy: + description: HTTP Proxy + type: proxy + + address: + default: null + + port: + default: 8080 + ... + +We can see that the `http_proxy` family has the `type: proxy` declared. Very simple. + +So we have declared our new type. How do you make it available in our structure file definitions? + +The Rougail CLI with the type declaration command line option: + +.. raw:: html + :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt + :class: terminal + +The output: + +.. raw:: html + :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html + :class: output TODO: @@ -78,6 +130,7 @@ TODO: - la notion de type vient de la déclaration ligne de commande --type rougail -m firefox/ --types types/proxy -u yaml -yf config/01/config.yml + - le fichier firefox/10-manual.yml a des changements https://forge.cloud.silique.fr/stove/rougail-tutorials/compare/v1.1_080~1..v1.1_080 dégraissage dû à la déclaration de type @@ -98,24 +151,4 @@ TODO: ┣━━ 📓 SOCKS port: 3128 ┗━━ 📓 SOCKS host version used by proxy: v5 -.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/types/proxy/00_type.yml - :language: yaml - :caption: The :file:`types/proxy/00_type.yml` structure file with proxy type declaration - -.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/firefox/10-manual.yml - :language: yaml - :caption: The :file:`firefox/10-manual.yml` structure file with less declaration due to the type definition - - -The Rougail CLI with the type declaration command line option: - -.. raw:: html - :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/cmd_ro.txt - :class: terminal - -The output: - -.. raw:: html - :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_080/config/01/output_ro.html - :class: output