fix: doc example with leader example lower than leader default value

This commit is contained in:
egarette@silique.fr 2025-05-11 14:44:46 +02:00
parent 8f2c4b0011
commit 561d117d4d
58 changed files with 404 additions and 7 deletions

View file

@ -208,14 +208,15 @@ class RougailOutputDoc(Examples):
def _parse_variable( def _parse_variable(
self, variable, leader: dict, name: str, path: str, informations: dict self, variable, leader: dict, name: str, path: str, informations: dict
) -> Optional[dict]: ) -> Optional[dict]:
potential_leader = None
if variable.isdynamic(): if variable.isdynamic():
# information is already set # information is already set
potential_leader = self._parse_variable_dynamic( potential_leader = self._parse_variable_dynamic(
variable, leader, name, path, informations variable, leader, name, path, informations
) )
elif variable.isfollower() and variable.index(): elif variable.isfollower() and variable.index():
potential_leader = self._parse_variable_follower_with_index( self._parse_variable_follower_with_index(
variable, path, informations variable, leader, path, informations
) )
else: else:
potential_leader = self._parse_variable_normal( potential_leader = self._parse_variable_normal(
@ -244,14 +245,13 @@ class RougailOutputDoc(Examples):
return None return None
def _parse_variable_follower_with_index( def _parse_variable_follower_with_index(
self, variable, path: str, informations: dict self, variable, leader: dict, path: str, informations: dict
) -> None: ) -> None:
if not self.example: if not self.example or (variable.index() + 1) > len(leader['example'][-1]):
return None return
informations[path]["example"][-1][variable.index()] = self._get_example( informations[path]["example"][-1][variable.index()] = self._get_example(
variable, informations[path], None variable, informations[path], None
) )
return None
def _parse_variable_dynamic( def _parse_variable_dynamic(
self, variable, leader, name, path, informations self, variable, leader, name, path, informations
@ -432,6 +432,7 @@ class RougailOutputDoc(Examples):
if multi: if multi:
example = [example] example = [example]
if leader is not None and variable.isfollower(): 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) example = [example] + [undefined] * (len(leader["example"][-1]) - 1)
return example return example

View file

View file

@ -0,0 +1 @@
{}

View file

View file

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

View 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.
|====

View 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."
]
}
}
}
}

View 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. |

View file

@ -0,0 +1,26 @@
a leadership
 basic 
This family contains lists of variable blocks.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
 Variable  ┃ Description  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
leadership.leader │ A leader. │
 string   standard   mandatory    │ Default: │
unique   multiple  │ - value_1 │
│ │ - value_2 │
│ │ - value_3 │
│ │ Examples: │
│ │ - val1 │
│ │ - val2 │
├───────────────────────────────────────┼──────────────────────────────────────┤
leadership.follower │ A follower. │
 string   basic   mandatory  │ │
└───────────────────────────────────────┴──────────────────────────────────────┘

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,10 @@
# Example with all variables modifiable
```yaml
---
leadership:
- leader: val1
follower: example
- leader: val2
follower: example
```

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

View 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.
|====

View 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."
]
}
}
}
}
}
}

View file

@ -0,0 +1,13 @@
# Variables for "Rougail"
## a leadership
`basic`
This family contains lists of variable blocks.
| Variable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **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. |

View file

@ -0,0 +1,31 @@
Variables for "Rougail"
a leadership
 basic 
This family contains lists of variable blocks.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
 Variable  ┃ Description  ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
rougail.leadership.leader │ A leader. │
 string   standard   mandatory    │ Default: │
unique   multiple  │ - value_1 │
│ │ - value_2 │
│ │ - value_3 │
│ │ Examples: │
│ │ - val1 │
│ │ - val2 │
├───────────────────────────────────────┼──────────────────────────────────────┤
rougail.leadership.follower │ A follower. │
 string   basic   mandatory  │ │
└───────────────────────────────────────┴──────────────────────────────────────┘

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,11 @@
# Example with all variables modifiable
```yaml
---
rougail:
leadership:
- leader: val1
follower: example
- leader: val2
follower: example
```

View file

@ -0,0 +1 @@
[]

View file

@ -20,7 +20,7 @@ excludes = [
] ]
test_ok = get_structures_list(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' os.environ['COLUMNS'] = '80'