fix: doc example with leader example lower than leader default value
This commit is contained in:
parent
8f2c4b0011
commit
561d117d4d
58 changed files with 404 additions and 7 deletions
|
|
@ -208,14 +208,15 @@ class RougailOutputDoc(Examples):
|
|||
def _parse_variable(
|
||||
self, variable, leader: dict, name: str, path: str, informations: dict
|
||||
) -> Optional[dict]:
|
||||
potential_leader = None
|
||||
if variable.isdynamic():
|
||||
# information is already set
|
||||
potential_leader = self._parse_variable_dynamic(
|
||||
variable, leader, name, path, informations
|
||||
)
|
||||
elif variable.isfollower() and variable.index():
|
||||
potential_leader = self._parse_variable_follower_with_index(
|
||||
variable, path, informations
|
||||
self._parse_variable_follower_with_index(
|
||||
variable, leader, path, informations
|
||||
)
|
||||
else:
|
||||
potential_leader = self._parse_variable_normal(
|
||||
|
|
@ -244,14 +245,13 @@ class RougailOutputDoc(Examples):
|
|||
return None
|
||||
|
||||
def _parse_variable_follower_with_index(
|
||||
self, variable, path: str, informations: dict
|
||||
self, variable, leader: dict, path: str, informations: dict
|
||||
) -> None:
|
||||
if not self.example:
|
||||
return None
|
||||
if not self.example or (variable.index() + 1) > len(leader['example'][-1]):
|
||||
return
|
||||
informations[path]["example"][-1][variable.index()] = self._get_example(
|
||||
variable, informations[path], None
|
||||
)
|
||||
return None
|
||||
|
||||
def _parse_variable_dynamic(
|
||||
self, variable, leader, name, path, informations
|
||||
|
|
@ -432,6 +432,7 @@ class RougailOutputDoc(Examples):
|
|||
if multi:
|
||||
example = [example]
|
||||
if leader is not None and variable.isfollower():
|
||||
# len of leader is known, add "undefined" example, it will be modify latter with true value
|
||||
example = [example] + [undefined] * (len(leader["example"][-1]) - 1)
|
||||
return example
|
||||
|
||||
|
|
|
|||
0
tests/results/test/00_0no_variable.adoc
Normal file
0
tests/results/test/00_0no_variable.adoc
Normal file
1
tests/results/test/00_0no_variable.json
Normal file
1
tests/results/test/00_0no_variable.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
0
tests/results/test/00_0no_variable.md
Normal file
0
tests/results/test/00_0no_variable.md
Normal file
0
tests/results/test/00_0no_variable.sh
Normal file
0
tests/results/test/00_0no_variable.sh
Normal file
0
tests/results/test/00_0no_variable_default_version.adoc
Normal file
0
tests/results/test/00_0no_variable_default_version.adoc
Normal file
1
tests/results/test/00_0no_variable_default_version.json
Normal file
1
tests/results/test/00_0no_variable_default_version.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
0
tests/results/test/00_0no_variable_default_version.md
Normal file
0
tests/results/test/00_0no_variable_default_version.md
Normal file
0
tests/results/test/00_0no_variable_default_version.sh
Normal file
0
tests/results/test/00_0no_variable_default_version.sh
Normal file
0
tests/results/test/00_0no_variable_remove_version.adoc
Normal file
0
tests/results/test/00_0no_variable_remove_version.adoc
Normal file
1
tests/results/test/00_0no_variable_remove_version.json
Normal file
1
tests/results/test/00_0no_variable_remove_version.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
0
tests/results/test/00_0no_variable_remove_version.md
Normal file
0
tests/results/test/00_0no_variable_remove_version.md
Normal file
0
tests/results/test/00_0no_variable_remove_version.sh
Normal file
0
tests/results/test/00_0no_variable_remove_version.sh
Normal file
31
tests/results/test/40_0leadership_reduce.adoc
Normal file
31
tests/results/test/40_0leadership_reduce.adoc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
== a leadership
|
||||
|
||||
`basic`
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
[cols="1a,1a"]
|
||||
|====
|
||||
| Variable | Description
|
||||
|
|
||||
|
||||
**leadership.leader** +
|
||||
`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `standard` `mandatory` `unique` `multiple` |
|
||||
A leader. +
|
||||
**Default**:
|
||||
|
||||
* value_1
|
||||
* value_2
|
||||
* value_3
|
||||
|
||||
**Examples**:
|
||||
|
||||
* val1
|
||||
* val2
|
||||
|
|
||||
|
||||
**leadership.follower** +
|
||||
`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `basic` `mandatory` |
|
||||
A follower.
|
||||
|====
|
||||
|
||||
94
tests/results/test/40_0leadership_reduce.json
Normal file
94
tests/results/test/40_0leadership_reduce.json
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"leadership": {
|
||||
"type": "leadership",
|
||||
"informations": {
|
||||
"paths": [
|
||||
"leadership"
|
||||
],
|
||||
"names": [
|
||||
"leadership"
|
||||
],
|
||||
"description": "a leadership",
|
||||
"properties": [
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "basic"
|
||||
}
|
||||
],
|
||||
"help": [
|
||||
"This family contains lists of variable blocks."
|
||||
]
|
||||
},
|
||||
"children": {
|
||||
"leadership.leader": {
|
||||
"type": "variable",
|
||||
"default": [
|
||||
"value_1",
|
||||
"value_2",
|
||||
"value_3"
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"type": "type",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "standard"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "mandatory"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "unique"
|
||||
},
|
||||
{
|
||||
"type": "multiple",
|
||||
"name": "multiple"
|
||||
}
|
||||
],
|
||||
"paths": [
|
||||
"leadership.leader"
|
||||
],
|
||||
"names": [
|
||||
"leader"
|
||||
],
|
||||
"descriptions": [
|
||||
"A leader."
|
||||
],
|
||||
"examples": [
|
||||
"val1",
|
||||
"val2"
|
||||
]
|
||||
},
|
||||
"leadership.follower": {
|
||||
"type": "variable",
|
||||
"properties": [
|
||||
{
|
||||
"type": "type",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "basic"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "mandatory"
|
||||
}
|
||||
],
|
||||
"paths": [
|
||||
"leadership.follower"
|
||||
],
|
||||
"names": [
|
||||
"follower"
|
||||
],
|
||||
"descriptions": [
|
||||
"A follower."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
tests/results/test/40_0leadership_reduce.md
Normal file
11
tests/results/test/40_0leadership_reduce.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# a leadership
|
||||
|
||||
`basic`
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
| Variable | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **leadership.leader**<br/>[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` `unique` `multiple` | A leader.<br/>**Default**: <br/>- value_1<br/>- value_2<br/>- value_3<br/>**Examples**: <br/>- val1<br/>- val2 |
|
||||
| **leadership.follower**<br/>[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` | A follower. |
|
||||
|
||||
26
tests/results/test/40_0leadership_reduce.sh
Normal file
26
tests/results/test/40_0leadership_reduce.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
|
||||
[1;4;96ma leadership[0m
|
||||
|
||||
|
||||
[1;7m basic [0m
|
||||
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃[1m [0m[1mVariable [0m[1m [0m┃[1m [0m[1mDescription [0m[1m [0m┃
|
||||
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
│ [1mleadership.leader[0m │ A leader. │
|
||||
│ [1;7m string [0m [1;7m standard [0m [1;7m mandatory [0m [1;7m [0m │ [1mDefault[0m: │
|
||||
│ [1;7munique [0m [1;7m multiple [0m │ - value_1 │
|
||||
│ │ - value_2 │
|
||||
│ │ - value_3 │
|
||||
│ │ [1mExamples[0m: │
|
||||
│ │ - val1 │
|
||||
│ │ - val2 │
|
||||
├───────────────────────────────────────┼──────────────────────────────────────┤
|
||||
│ [1mleadership.follower[0m │ A follower. │
|
||||
│ [1;7m string [0m [1;7m basic [0m [1;7m mandatory [0m │ │
|
||||
└───────────────────────────────────────┴──────────────────────────────────────┘
|
||||
1
tests/results/test/warnings_00_0no_variable
Normal file
1
tests/results/test/warnings_00_0no_variable
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
1
tests/results/test/warnings_40_0leadership_reduce
Normal file
1
tests/results/test/warnings_40_0leadership_reduce
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
0
tests/results/test_examples/00_0no_variable.md
Normal file
0
tests/results/test_examples/00_0no_variable.md
Normal file
10
tests/results/test_examples/40_0leadership_reduce.md
Normal file
10
tests/results/test_examples/40_0leadership_reduce.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Example with all variables modifiable
|
||||
|
||||
```yaml
|
||||
---
|
||||
leadership:
|
||||
- leader: val1
|
||||
follower: example
|
||||
- leader: val2
|
||||
follower: example
|
||||
```
|
||||
1
tests/results/test_examples/warnings_00_0no_variable
Normal file
1
tests/results/test_examples/warnings_00_0no_variable
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
0
tests/results/test_namespace/00_0no_variable.adoc
Normal file
0
tests/results/test_namespace/00_0no_variable.adoc
Normal file
1
tests/results/test_namespace/00_0no_variable.json
Normal file
1
tests/results/test_namespace/00_0no_variable.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
0
tests/results/test_namespace/00_0no_variable.md
Normal file
0
tests/results/test_namespace/00_0no_variable.md
Normal file
0
tests/results/test_namespace/00_0no_variable.sh
Normal file
0
tests/results/test_namespace/00_0no_variable.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
33
tests/results/test_namespace/40_0leadership_reduce.adoc
Normal file
33
tests/results/test_namespace/40_0leadership_reduce.adoc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
== Variables for "Rougail"
|
||||
|
||||
=== a leadership
|
||||
|
||||
`basic`
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
[cols="1a,1a"]
|
||||
|====
|
||||
| Variable | Description
|
||||
|
|
||||
|
||||
**rougail.leadership.leader** +
|
||||
`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `standard` `mandatory` `unique` `multiple` |
|
||||
A leader. +
|
||||
**Default**:
|
||||
|
||||
* value_1
|
||||
* value_2
|
||||
* value_3
|
||||
|
||||
**Examples**:
|
||||
|
||||
* val1
|
||||
* val2
|
||||
|
|
||||
|
||||
**rougail.leadership.follower** +
|
||||
`https://rougail.readthedocs.io/en/latest/variable.html#variables-types[string]` `basic` `mandatory` |
|
||||
A follower.
|
||||
|====
|
||||
|
||||
114
tests/results/test_namespace/40_0leadership_reduce.json
Normal file
114
tests/results/test_namespace/40_0leadership_reduce.json
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
{
|
||||
"rougail": {
|
||||
"type": "namespace",
|
||||
"informations": {
|
||||
"paths": [
|
||||
"rougail"
|
||||
],
|
||||
"names": [
|
||||
"rougail"
|
||||
],
|
||||
"description": "Rougail",
|
||||
"properties": [
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "basic"
|
||||
}
|
||||
]
|
||||
},
|
||||
"children": {
|
||||
"leadership": {
|
||||
"type": "leadership",
|
||||
"informations": {
|
||||
"paths": [
|
||||
"rougail.leadership"
|
||||
],
|
||||
"names": [
|
||||
"leadership"
|
||||
],
|
||||
"description": "a leadership",
|
||||
"properties": [
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "basic"
|
||||
}
|
||||
],
|
||||
"help": [
|
||||
"This family contains lists of variable blocks."
|
||||
]
|
||||
},
|
||||
"children": {
|
||||
"rougail.leadership.leader": {
|
||||
"type": "variable",
|
||||
"default": [
|
||||
"value_1",
|
||||
"value_2",
|
||||
"value_3"
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"type": "type",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "standard"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "mandatory"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "unique"
|
||||
},
|
||||
{
|
||||
"type": "multiple",
|
||||
"name": "multiple"
|
||||
}
|
||||
],
|
||||
"paths": [
|
||||
"rougail.leadership.leader"
|
||||
],
|
||||
"names": [
|
||||
"leader"
|
||||
],
|
||||
"descriptions": [
|
||||
"A leader."
|
||||
],
|
||||
"examples": [
|
||||
"val1",
|
||||
"val2"
|
||||
]
|
||||
},
|
||||
"rougail.leadership.follower": {
|
||||
"type": "variable",
|
||||
"properties": [
|
||||
{
|
||||
"type": "type",
|
||||
"name": "string"
|
||||
},
|
||||
{
|
||||
"type": "mode",
|
||||
"name": "basic"
|
||||
},
|
||||
{
|
||||
"type": "property",
|
||||
"name": "mandatory"
|
||||
}
|
||||
],
|
||||
"paths": [
|
||||
"rougail.leadership.follower"
|
||||
],
|
||||
"names": [
|
||||
"follower"
|
||||
],
|
||||
"descriptions": [
|
||||
"A follower."
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
tests/results/test_namespace/40_0leadership_reduce.md
Normal file
13
tests/results/test_namespace/40_0leadership_reduce.md
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Variables for "Rougail"
|
||||
|
||||
## a leadership
|
||||
|
||||
`basic`
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
| Variable | Description |
|
||||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **rougail.leadership.leader**<br/>[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `standard` `mandatory` `unique` `multiple` | A leader.<br/>**Default**: <br/>- value_1<br/>- value_2<br/>- value_3<br/>**Examples**: <br/>- val1<br/>- val2 |
|
||||
| **rougail.leadership.follower**<br/>[`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `basic` `mandatory` | A follower. |
|
||||
|
||||
31
tests/results/test_namespace/40_0leadership_reduce.sh
Normal file
31
tests/results/test_namespace/40_0leadership_reduce.sh
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
|
||||
[1;4;96mVariables for [0m[1;4;96m"Rougail"[0m
|
||||
|
||||
|
||||
|
||||
|
||||
[1;4;92ma leadership[0m
|
||||
|
||||
|
||||
[1;7m basic [0m
|
||||
|
||||
|
||||
This family contains lists of variable blocks.
|
||||
|
||||
|
||||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃[1m [0m[1mVariable [0m[1m [0m┃[1m [0m[1mDescription [0m[1m [0m┃
|
||||
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
|
||||
│ [1mrougail.leadership.leader[0m │ A leader. │
|
||||
│ [1;7m string [0m [1;7m standard [0m [1;7m mandatory [0m [1;7m [0m │ [1mDefault[0m: │
|
||||
│ [1;7munique [0m [1;7m multiple [0m │ - value_1 │
|
||||
│ │ - value_2 │
|
||||
│ │ - value_3 │
|
||||
│ │ [1mExamples[0m: │
|
||||
│ │ - val1 │
|
||||
│ │ - val2 │
|
||||
├───────────────────────────────────────┼──────────────────────────────────────┤
|
||||
│ [1mrougail.leadership.follower[0m │ A follower. │
|
||||
│ [1;7m string [0m [1;7m basic [0m [1;7m mandatory [0m │ │
|
||||
└───────────────────────────────────────┴──────────────────────────────────────┘
|
||||
1
tests/results/test_namespace/warnings_00_0no_variable
Normal file
1
tests/results/test_namespace/warnings_00_0no_variable
Normal file
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
0
tests/results/test_namespace_examples/00_0no_variable.md
Normal file
0
tests/results/test_namespace_examples/00_0no_variable.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Example with all variables modifiable
|
||||
|
||||
```yaml
|
||||
---
|
||||
rougail:
|
||||
leadership:
|
||||
- leader: val1
|
||||
follower: example
|
||||
- leader: val2
|
||||
follower: example
|
||||
```
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[]
|
||||
|
|
@ -20,7 +20,7 @@ excludes = [
|
|||
]
|
||||
|
||||
test_ok = get_structures_list(excludes)
|
||||
# test_ok = [HERE.parent.parent / "rougail-tests" / "structures" / "60_5family_dynamic_calc_suffix_hidden"]
|
||||
# test_ok = [HERE.parent.parent / "rougail-tests" / "structures" / "40_0leadership_reduce"]
|
||||
|
||||
os.environ['COLUMNS'] = '80'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue