From 604cfa0a1d6c73414044dc71c8ba947b02a2e74f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 19 Feb 2025 16:43:32 +0100 Subject: [PATCH] fix: support suffix (in version 1.0 format) in calculation --- src/rougail/output_doc/annotator.py | 2 + ..._5family_dynamic_variable_outside_1_0.adoc | 50 ++++++ ..._5family_dynamic_variable_outside_1_0.json | 149 ++++++++++++++++++ ...60_5family_dynamic_variable_outside_1_0.md | 26 +++ ...60_5family_dynamic_variable_outside_1_0.sh | 55 +++++++ .../60_6family_dynamic_sub_dynamic_1_0.adoc | 5 +- .../60_6family_dynamic_sub_dynamic_1_0.json | 5 +- .../60_6family_dynamic_sub_dynamic_1_0.md | 2 +- .../60_6family_dynamic_sub_dynamic_1_0.sh | 5 +- ...60_5family_dynamic_variable_outside_1_0.md | 20 +++ 10 files changed, 315 insertions(+), 4 deletions(-) create mode 100644 tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.adoc create mode 100644 tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.json create mode 100644 tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.md create mode 100644 tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.sh create mode 100644 tests/results/test_namespace_examples/60_5family_dynamic_variable_outside_1_0.md diff --git a/src/rougail/output_doc/annotator.py b/src/rougail/output_doc/annotator.py index bf583c1..48419a5 100644 --- a/src/rougail/output_doc/annotator.py +++ b/src/rougail/output_doc/annotator.py @@ -328,4 +328,6 @@ class Annotator(Walk): variable_path, path, ) + elif version == '1.0' and '{{ suffix }}' in variable_path: + variable_path = variable_path.replace("{{ suffix }}", "{{ identifier }}") return variable_path diff --git a/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.adoc b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.adoc new file mode 100644 index 0000000..21b7b44 --- /dev/null +++ b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.adoc @@ -0,0 +1,50 @@ +== Variables for "Rougail" + +[cols="1a,1a"] +|==== +| Variable | Description +| + +**rougail.var** + +`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `standard` `mandatory` `unique` `multiple` | +A suffix variable. + +**Default**: + +* val1 +* val2 +|==== + +=== a dynamic family + +`standard` + +This family builds families dynamically. + +**Identifiers**: the value of the variable "rougail.var". + +[cols="1a,1a"] +|==== +| Variable | Description +| + +**rougail.my_dyn_family___val1__.var** + +**rougail.my_dyn_family___val2__.var** + +`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `standard` | +A variable inside a dynamic family. + +**Default**: the value of the identifier. +|==== + +[cols="1a,1a"] +|==== +| Variable | Description +| + +**rougail.var2** + +`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `standard` `mandatory` `unique` `multiple` | +A variable. + +**Default**: + +* the value of the variable "rougail.my_dyn_family___val1__.var" +* the value of the variable "rougail.my_dyn_family___val2__.var" +|==== + diff --git a/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.json b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.json new file mode 100644 index 0000000..2f46fb8 --- /dev/null +++ b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.json @@ -0,0 +1,149 @@ +{ + "rougail": { + "type": "namespace", + "informations": { + "paths": [ + "rougail" + ], + "names": [ + "rougail" + ], + "description": "Rougail", + "properties": [ + { + "type": "mode", + "name": "standard" + } + ] + }, + "children": { + "rougail.var": { + "type": "variable", + "default": [ + "val1", + "val2" + ], + "properties": [ + { + "type": "type", + "name": "string" + }, + { + "type": "mode", + "name": "standard" + }, + { + "type": "property", + "name": "mandatory" + }, + { + "type": "property", + "name": "unique" + }, + { + "type": "multiple", + "name": "multiple" + } + ], + "paths": [ + "rougail.var" + ], + "names": [ + "var" + ], + "descriptions": [ + "A suffix variable." + ] + }, + "my_dyn_family_{{ identifier }}": { + "type": "dynamic", + "informations": { + "paths": [ + "rougail.my_dyn_family_val1", + "rougail.my_dyn_family_val2" + ], + "names": [ + "my_dyn_family_val1", + "my_dyn_family_val2" + ], + "description": "a dynamic family", + "properties": [ + { + "type": "mode", + "name": "standard" + } + ], + "identifiers": "the value of the variable \"rougail.var\".", + "help": [ + "This family builds families dynamically." + ] + }, + "children": { + "rougail.my_dyn_family_{{ identifier }}.var": { + "paths": [ + "rougail.my_dyn_family_val1.var", + "rougail.my_dyn_family_val2.var" + ], + "names": [ + "var", + "var" + ], + "type": "variable", + "default": "the value of the identifier.", + "properties": [ + { + "type": "type", + "name": "string" + }, + { + "type": "mode", + "name": "standard" + } + ], + "descriptions": [ + "A variable inside a dynamic family." + ] + } + } + }, + "rougail.var2": { + "type": "variable", + "default": [ + "the value of the variable \"rougail.my_dyn_family_val1.var\"", + "the value of the variable \"rougail.my_dyn_family_val2.var\"" + ], + "properties": [ + { + "type": "type", + "name": "string" + }, + { + "type": "mode", + "name": "standard" + }, + { + "type": "property", + "name": "mandatory" + }, + { + "type": "property", + "name": "unique" + }, + { + "type": "multiple", + "name": "multiple" + } + ], + "paths": [ + "rougail.var2" + ], + "names": [ + "var2" + ], + "descriptions": [ + "A variable." + ] + } + } + } +} \ No newline at end of file diff --git a/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.md b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.md new file mode 100644 index 0000000..9b49ab0 --- /dev/null +++ b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.md @@ -0,0 +1,26 @@ +--- +gitea: none +include_toc: true +--- +# Variables for "Rougail" + +| Variable                                                                                                                       | Description                                                                                                                    | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **rougail.var**
[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` `unique` `multiple` | A suffix variable.
**Default**:
- val1
- val2 | + +## a dynamic family + +`standard` + +This family builds families dynamically. + +**Identifiers**: the value of the variable "rougail.var". + +| Variable                                                                                                                       | Description                                                                                                                    | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **rougail.my_dyn_family_*val1*.var**
**rougail.my_dyn_family_*val2*.var**
[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` | A variable inside a dynamic family.
**Default**: the value of the identifier. | + +| Variable                                                                                                                       | Description                                                                                                                    | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| **rougail.var2**
[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` `unique` `multiple` | A variable.
**Default**:
- the value of the variable "rougail.my_dyn_family_*val1*.var"
- the value of the variable "rougail.my_dyn_family_*val2*.var" | + diff --git a/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.sh b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.sh new file mode 100644 index 0000000..9385e1c --- /dev/null +++ b/tests/results/test_namespace/60_5family_dynamic_variable_outside_1_0.sh @@ -0,0 +1,55 @@ +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ Variables for "Rougail" ┃ +┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ + + + + +  Variable                               Description                            + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + rougail.var + string standard mandatory unique A suffix variable. + multiple + Default: + + + • val1 + • val2 + | + + + a dynamic family + +standard + +This family builds families dynamically. + +Identifiers: the value of the variable "rougail.var". + + + + + +  Variable                               Description                            + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + rougail.my_dyn_family_val1.var + rougail.my_dyn_family_val2.var + string standard A variable inside a dynamic family. + Default: the value of the + identifier. + + + + + +  Variable                                Description                           + ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + rougail.var2 + string standard mandatory unique A variable. + multiple + Default: + + + • the value of the variable "rougail.my_dyn_family_val1.var" + • the value of the variable "rougail.my_dyn_family_val2.var" + | diff --git a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.adoc b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.adoc index 84d6506..28be3ed 100644 --- a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.adoc +++ b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.adoc @@ -40,7 +40,10 @@ A dynamic variable. + This family builds families dynamically. -**Identifiers**: the value of the variable "rougail.dyn{{ suffix }}.var". +**Identifiers**: + +* the value of the variable "rougail.dyn__val1__.var" +* the value of the variable "rougail.dyn__val2__.var" [cols="1a,1a"] |==== diff --git a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.json b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.json index 0091096..ce5f925 100644 --- a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.json +++ b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.json @@ -138,7 +138,10 @@ "name": "standard" } ], - "identifiers": "the value of the variable \"rougail.dyn{{ suffix }}.var\".", + "identifiers": [ + "the value of the variable \"rougail.dynval1.var\"", + "the value of the variable \"rougail.dynval2.var\"" + ], "help": [ "This family builds families dynamically." ] diff --git a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.md b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.md index 01fe19c..6d99115 100644 --- a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.md +++ b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.md @@ -26,7 +26,7 @@ This family builds families dynamically. This family builds families dynamically. -**Identifiers**: the value of the variable "rougail.dyn{{ suffix }}.var". +**Identifiers**:
- the value of the variable "rougail.dyn*val1*.var"
- the value of the variable "rougail.dyn*val2*.var" | Variable                                                                                                                       | Description                                                                                                                    | |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| diff --git a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.sh b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.sh index 0cd9c3a..5da0bdd 100644 --- a/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.sh +++ b/tests/results/test_namespace/60_6family_dynamic_sub_dynamic_1_0.sh @@ -45,7 +45,10 @@ This family builds families dynamically. This family builds families dynamically. -Identifiers: the value of the variable "rougail.dyn{{ suffix }}.var". +Identifiers: + + • the value of the variable "rougail.dynval1.var" + • the value of the variable "rougail.dynval2.var" diff --git a/tests/results/test_namespace_examples/60_5family_dynamic_variable_outside_1_0.md b/tests/results/test_namespace_examples/60_5family_dynamic_variable_outside_1_0.md new file mode 100644 index 0000000..fef3031 --- /dev/null +++ b/tests/results/test_namespace_examples/60_5family_dynamic_variable_outside_1_0.md @@ -0,0 +1,20 @@ +--- +gitea: none +include_toc: true +--- +# Example with all variables modifiable + +```yaml +--- +rougail: + var: + - val1 + - val2 + my_dyn_family_val1: + var: val1 + my_dyn_family_val2: + var: val2 + var2: + - val1 + - val2 +```