-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Wrote user docs, edit docstrings for .rst syntax
- Loading branch information
1 parent
ce64bc8
commit 53a8cee
Showing
5 changed files
with
219 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.. currentmodule:: confiddler | ||
|
||
.. _core: | ||
|
||
|
||
API Reference | ||
============= | ||
|
||
.. | ||
(The following |br| definition is the only way | ||
I can force numpydoc to display explicit newlines...) | ||
.. |br| raw:: html | ||
|
||
<br /> | ||
|
||
|
||
.. | ||
- :py:func:`load_config <load_config>` | ||
|
||
.. autofunction:: load_config | ||
.. autofunction:: dump_default_config | ||
|
||
.. autofunction:: validate | ||
.. autofunction:: emit_defaults | ||
|
||
|
||
.. | ||
.. autofunction:: flow_style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.. _quickstart: | ||
|
||
|
||
Quickstart | ||
---------- | ||
|
||
Define your schema | ||
|
||
.. code-block:: python | ||
>>> from confiddler import dump_default_config, load_config | ||
>>> schema = { | ||
"description": "Settings for a robot vacuum cleaner", | ||
"properties": { | ||
"speed": { | ||
"description": "Speed of the robot (1-10)", | ||
"type": "number", | ||
"minValue": 1, | ||
"maxValue": 10, | ||
"default": 1 | ||
}, | ||
"movement": { | ||
"description": "Movement strategy: random, raster, or spiral", | ||
"type": "string", | ||
"enum": ["random", "raster", "spiral"], | ||
"default": "random" | ||
} | ||
} | ||
} | ||
Show your user the default config. | ||
|
||
.. code-block:: python | ||
>>> dump_default_config(schema, sys.stdout, 'yaml') | ||
speed: 1 | ||
movement: random | ||
>>> dump_default_config(schema, sys.stdout, 'yaml-with-comments') | ||
# | ||
# Settings for a robot vacuum cleaner | ||
# | ||
# Speed of the robot (1-10) | ||
speed: 1 | ||
# Movement strategy: random, raster, or spiral | ||
movement: random | ||
Load your user's config. | ||
|
||
.. code-block:: yaml | ||
# my-robot-config.yaml | ||
speed: 2 | ||
.. code-block:: python | ||
>>> load_config('my-robot-config.yaml', schema, inject_defaults=True) | ||
{'speed': 2, 'movement': 'random'} | ||