WIP: Expand the developer documentation #27

Draft
gremond wants to merge 51 commits from develop into developer_docs
2 changed files with 22 additions and 23 deletions
Showing only changes of commit 7c69ac9557 - Show all commits

View file

@ -28,20 +28,27 @@ Create the file `dict/dictionary.yml`:
```yml
---
version: '1.0'
version: 1.1
# describe a variable my_first_variable
# and a family with a variable my_second_variable
my_first_variable:
default: my_value
my_first_variable: my_value
my_family:
my_second_variable:
type: number
mandatory: true
value: 1
my_second_variable: 1
```
## Generate variable
### With commandline:
```bash
# rougail -m dict
Variables:
┣━━ 📓 my_first_variable: my_value
┗━━ 📂 my_family
┗━━ 📓 my_second_variable: 1
```
### With default value:
Here is a python3 example file:
@ -51,19 +58,16 @@ from rougail import Rougail, RougailConfig
from pprint import pprint
RougailConfig['dictionaries_dir'] = ['dict']
RougailConfig['templates_dir'] = ['tmpl']
RougailConfig['tmp_dir'] = 'tmp'
RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
config = rougail.run()
pprint(config.value.get(), sort_dicts=False)
```
The result is:
```json
{'rougail.my_first_variable': 'my_value',
'rougail.my_family.my_second_variable': 1}
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'my_value',
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 1}}}
```
### With modified value
@ -76,9 +80,6 @@ from rougail import Rougail, RougailConfig
from pprint import pprint
RougailConfig['dictionaries_dir'] = ['dict']
RougailConfig['templates_dir'] = ['tmpl']
RougailConfig['tmp_dir'] = 'tmp'
RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
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:
```json
{'rougail.my_first_variable': 'modified_value',
'rougail.my_family.my_second_variable': 2}
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'modified_value',
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 2}}}
```
# Link

View file

@ -406,7 +406,7 @@ suffix:
disabled:
variable: upgrade"""
for process in processes:
if processes[process]:
if processes[process] or process == 'output':
objects = processes[process]
rougail_process += """
{NAME}:
@ -438,10 +438,8 @@ suffix:
rougail_process += """ {% if _.output == 'NAME' %}
Cannot load user data for NAME output
{% endif %}
""".replace(
"NAME", hidden_output
)
else:
""".replace("NAME", hidden_output)
elif objects:
rougail_process += " default: {DEFAULT}".format(
DEFAULT=objects[0]["name"]
)