documentation on the requirements and docstring updates
This commit is contained in:
@ -50,17 +50,27 @@ Configuration options can specify requirements as parameters at the init
|
||||
time, the specification of some links between options or groups allows
|
||||
to carry out a dependencies calculation. For example, an option can ben
|
||||
hidden if another option has been set with some expected value. This is
|
||||
just an example, because the possibilities are hudge.
|
||||
just an example, the possibilities are hudge.
|
||||
|
||||
A requirement is specified using a list of triplets. The first element
|
||||
of the triplet gives the path of the option that is required, the second
|
||||
element is the value wich is expected to trigger the callback, and the
|
||||
third one is the callback's action name (`hide`, `show`...)::
|
||||
A requirement is a list of dictionnaries that have fairly this form::
|
||||
|
||||
stroption = StrOption('str', 'Test string option', default="abc",
|
||||
requires=[('int', 1, 'hide')])
|
||||
[{'option': a, 'expected': False, 'action': 'disabled', 'inverse': True,
|
||||
'transitive':True, 'same_action': True}]
|
||||
|
||||
Requirements are validated in :class:`setting.Setting`.
|
||||
Actually a transformation is made to this dictionnary during the validation of
|
||||
this requires at the :class:`~option.Option()`'s init. The dictionnairy becomes
|
||||
a tuple, wich is passed to the :meth:`~setting.Settings.apply_requires()`
|
||||
method. Take a look at the code to fully understand the exact meaning of the
|
||||
requirements:
|
||||
|
||||
.. automethod:: tiramisu.setting.Settings.apply_requires
|
||||
|
||||
|
||||
The path of the option is required, the second element is the value wich is
|
||||
expected to trigger the callback, it is required too, and the third one is the
|
||||
callback's action name (`hide`, `show`...), wich is a
|
||||
:class:`~setting.Property()`. Requirements are validated in
|
||||
:class:`setting.Setting`.
|
||||
|
||||
Validation upon a whole configuration object
|
||||
----------------------------------------------
|
||||
|
Reference in New Issue
Block a user