ycleptic 2.2.0__tar.gz → 2.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {ycleptic-2.2.0 → ycleptic-2.2.1}/CHANGELOG.md +9 -0
  2. ycleptic-2.2.1/PKG-INFO +161 -0
  3. ycleptic-2.2.1/README.md +114 -0
  4. ycleptic-2.2.1/docs/source/index.rst +28 -0
  5. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/class.rst +2 -1
  6. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/interactive_help.rst +5 -4
  7. ycleptic-2.2.1/docs/source/usage/quickstart.rst +72 -0
  8. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/resource_file.rst +4 -4
  9. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/the_base_config.rst +40 -8
  10. ycleptic-2.2.1/docs/source/usage/yclept_config-help.rst +41 -0
  11. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/yclept_makedoc.rst +1 -1
  12. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage.rst +2 -1
  13. {ycleptic-2.2.0 → ycleptic-2.2.1}/pyproject.toml +1 -1
  14. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set.py +9 -0
  15. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/resources/example_base.yaml +2 -2
  16. ycleptic-2.2.0/PKG-INFO +0 -88
  17. ycleptic-2.2.0/README.md +0 -41
  18. ycleptic-2.2.0/docs/source/changelog.md +0 -5
  19. ycleptic-2.2.0/docs/source/index.rst +0 -26
  20. ycleptic-2.2.0/docs/source/usage/yclept_config-help.rst +0 -10
  21. {ycleptic-2.2.0 → ycleptic-2.2.1}/.envrc +0 -0
  22. {ycleptic-2.2.0 → ycleptic-2.2.1}/.github/workflows/ci.yaml +0 -0
  23. {ycleptic-2.2.0 → ycleptic-2.2.1}/.github/workflows/release.yaml +0 -0
  24. {ycleptic-2.2.0 → ycleptic-2.2.1}/.gitignore +0 -0
  25. {ycleptic-2.2.0 → ycleptic-2.2.1}/.readthedocs.yaml +0 -0
  26. {ycleptic-2.2.0 → ycleptic-2.2.1}/LICENSE +0 -0
  27. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/Makefile +0 -0
  28. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/make.bat +0 -0
  29. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/requirements.txt +0 -0
  30. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/_static/css/custom.css +0 -0
  31. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/about.rst +0 -0
  32. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/API.rst +0 -0
  33. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.cli.rst +0 -0
  34. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.dictthings.rst +0 -0
  35. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.errors.rst +0 -0
  36. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.makedoc.rst +0 -0
  37. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.resources.rst +0 -0
  38. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.rst +0 -0
  39. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.stringthings.rst +0 -0
  40. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.walkers.rst +0 -0
  41. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/api/ycleptic.yclept.rst +0 -0
  42. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/changelog.rst +0 -0
  43. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/conf.py +0 -0
  44. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/installation.rst +0 -0
  45. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/roadmap.md +0 -0
  46. {ycleptic-2.2.0 → ycleptic-2.2.1}/docs/source/usage/the_user_config.rst +0 -0
  47. {ycleptic-2.2.0 → ycleptic-2.2.1}/pytest.ini +0 -0
  48. {ycleptic-2.2.0 → ycleptic-2.2.1}/scripts/release.sh +0 -0
  49. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/__init__.py +0 -0
  50. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/conftest.py +0 -0
  51. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/README.md +0 -0
  52. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/__init__.py +0 -0
  53. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/config.py +0 -0
  54. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/data/__init__.py +0 -0
  55. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/data/base.yaml +0 -0
  56. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/docs/source/intro.rst +0 -0
  57. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/mypackage/otherstuff/stuff.py +0 -0
  58. {ycleptic-2.2.0 → ycleptic-2.2.1}/tests/test_set/test_package/rootdir/setup.py +0 -0
  59. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/__init__.py +0 -0
  60. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/cli.py +0 -0
  61. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/dictthings.py +0 -0
  62. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/errors.py +0 -0
  63. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/makedoc.py +0 -0
  64. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/resources/__init__.py +0 -0
  65. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/src/__init__.py +0 -0
  66. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/stringthings.py +0 -0
  67. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/walkers.py +0 -0
  68. {ycleptic-2.2.0 → ycleptic-2.2.1}/ycleptic/yclept.py +0 -0
@@ -5,6 +5,15 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.2.1] - 2026-07-21
9
+
10
+ ### Changed
11
+ - Repositioned the README and documentation landing page to lead with Ycleptic's distinctive workflow — one YAML schema as a single source of truth for validation, generated documentation, and interactive help — with an honest "when to use it" comparison to pydantic, jsonschema, and Hydra
12
+
13
+ ### Fixed
14
+ - `example_base.yaml` used `options:` for two attributes, but only `choices:` is actually validated; those keys are now `choices:` so the shipped example enforces its allowed values as documented
15
+ - Documentation audit: corrected the allowed-values key from `options` to `choices` throughout; documented the previously-undocumented `case_sensitive` key and the `tuple` type; fixed the non-runnable `MyConfig` example snippets (`super().__init__(basefile, userfile=...)` and a missing `import os`); replaced stale "Directive" terminology left from the 2.0.3 rename; added a Quickstart page and a worked `docs:` example; fleshed out the `config-help` page with sample output; and fixed assorted typos
16
+
8
17
  ## [2.2.0] - 2026-07-21
