WIP: Expand the developer documentation #27
2 changed files with 22 additions and 23 deletions
37
README.md
37
README.md
|
@ -28,20 +28,27 @@ Create the file `dict/dictionary.yml`:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
---
|
---
|
||||||
version: '1.0'
|
version: 1.1
|
||||||
# describe a variable my_first_variable
|
# describe a variable my_first_variable
|
||||||
# and a family with a variable my_second_variable
|
# and a family with a variable my_second_variable
|
||||||
my_first_variable:
|
my_first_variable: my_value
|
||||||
default: my_value
|
|
||||||
my_family:
|
my_family:
|
||||||
my_second_variable:
|
my_second_variable: 1
|
||||||
type: number
|
|
||||||
mandatory: true
|
|
||||||
value: 1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generate variable
|
## Generate variable
|
||||||
|
|
||||||
|
### With commandline:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# rougail -m dict
|
||||||
|
Variables:
|
||||||
|
┣━━ 📓 my_first_variable: my_value
|
||||||
|
┗━━ 📂 my_family
|
||||||
|
┗━━ 📓 my_second_variable: 1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### With default value:
|
### With default value:
|
||||||
|
|
||||||
Here is a python3 example file:
|
Here is a python3 example file:
|
||||||
|
@ -51,19 +58,16 @@ from rougail import Rougail, RougailConfig
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
RougailConfig['dictionaries_dir'] = ['dict']
|
RougailConfig['dictionaries_dir'] = ['dict']
|
||||||
RougailConfig['templates_dir'] = ['tmpl']
|
|
||||||
RougailConfig['tmp_dir'] = 'tmp'
|
|
||||||
RougailConfig['destinations_dir'] = 'dest'
|
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.get_config()
|
config = rougail.run()
|
||||||
pprint(config.value.get(), sort_dicts=False)
|
pprint(config.value.get(), sort_dicts=False)
|
||||||
```
|
```
|
||||||
|
|
||||||
The result is:
|
The result is:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{'rougail.my_first_variable': 'my_value',
|
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'my_value',
|
||||||
'rougail.my_family.my_second_variable': 1}
|
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 1}}}
|
||||||
```
|
```
|
||||||
|
|
||||||
### With modified value
|
### With modified value
|
||||||
|
@ -76,9 +80,6 @@ from rougail import Rougail, RougailConfig
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
RougailConfig['dictionaries_dir'] = ['dict']
|
RougailConfig['dictionaries_dir'] = ['dict']
|
||||||
RougailConfig['templates_dir'] = ['tmpl']
|
|
||||||
RougailConfig['tmp_dir'] = 'tmp'
|
|
||||||
RougailConfig['destinations_dir'] = 'dest'
|
|
||||||
rougail = Rougail()
|
rougail = Rougail()
|
||||||
config = rougail.get_config()
|
config = rougail.get_config()
|
||||||
config.option('rougail.my_first_variable').value.set('modified_value')
|
config.option('rougail.my_first_variable').value.set('modified_value')
|
||||||
|
@ -89,8 +90,8 @@ pprint(config.value.get(), sort_dicts=False)
|
||||||
The destination file is generated with new values:
|
The destination file is generated with new values:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{'rougail.my_first_variable': 'modified_value',
|
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'modified_value',
|
||||||
'rougail.my_family.my_second_variable': 2}
|
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 2}}}
|
||||||
```
|
```
|
||||||
|
|
||||||
# Link
|
# Link
|
||||||
|
|
|
@ -406,7 +406,7 @@ suffix:
|
||||||
disabled:
|
disabled:
|
||||||
variable: upgrade"""
|
variable: upgrade"""
|
||||||
for process in processes:
|
for process in processes:
|
||||||
if processes[process]:
|
if processes[process] or process == 'output':
|
||||||
objects = processes[process]
|
objects = processes[process]
|
||||||
rougail_process += """
|
rougail_process += """
|
||||||
{NAME}:
|
{NAME}:
|
||||||
|
@ -438,10 +438,8 @@ suffix:
|
||||||
rougail_process += """ {% if _.output == 'NAME' %}
|
rougail_process += """ {% if _.output == 'NAME' %}
|
||||||
Cannot load user data for NAME output
|
Cannot load user data for NAME output
|
||||||
{% endif %}
|
{% endif %}
|
||||||
""".replace(
|
""".replace("NAME", hidden_output)
|
||||||
"NAME", hidden_output
|
elif objects:
|
||||||
)
|
|
||||||
else:
|
|
||||||
rougail_process += " default: {DEFAULT}".format(
|
rougail_process += " default: {DEFAULT}".format(
|
||||||
DEFAULT=objects[0]["name"]
|
DEFAULT=objects[0]["name"]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue