From f2473f85f879ec049da591ce27f2dca7daa7ac68 Mon Sep 17 00:00:00 2001 From: gwen Date: Sat, 2 May 2026 09:48:18 +0200 Subject: [PATCH] type definition, end of relecture --- docs/tutorial/customtype.rst | 105 ++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/docs/tutorial/customtype.rst b/docs/tutorial/customtype.rst index b7d4ea8eb..4c960918c 100644 --- a/docs/tutorial/customtype.rst +++ b/docs/tutorial/customtype.rst @@ -388,9 +388,111 @@ Redefine other parameter in custom type In this sections we are going to make explicit :term:`redefinitions `. +The type definition didn't change, what we're talking about here is modifiying what has been previously defined +in the type definition file: -FIXME : redΓ©finition explicites. +.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_083/types/proxy/00-type.yml + :language: yaml + :caption: The :file:`types/proxy/00-type.yml` type definition file with the default definitions +.. + %YAML 1.2 + --- + version: 1.1 + + proxy: + + address: + description: Proxy address + type: domainname + params: + allow_ip: true + default: + variable: __.http_proxy.address + + port: + description: Proxy port + type: port + default: + variable: __.http_proxy.port + ... + +We can see here, for example, that the `address` and `port` variables don't have +any `description` atribute. We need to add one, so we need to extend the type +defintions. + +.. extinclude:: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_083/firefox/10-manual.yml + :language: yaml + :caption: The :file:`firefox/10-manual.yml` structure definition file with explicit redefinitions + +.. + %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: + redefine: true + default: null + description: HTTP proxy address + + port: + redefine: true + default: 8080 + description: HTTP proxy port + ... + + +.. note:: Transforming an implicit defintion into an explicit redefinition is very simple; you just need to add the `redefine: true` attribute: + +Let's launch the Rougail CLI: + +.. raw:: html + :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_083/config/01/cmd_ro.txt + :class: terminal + +.. + rougail -m firefox/ -u yaml -yf config/01/config.yml + +We have this output: + +.. raw:: html + :url: https://forge.cloud.silique.fr/stove/rougail-tutorials/raw/commit/v1.1_083/config/01/output_ro.html + :class: output + +.. + Variables: + ┣━━ πŸ““ Configure Proxy Access to the Internet: Manual proxy configuration β—€ + ┃ loaded from the YAML file "config/01/config.yml" (⏳ No proxy) + ┗━━ πŸ“‚ Manual proxy configuration + ┣━━ πŸ“‚ HTTP Proxy + ┃ ┣━━ πŸ““ HTTP proxy address: http.proxy.net β—€ loaded from the YAML file + ┃ ┃ "config/01/config.yml" + ┃ ┗━━ πŸ““ HTTP proxy port: 3128 β—€ loaded from the YAML file + ┃ "config/01/config.yml" (⏳ 8080) + ┣━━ πŸ““ Also use this proxy for HTTPS: false β—€ loaded from the YAML file + ┃ "config/01/config.yml" (⏳ true) + ┣━━ πŸ“‚ HTTPS Proxy + ┃ ┣━━ πŸ““ HTTPS proxy address: https.proxy.net β—€ loaded from the YAML file + ┃ ┃ "config/01/config.yml" (⏳ http.proxy.net) + ┃ ┗━━ πŸ““ HTTPS proxy port: 3128 + ┗━━ πŸ“‚ SOCKS Proxy + ┣━━ πŸ““ SOCKS proxy address: http.proxy.net + ┣━━ πŸ““ SOCKS proxy port: 3128 + ┗━━ πŸ““ SOCKS host version used by proxy: v5 + +We can see in the output that the `address` and `port` variables have default values, +and descriptions ("HTTP proxy address", "HTTP proxy port") that weren't present in the +type definition file. .. keypoints:: Key points @@ -399,5 +501,6 @@ FIXME : redΓ©finition explicites. - more conscious family definition - using a type for an extended family definition - we can redefine things in the structure file and it overloads the type definition file + - implicit or explicit redefinitions We have seen how the definition of type, used effectively, allows for a new expressiveness.