9
18
 
10
19
  ### Added
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: ycleptic
3
+ Version: 2.2.1
4
+ Summary: A YAML-format configuration generator
5
+ Project-URL: Source, https://github.com/cameronabrams/ycleptic
6
+ Project-URL: Documentation, https://ycleptic.readthedocs.io/en/latest/
7
+ Project-URL: Bug Tracker, https://github.com/cameronabrams/ycleptic/issues
8
+ Author-email: Cameron F Abrams <cfa22@drexel.edu>
9
+ License: MIT License
10
+
11
+ Copyright (c) 2022 Cameron Abrams
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.9
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Requires-Python: >=3.9
40
+ Requires-Dist: pyyaml>=6
41
+ Provides-Extra: lint
42
+ Requires-Dist: mypy; extra == 'lint'
43
+ Requires-Dist: ruff==0.15.22; extra == 'lint'
44
+ Provides-Extra: test
45
+ Requires-Dist: pytest; extra == 'test'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # Ycleptic
49
+ > Self-documenting YAML configuration for Python applications
50
+
51
+ One structured YAML file describes your application's configuration schema. From
52
+ that single source of truth, Ycleptic gives you three things that normally live
53
+ in three separate places:
54
+
55
+ 1. **Validation & defaults** — a user's YAML config is checked against the
56
+ schema (allowed keys, data types, `choices`, required values), and omitted
57
+ parameters are filled in from their declared defaults.
58
+ 2. **Generated documentation** — `yclept make-doc` builds an RST/Sphinx
59
+ documentation tree for your config directly from the schema.
60
+ 3. **Interactive help** — `yclept config-help` lets users explore the
61
+ configuration tree and read the help text for every parameter.
62
+
63
+ Because the schema is *data* — a YAML file you ship as package data, not a set of
64
+ Python classes — editing that one file keeps validation, documentation, and help
65
+ in lockstep. No more reference docs drifting out of date because you added a
66
+ parameter and forgot to write it up.
67
+
68
+ ## When to use it
69
+
70
+ Ycleptic fills a specific niche: it shines when your configuration's **schema
71
+ should double as its documentation**, and when your users benefit from
72
+ *exploring* that configuration interactively — a common situation in scientific
73
+ and command-line applications whose users are domain experts rather than
74
+ programmers.
75
+
76
+ It is intentionally **not** a heavyweight validation engine. If your main need is:
77
+
78
+ - **robust validation, coercion, and rich error messages** — reach for
79
+ [pydantic](https://docs.pydantic.dev/) or
80
+ [jsonschema](https://python-jsonschema.readthedocs.io/);
81
+ - **composable, hierarchical config with overrides and interpolation** — reach
82
+ for [Hydra / OmegaConf](https://hydra.cc/).
83
+
84
+ Ycleptic keeps validation deliberately lightweight and puts its weight behind the
85
+ spec-as-documentation workflow. (It also supports a per-user dotfile/rcfile that
86
+ extends or overrides the base config, merged in automatically at load time.)
87
+
88
+ ## How it works
89
+
90
+ As the developer, you write a **base config** that specifies what your users may
91
+ configure:
92
+
93
+ ```yaml
94
+ # mypackage/data/base.yaml
95
+ attributes:
96
+ - name: temperature
97
+ type: float
98
+ text: Simulation temperature in kelvin
99
+ default: 300.0
100
+ - name: integrator
101
+ type: str
102
+ text: Integration scheme to use
103
+ choices: [verlet, langevin]
104
+ default: verlet
105
+ ```
106
+
107
+ Your app reads the base config together with the user's config through the
108
+ `Yclept` class (typically subclassed):
109
+
110
+ ```python
111
+ from ycleptic import Yclept, YclepticError
112
+
113
+ try:
114
+ config = Yclept(basefile='mypackage/data/base.yaml', userfile=user_yaml)
115
+ except YclepticError as e:
116
+ raise SystemExit(f'Invalid configuration: {e}')
117
+ ```
118
+
119
+ Then, from the *same* base config, you can generate reference documentation:
120
+
121
+ ```bash
122
+ yclept make-doc mypackage/data/base.yaml --root docs/source/config_ref
123
+ ```
124
+
125
+ and your users can explore the configuration interactively:
126
+
127
+ ```bash
128
+ yclept config-help mypackage/data/base.yaml
129
+ ```
130
+
131
+ ## Installation
132
+
133
+ ```bash
134
+ pip install ycleptic
135
+ ```
136
+
137
+ ## Documentation
138
+
139
+ Full documentation is at <https://ycleptic.readthedocs.io/en/latest/>.
140
+
141
+ ## Release History
142
+
143
+ See [CHANGELOG.md](CHANGELOG.md) for the full release history.
144
+
145
+ ## Meta
146
+
147
+ Cameron F. Abrams – cfa22@drexel.edu
148
+
149
+ Distributed under the MIT license. See `LICENSE` for more information.
150
+
151
+ [https://github.com/cameronabrams](https://github.com/cameronabrams/)
152
+
153
+ [https://github.com/AbramsGroup](https://github.com/AbramsGroup/)
154
+
155
+ ## Contributing
156
+
157
+ 1. Fork it (<https://github.com/cameronabrams/ycleptic/fork>)
158
+ 2. Create your feature branch (`git checkout -b feature/fooBar`)
159
+ 3. Commit your changes (`git commit -am 'Add some fooBar'`)
160
+ 4. Push to the branch (`git push origin feature/fooBar`)
161
+ 5. Create a new Pull Request
@@ -0,0 +1,114 @@
1
+ # Ycleptic
2
+ > Self-documenting YAML configuration for Python applications
3
+
4
+ One structured YAML file describes your application's configuration schema. From
5
+ that single source of truth, Ycleptic gives you three things that normally live
6
+ in three separate places:
7
+
8
+ 1. **Validation & defaults** — a user's YAML config is checked against the
9
+ schema (allowed keys, data types, `choices`, required values), and omitted
10
+ parameters are filled in from their declared defaults.
11
+ 2. **Generated documentation** — `yclept make-doc` builds an RST/Sphinx
12
+ documentation tree for your config directly from the schema.
13
+ 3. **Interactive help** — `yclept config-help` lets users explore the
14
+ configuration tree and read the help text for every parameter.
15
+
16
+ Because the schema is *data* — a YAML file you ship as package data, not a set of
17
+ Python classes — editing that one file keeps validation, documentation, and help
18
+ in lockstep. No more reference docs drifting out of date because you added a
19
+ parameter and forgot to write it up.
20
+
21
+ ## When to use it
22
+
23
+ Ycleptic fills a specific niche: it shines when your configuration's **schema
24
+ should double as its documentation**, and when your users benefit from
25
+ *exploring* that configuration interactively — a common situation in scientific
26
+ and command-line applications whose users are domain experts rather than
27
+ programmers.
28
+
29
+ It is intentionally **not** a heavyweight validation engine. If your main need is:
30
+
31
+ - **robust validation, coercion, and rich error messages** — reach for
32
+ [pydantic](https://docs.pydantic.dev/) or
33
+ [jsonschema](https://python-jsonschema.readthedocs.io/);
34
+ - **composable, hierarchical config with overrides and interpolation** — reach
35
+ for [Hydra / OmegaConf](https://hydra.cc/).
36
+
37
+ Ycleptic keeps validation deliberately lightweight and puts its weight behind the
38
+ spec-as-documentation workflow. (It also supports a per-user dotfile/rcfile that
39
+ extends or overrides the base config, merged in automatically at load time.)
40
+
41
+ ## How it works
42
+
43
+ As the developer, you write a **base config** that specifies what your users may
44
+ configure:
45
+
46
+ ```yaml
47
+ # mypackage/data/base.yaml
48
+ attributes:
49
+ - name: temperature
50
+ type: float
51
+ text: Simulation temperature in kelvin
52
+ default: 300.0
53
+ - name: integrator
54
+ type: str
55
+ text: Integration scheme to use
56
+ choices: [verlet, langevin]
57
+ default: verlet
58
+ ```
59
+
60
+ Your app reads the base config together with the user's config through the
61
+ `Yclept` class (typically subclassed):
62
+
63
+ ```python
64
+ from ycleptic import Yclept, YclepticError
65
+
66
+ try:
67
+ config = Yclept(basefile='mypackage/data/base.yaml', userfile=user_yaml)
68
+ except YclepticError as e:
69
+ raise SystemExit(f'Invalid configuration: {e}')
70
+ ```
71
+
72
+ Then, from the *same* base config, you can generate reference documentation:
73
+
74
+ ```bash
75
+ yclept make-doc mypackage/data/base.yaml --root docs/source/config_ref
76
+ ```
77
+
78
+ and your users can explore the configuration interactively:
79
+
80
+ ```bash
81
+ yclept config-help mypackage/data/base.yaml
82
+ ```
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ pip install ycleptic
88
+ ```
89
+
90
+ ## Documentation
91
+
92
+ Full documentation is at <https://ycleptic.readthedocs.io/en/latest/>.
93
+
94
+ ## Release History
95
+
96
+ See [CHANGELOG.md](CHANGELOG.md) for the full release history.
97
+
98
+ ## Meta
99
+
100
+ Cameron F. Abrams – cfa22@drexel.edu
101
+
102
+ Distributed under the MIT license. See `LICENSE` for more information.
103
+
104
+ [https://github.com/cameronabrams](https://github.com/cameronabrams/)
105
+
106
+ [https://github.com/AbramsGroup](https://github.com/AbramsGroup/)
107
+
108
+ ## Contributing
109
+
110
+ 1. Fork it (<https://github.com/cameronabrams/ycleptic/fork>)
111
+ 2. Create your feature branch (`git checkout -b feature/fooBar`)
112
+ 3. Commit your changes (`git commit -am 'Add some fooBar'`)
113
+ 4. Push to the branch (`git push origin feature/fooBar`)
114
+ 5. Create a new Pull Request
@@ -0,0 +1,28 @@
1
+ ycleptic
2
+ ========
3
+
4
+ **Ycleptic** (ee-KLEP-tic) turns a single, structured YAML file into a self-documenting configuration system for your Python application. From one schema file you get three things at once: validation of a user's config (with defaults, allowed value ``choices``, and required parameters), an automatically generated RST/Sphinx documentation tree, and an interactive help explorer for your users. Because the schema is data rather than Python code, editing that one file keeps validation, documentation, and help in lockstep.
5
+
6
+ Ycleptic is intentionally lightweight on validation and focuses on the *spec-as-documentation* workflow — a good fit for scientific and command-line applications whose users are domain experts. If you need heavyweight validation and coercion, `pydantic <https://docs.pydantic.dev/>`_ or `jsonschema <https://python-jsonschema.readthedocs.io/>`_ are better suited; for composable, hierarchical config, see `Hydra <https://hydra.cc/>`_.
7
+
8
+ .. note::
9
+
10
+ Ycleptic is under active development.
11
+
12
+ .. note::
13
+
14
+ Ycleptic is used in the `pestifer <https://pypi.org/project/pestifer/>`_ package.
15
+
16
+ Contents
17
+ --------
18
+
19
+ .. toctree::
20
+ :maxdepth: 1
21
+
22
+ about
23
+ installation
24
+ usage
25
+ API <api/API>
26
+ roadmap
27
+ changelog
28
+
@@ -34,13 +34,14 @@ You then might like to create a "config" class for your package that inherits :c
34
34
 
35
35
  .. code-block:: python
36
36
 
37
+ import os
37
38
  from ycleptic.yclept import Yclept
38
39
  from mypackage import data # to get the path to your package data; there are other ways to do this
39
40
 
40
41
  class MyConfig(Yclept):
41
42
  def __init__(self, userconfigfile=''):
42
43
  basefile=os.path.join(os.path.dirname(data.__file__),"base.yaml") # your app's base config
43
- super().__init__(data.basefile,userconfigfile=userconfigfile)
44
+ super().__init__(basefile, userfile=userconfigfile)
44
45
 
45
46
 
46
47
  Here, ``data`` is just a directory where you store your package data (``rootdir/mypackage/data``, in the example), and you can put ``base.yaml`` in that directory as the base configuration description. Essentially, it is a description of **what** can be configured by a **user's** configuration file when **they** run your app. Now, inside your app source, if you want to read in the user's configuration file (like if its name was passed in as a command-line argument), you would instantiate a member of the ``MyConfig`` class:
@@ -3,19 +3,20 @@
3
3
  Interactive Help
4
4
  ===================
5
5
 
6
- The ``Yclept`` class has a method called ``console_help()`` that is meant to provides interactive help to a package user trying to develop their own config file that conform's to your package's base config.
6
+ The ``Yclept`` class has a method called ``console_help()`` that is meant to provide interactive help to a package user trying to develop their own config file that conforms to your package's base config.
7
7
 
8
8
  Suppose this is the content of ``config.py``:
9
9
 
10
10
  .. code-block:: python
11
11
 
12
+ import os
12
13
  from ycleptic.yclept import Yclept
13
14
  from mypackage import data
14
15
 
15
16
  class MyConfig(Yclept):
16
17
  def __init__(self, userconfigfile=''):
17
18
  basefile=os.path.join(os.path.dirname(data.__file__),"base.yaml")
18
- super().__init__(data.basefile,userconfigfile=userconfigfile)
19
+ super().__init__(basefile, userfile=userconfigfile)
19
20
 
20
21
 
21
22
  Here is an example of how the interactive help works:
@@ -36,7 +37,7 @@ This reflects the fact that the three top-level attributes available are called
36
37
 
37
38
  .. code-block:: console
38
39
 
39
- >>> Y.console_help([],interactive_prompt='help: ')
40
+ >>> c.console_help([],interactive_prompt='help: ')
40
41
  attribute_1 ->
41
42
  attribute_2 ->
42
43
  attribute_3 ->
@@ -45,7 +46,7 @@ This reflects the fact that the three top-level attributes available are called
45
46
  help: attribute_1
46
47
 
47
48
  attribute_1:
48
- This is a description of Directive 1
49
+ This is a description of Attribute 1
49
50
 
50
51
  base|attribute_1
51
52
  attribute_1_1
@@ -0,0 +1,72 @@
1
+ .. _usage_quickstart:
2
+
3
+ Quickstart
4
+ ==========
5
+
6
+ This is the smallest useful Ycleptic setup: define a base config, load a user
7
+ config against it, and generate documentation — all from one schema file.
8
+
9
+ 1. Write a base config
10
+ -----------------------------
11
+
12
+ The base config is a YAML file describing what your users may configure. Ship
13
+ it as package data, e.g. ``mypackage/data/base.yaml``:
14
+
15
+ .. code-block:: yaml
16
+
17
+ attributes:
18
+ - name: temperature
19
+ type: float
20
+ text: Simulation temperature in kelvin
21
+ default: 300.0
22
+ - name: integrator
23
+ type: str
24
+ text: Integration scheme to use
25
+ choices: [verlet, langevin]
26
+ default: verlet
27
+
28
+ 2. Load a user config
29
+ -----------------------------
30
+
31
+ Read the base config together with a user's config through
32
+ :class:`ycleptic.yclept.Yclept`. Omitted values are filled in from their
33
+ declared defaults; invalid values raise :class:`ycleptic.YclepticError`:
34
+
35
+ .. code-block:: python
36
+
37
+ from ycleptic import Yclept, YclepticError
38
+
39
+ try:
40
+ config = Yclept(basefile='mypackage/data/base.yaml', userfile='user.yaml')
41
+ except YclepticError as e:
42
+ raise SystemExit(f'Invalid configuration: {e}')
43
+
44
+ print(config['user']['temperature']) # 300.0 if the user omitted it
45
+
46
+ If ``user.yaml`` sets only the integrator:
47
+
48
+ .. code-block:: yaml
49
+
50
+ integrator: langevin
51
+
52
+ then ``config['user']`` becomes ``{'integrator': 'langevin', 'temperature':
53
+ 300.0}`` — the default temperature is supplied automatically.
54
+
55
+ 3. Generate documentation and explore
56
+ --------------------------------------------
57
+
58
+ From the *same* base config you can generate a Sphinx reference tree:
59
+
60
+ .. code-block:: console
61
+
62
+ $ yclept make-doc mypackage/data/base.yaml --root docs/source/config_ref
63
+
64
+ and let your users explore the configuration interactively:
65
+
66
+ .. code-block:: console
67
+
68
+ $ yclept config-help mypackage/data/base.yaml
69
+
70
+ The rest of this guide covers each piece in detail: :ref:`usage_the_base_config`,
71
+ :ref:`usage_the_user_config`, :ref:`usage_interactive_help`, and
72
+ :ref:`usage_yclept_makedoc`.
@@ -5,22 +5,22 @@ Resource File
5
5
 
6
6
  You may want users of your application to be able to set their own global default values for attributes, overwriting defaults you define in your application's base configuration. ``Yclept`` supports reading a secondary resource file (e.g., ``~/.your_app_name.rc``) in which users can specify attributes that replace or add to the list of attributes in your application's base configuration.
7
7
 
8
- For example, continuing with the base configuration defined above, suppose a user of your application has the file ``~/.your_app_name.rc`` with these contents:
8
+ For example, continuing with the base configuration from :ref:`usage_the_base_config`, suppose a user of your application has the file ``~/.your_app_name.rc`` with these contents:
9
9
 
10
10
  .. code-block:: yaml
11
11
 
12
12
  attributes:
13
13
  - name: attribute_2
14
14
  type: list
15
- text: Directive 2 is interpretable as an ordered list of attributes
15
+ text: Attribute 2 is interpretable as an ordered list of attributes
16
16
  attributes:
17
17
  - name: attribute_2a
18
18
  type: dict
19
- text: Directive 2a is one possible attribute in a user's list
19
+ text: Attribute 2a is one possible attribute in a user's list
20
20
  attributes:
21
21
  - name: d2a_val2
22
22
  type: int
23
- text: An int for Value 2 of Directive 2a
23
+ text: An int for Value 2 of Attribute 2a
24
24
  default: 7 # user has changed this in their resource file
25
25
 
26
26
  The presence of this file indicates the user would like the default value of attribute ``d2a_val2`` under attribute ``attribute_2a`` of base attribute ``attribute_2`` to be 7 instead of 6.
@@ -22,7 +22,7 @@ The heart of ``ycleptic`` is the base configuration file, which the app develope
22
22
  - name: attribute_1_2
23
23
  type: str
24
24
  text: This is a description of Attribute 1.2
25
- options: [ValA, ValB]
25
+ choices: [valA, valB]
26
26
  - name: attribute_2
27
27
  type: list
28
28
  text: Attribute 2 is interpretable as an ordered list of attributes
@@ -101,7 +101,7 @@ The heart of ``ycleptic`` is the base configuration file, which the app develope
101
101
  - name: flipaxis
102
102
  type: str
103
103
  text: Axis around which flip is performed
104
- options: ['x','y','z']
104
+ choices: ['x','y','z']
105
105
  - name: d322b
106
106
  type: dict
107
107
  text: Subattribute D 3.2.2b saves the result
@@ -114,7 +114,7 @@ The heart of ``ycleptic`` is the base configuration file, which the app develope
114
114
 
115
115
  The base config must open with the single identifier ``attributes``, under which is a list of one or more top-level attributes. Every attribute must have a declared type, and attributes can be nested.
116
116
 
117
- ``type`` can be one of ``int``, ``float``, ``str``, ``bool``, ``list``, or ``dict``. The data content in a attribute is of type ``type`` unless two conditions are met:
117
+ ``type`` can be one of ``int``, ``float``, ``str``, ``bool``, ``tuple``, ``list``, or ``dict``. The data content in an attribute is of type ``type`` unless two conditions are met:
118
118
 
119
119
  1. ``type`` is either ``list`` or ``dict``; and
120
120
  2. the keyword ``attributes`` is present.
@@ -123,9 +123,41 @@ In this case, there are subattributes. If the ``type`` was ``dict``, then the s
123
123
 
124
124
  ``text`` is just meant for helpful text describing the attribute, and it can be completely free-form as long as it is on one line or blocked multiline using ``|``.
125
125
 
126
- There are four other keys that a attribute may have:
126
+ There are several other keys an attribute may have:
127
127
 
128
- 1. ``default``: as you might expect, this are default values to assign to the attribute if the user "declares" the attribute but does not provide it any values.
129
- 2. ``required``: a boolean. If False, that means no defaults are assigned; if a user declares this attribute without providing values, an error occurs, but a user need not declare this attribute at all. If True, the attribute must be declared (and if it is nested, all the antecedant attributes must also be declared).
130
- 3. ``options``: a list of allowed values; if the user declares this attribute with a value not in this list, an error occurs.
131
- 4. ``docs``: this is a subattribute that can have ``title``, ``text``, and ``example`` keys. ``title`` and ``text`` are strings used in automatic documentation generation using ``yclept make-doc``. ``example`` is a YAML-format example of how to use the attribute in a config file. This is used in the documentation generation as well.
128
+ 1. ``default``: the default value (or values) assigned to the attribute when the user declares it but provides no value.
129
+ 2. ``required``: a boolean. If ``True``, the attribute must be declared (and if it is nested, all its antecedent attributes must be declared too). If ``False``, no defaults are assigned: the user need not declare the attribute at all, but declaring it without providing a value is an error.
130
+ 3. ``choices``: a list of allowed values; if the user gives a value that is not in the list, an error occurs. For ``str`` attributes the comparison honors ``case_sensitive`` (below).
131
+ 4. ``case_sensitive``: for ``str`` attributes only; a boolean that defaults to ``True``. When ``False``, the user's value is matched against ``choices`` case-insensitively and stored in casefolded (lower-case) form.
132
+ 5. ``docs``: a block that enriches the output of ``yclept make-doc``. It may contain ``title`` and ``text`` strings and a YAML-format ``example`` showing the attribute in use. See :ref:`base_config_docs_key` below.
133
+
134
+ .. _base_config_docs_key:
135
+
136
+ Enriching generated documentation with ``docs``
137
+ -------------------------------------------------
138
+
139
+ The ``text`` key gives every attribute a one-line description that appears in
140
+ interactive help and generated documentation. When you want richer, prose
141
+ documentation for an attribute — the kind you would write into a reference
142
+ manual — add a ``docs`` block. It is used only by ``yclept make-doc`` and is
143
+ ignored during configuration validation:
144
+
145
+ .. code-block:: yaml
146
+
147
+ - name: integrator
148
+ type: str
149
+ text: Integration scheme to use
150
+ choices: [verlet, langevin]
151
+ default: verlet
152
+ docs:
153
+ title: Integration scheme
154
+ text: |
155
+ Selects the time-integration algorithm. ``verlet`` is symplectic and
156
+ conserves energy well; ``langevin`` couples the system to a heat bath
157
+ and is appropriate for constant-temperature runs.
158
+ example:
159
+ integrator: langevin
160
+
161
+ ``title`` and ``text`` supply a heading and prose for the attribute's generated
162
+ page, and ``example`` is rendered as a YAML code block showing the attribute in
163
+ use. See :ref:`usage_yclept_makedoc` for how the tree is generated.
@@ -0,0 +1,41 @@
1
+ .. _usage_yclept_config_help:
2
+
3
+ ``yclept config-help``
4
+ ========================
5
+
6
+ The command-line tool ``yclept config-help <base.yaml>`` lets you use the interactive help feature detailed in :ref:`usage_interactive_help` to explore a base configuration file directly, without writing any code. For example, if you have a base configuration file called ``base.yaml``, you can run:
7
+
8
+ .. code-block:: console
9
+
10
+ $ yclept config-help base.yaml
11
+
12
+ which drops you into the interactive explorer:
13
+
14
+ .. code-block:: console
15
+
16
+ $ yclept config-help base.yaml
17
+ attribute_1 ->
18
+ attribute_2 ->
19
+ attribute_3 ->
20
+ .. up
21
+ ! quit
22
+ help: attribute_2
23
+
24
+ attribute_2:
25
+ Attribute 2 is interpretable as an ordered list of attributes
26
+
27
+ base|attribute_2
28
+ attribute_2a ->
29
+ attribute_2b ->
30
+ .. up
31
+ ! quit
32
+ help: !
33
+
34
+ At each prompt, type an attribute name to drill into it, ``..`` to go back up a
35
+ level, and ``!`` to quit. A trailing ``->`` marks an attribute that has
36
+ subattributes. You can also pass a space-separated attribute path on the
37
+ command line to jump straight to a node, for example:
38
+
39
+ .. code-block:: console
40
+
41
+ $ yclept config-help base.yaml attribute_2 attribute_2a
@@ -77,7 +77,7 @@ Each generated RST file ends with a footer whose appearance is controlled by
77
77
 
78
78
  ----
79
79
 
80
- This page was automatically generated by **ycleptic** v2.0.3 on 2025-09-04.
80
+ This page was automatically generated by **ycleptic** vX.Y.Z on YYYY-MM-DD.
81
81
 
82
82
  ``comment``
83
83
  An RST comment — present in the source but invisible in the rendered output.
@@ -3,9 +3,10 @@ Usage
3
3
 
4
4
  ``Ycleptic`` primarily exposes the :class:`ycleptic.yclept.Yclept` class to inherit in your own applications. It also has a command-line interface with two subcommands: ``yclept config-help`` and ``yclept make-doc``. The former provides interactive help for the configuration file, and the latter generates documentation from the base configuration file.
5
5
 
6
- .. toctree::
6
+ .. toctree::
7
7
  :maxdepth: 1
8
8
 
9
+ usage/quickstart
9
10
  usage/class
10
11
  usage/the_base_config
11
12
  usage/the_user_config
@@ -3,7 +3,7 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "ycleptic"
6
- version = "2.2.0"
6
+ version = "2.2.1"
7
7
  authors = [
8
8
  { name="Cameron F Abrams", email="cfa22@drexel.edu" },
9
9
  ]
@@ -328,6 +328,15 @@ Subattributes:
328
328
  Y = Yclept(BFILE, userfile='example1.yaml')
329
329
  self.assertEqual(Y['user']['attribute_5'], 'b')
330
330
 
331
+ def test_choices_case_sensitive_invalid(self):
332
+ """A value outside a case-sensitive attribute's choices is rejected."""
333
+ # attribute_1_2 has choices [valA, valB] and is case-sensitive by default,
334
+ # so 'ValA' (wrong case) must be rejected.
335
+ with open('example1.yaml', 'w') as f:
336
+ f.write('attribute_1:\n attribute_1_2: ValA\n')
337
+ with self.assertRaises(YclepticError):
338
+ Yclept(BFILE, userfile='example1.yaml')
339
+
331
340
  def test_choices_invalid(self):
332
341
  """attribute_5 rejects a value not in its choices list."""
333
342
  with open('example1.yaml', 'w') as f:
@@ -26,7 +26,7 @@ attributes:
26
26
  - name: attribute_1_2
27
27
  type: str
28
28
  text: This is a description of Attribute 1.2
29
- options: [ValA, ValB]
29
+ choices: [valA, valB]
30
30
  - name: attribute_2
31
31
  type: list
32
32
  text: Attribute 2 is interpretable as an ordered list of attributes
@@ -105,7 +105,7 @@ attributes:
105
105
  - name: flipaxis
106
106
  type: str
107
107
  text: Axis around which flip is performed
108
- options: ['x','y','z']
108
+ choices: ['x','y','z']
109
109
  - name: d322b
110
110
  type: dict
111
111
  text: Subattribute D 3.2.2b saves the result
ycleptic-2.2.0/PKG-INFO DELETED
@@ -1,88 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ycleptic
3
- Version: 2.2.0
4
- Summary: A YAML-format configuration generator
5
- Project-URL: Source, https://github.com/cameronabrams/ycleptic
6
- Project-URL: Documentation, https://ycleptic.readthedocs.io/en/latest/
7
- Project-URL: Bug Tracker, https://github.com/cameronabrams/ycleptic/issues
8
- Author-email: Cameron F Abrams <cfa22@drexel.edu>
9
- License: MIT License
10
-
11
- Copyright (c) 2022 Cameron Abrams
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining a copy
14
- of this software and associated documentation files (the "Software"), to deal
15
- in the Software without restriction, including without limitation the rights
16
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- copies of the Software, and to permit persons to whom the Software is
18
- furnished to do so, subject to the following conditions:
19
-
20
- The above copyright notice and this permission notice shall be included in all
21
- copies or substantial portions of the Software.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- SOFTWARE.
30
- License-File: LICENSE
31
- Classifier: License :: OSI Approved :: MIT License
32
- Classifier: Operating System :: OS Independent
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3.9
35
- Classifier: Programming Language :: Python :: 3.10
36
- Classifier: Programming Language :: Python :: 3.11
37
- Classifier: Programming Language :: Python :: 3.12
38
- Classifier: Programming Language :: Python :: 3.13
39
- Requires-Python: >=3.9
40
- Requires-Dist: pyyaml>=6
41
- Provides-Extra: lint
42
- Requires-Dist: mypy; extra == 'lint'
43
- Requires-Dist: ruff==0.15.22; extra == 'lint'
44
- Provides-Extra: test
45
- Requires-Dist: pytest; extra == 'test'
46
- Description-Content-Type: text/markdown
47
-
48
- # Ycleptic
49
- > YAML configuration generator
50
-
51
- YAML is a popular markup language for input files, with its easy syntax and clear
52
- mapping to lists and dicts. Ycleptic allows a developer to specify all keys, datatypes,
53
- default values, choice restrictions, and other features of YAML-format input
54
- files for use in their own apps. This makes the specification of input file syntax on top
55
- of YAML for any particular application a bit easier than just using pure YAML. In addition,
56
- ycleptic can also automatically build the RST/Sphinx doctree for your app's configuration
57
- file.
58
-
59
- ## Installation
60
-
61
- ```bash
62
- pip install ycleptic
63
- ```
64
-
65
- Once installed, the developer has access to the ``Yclept`` class.
66
-
67
- ## Release History
68
-
69
- See [CHANGELOG.md](CHANGELOG.md) for the full release history.
70
-
71
- ## Meta
72
-
73
- Cameron F. Abrams – cfa22@drexel.edu
74
-
75
- Distributed under the MIT license. See ``LICENSE`` for more information.
76
-
77
- [https://github.com/cameronabrams](https://github.com/cameronabrams/)
78
-
79
- [https://github.com/AbramsGroup](https://github.com/AbramsGroup/)
80
-
81
- ## Contributing
82
-
83
- 1. Fork it (<https://github.com/cameronabrams/ycleptic/fork>)
84
- 2. Create your feature branch (`git checkout -b feature/fooBar`)
85
- 3. Commit your changes (`git commit -am 'Add some fooBar'`)
86
- 4. Push to the branch (`git push origin feature/fooBar`)
87
- 5. Create a new Pull Request
88
-
ycleptic-2.2.0/README.md DELETED
@@ -1,41 +0,0 @@
1
- # Ycleptic
2
- > YAML configuration generator
3
-
4
- YAML is a popular markup language for input files, with its easy syntax and clear
5
- mapping to lists and dicts. Ycleptic allows a developer to specify all keys, datatypes,
6
- default values, choice restrictions, and other features of YAML-format input
7
- files for use in their own apps. This makes the specification of input file syntax on top
8
- of YAML for any particular application a bit easier than just using pure YAML. In addition,
9
- ycleptic can also automatically build the RST/Sphinx doctree for your app's configuration
10
- file.
11
-
12
- ## Installation
13
-
14
- ```bash
15
- pip install ycleptic
16
- ```
17
-
18
- Once installed, the developer has access to the ``Yclept`` class.
19
-
20
- ## Release History
21
-
22
- See [CHANGELOG.md](CHANGELOG.md) for the full release history.
23
-
24
- ## Meta
25
-
26
- Cameron F. Abrams – cfa22@drexel.edu
27
-
28
- Distributed under the MIT license. See ``LICENSE`` for more information.
29
-
30
- [https://github.com/cameronabrams](https://github.com/cameronabrams/)
31
-
32
- [https://github.com/AbramsGroup](https://github.com/AbramsGroup/)
33
-
34
- ## Contributing
35
-
36
- 1. Fork it (<https://github.com/cameronabrams/ycleptic/fork>)
37
- 2. Create your feature branch (`git checkout -b feature/fooBar`)
38
- 3. Commit your changes (`git commit -am 'Add some fooBar'`)
39
- 4. Push to the branch (`git push origin feature/fooBar`)
40
- 5. Create a new Pull Request
41
-
@@ -1,5 +0,0 @@
1
- # Changelog
2
-
3
- ```{include} ../../CHANGELOG.md
4
- :heading-offset: 1
5
- ```
@@ -1,26 +0,0 @@
1
- ycleptic
2
- ========
3
-
4
- **Ycleptic** (ee-KLEP-tic) is a Python tool for facilitating the definition of YAML-format input files. It allows for specification of default values and value choices. It allows for fully nested dictionary/list structures for detailed input file organization.
5
-
6
- .. note::
7
-
8
- Ycleptic is under active development.
9
-
10
- .. note::
11
-
12
- Ycleptic is used in the `pestifer <https://pypi.org/project/pestifer/>`_ package.
13
-
14
- Contents
15
- --------
16
-
17
- .. toctree::
18
- :maxdepth: 1
19
-
20
- about
21
- installation
22
- usage
23
- API <api/API>
24
- roadmap
25
- changelog
26
-
@@ -1,10 +0,0 @@
1
- .. _usage_yclept_config_help:
2
-
3
- ``yclept config-help``
4
- ========================
5
-
6
- The command-line tool `yclept config-help <base.yaml>` allow you to use the interactive help feature detailed in :ref:`usage_interactive_help` to explore a base configuration file. For example, if you have a base configuration file called `base.yaml`, you can run the following command:
7
-
8
- .. code-block:: console
9
-
10
- $ yclept config-help base.yaml
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes