rougail/docs/library/extra.rst

46 lines
1.3 KiB
ReStructuredText
Raw Normal View History

2025-10-26 13:29:29 +01:00
Let's convert an extra namespace structural file
================================================
.. index:: extras
The default namespace for variables and families is `rougail`. It is possible to define other namespaces. These additional namespaces are called `extras`.
.. FIXME: faire une page pour les extras
Additional namespaces are defined during configuration.
For example, here's how to add an `example` namespace:
.. code-block:: python
RougailConfig['extra_namespaces']['example'] = ['extras/']
Then let's create an extra :term:`structure file` :file:`extras/00-base.yml`:
.. code-block:: yaml
:caption: the :file:`extras/00-base.yml` file content
---
version: '1.1'
my_variable_extra:
default: my_value_extra
Then, let's create the :term:`Tiramisu` objects via the following :file:`script.py` script:
.. code-block:: python
:caption: the :file:`script.py` file content
from rougail import Rougail, RougailConfig
RougailConfig['main_structural_directories'] = ['dict']
RougailConfig['extra_namespaces']['example'] = ['extras/']
rougail = Rougail()
config = rougail.get_config()
print(config.value.dict())
Let's execute `script.py`:
.. code-block:: bash
$ python3 script.py
{'rougail.my_variable': 'my_value', 'example.my_variable_extra': 'my_value_extra'}