Skip to content

Commit cb248e0

Browse files
committed
Update docs
1 parent a4cee7d commit cb248e0

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

docs/providers/configuration.rst

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,18 @@ where ``examples/providers/configuration/config.ini`` is:
4343
:language: ini
4444

4545
:py:meth:`Configuration.from_ini` method supports environment variables interpolation. Use
46-
``${ENV_NAME}`` format in the configuration file to substitute value of the environment
47-
variable ``ENV_NAME``.
46+
``${ENV_NAME}`` format in the configuration file to substitute value from ``ENV_NAME`` environment
47+
variable.
48+
49+
You can also specify a default value using ``${ENV_NAME:default}`` format. If environment
50+
variable ``ENV_NAME`` is undefined, configuration provider will substitute value ``default``.
51+
52+
.. code-block:: ini
53+
54+
[section]
55+
option1 = {$ENV_VAR}
56+
option2 = {$ENV_VAR}/path
57+
option3 = {$ENV_VAR:default}
4858
4959
Loading from a YAML file
5060
------------------------
@@ -62,12 +72,22 @@ where ``examples/providers/configuration/config.yml`` is:
6272
.. literalinclude:: ../../examples/providers/configuration/config.yml
6373
:language: ini
6474

65-
:py:meth:`Configuration.from_yaml` method uses custom version of ``yaml.SafeLoader``.
75+
:py:meth:`Configuration.from_yaml` method supports environment variables interpolation. Use
76+
``${ENV_NAME}`` format in the configuration file to substitute value from ``ENV_NAME`` environment
77+
variable.
6678

67-
The loader supports environment variables interpolation. Use ``${ENV_NAME}`` format
68-
in the configuration file to substitute value of the environment variable ``ENV_NAME``.
79+
You can also specify a default value using ``${ENV_NAME:default}`` format. If environment
80+
variable ``ENV_NAME`` is undefined, configuration provider will substitute value ``default``.
6981

70-
You can also specify a YAML loader as an argument:
82+
.. code-block:: ini
83+
84+
section:
85+
option1: {$ENV_VAR}
86+
option2: {$ENV_VAR}/path
87+
option3: {$ENV_VAR:default}
88+
89+
:py:meth:`Configuration.from_yaml` method uses custom version of ``yaml.SafeLoader``.
90+
To use another loader use ``loader`` argument:
7191

7292
.. code-block:: python
7393

0 commit comments

Comments
 (0)