From ff68ea7e3153e47833d7d4cb6d0ec8911a83206d Mon Sep 17 00:00:00 2001 From: Ievgen Popovych Date: Thu, 9 Nov 2023 20:48:57 +0200 Subject: [PATCH] docs: Mention Choice's Enum support in published docs, publish __init__ docs The fact that Choice/as_choice() support working with Enums was not visible in built/published documentation - fix this. Signed-off-by: Ievgen Popovych --- confuse/core.py | 3 +++ confuse/templates.py | 3 +++ docs/api.rst | 1 + 3 files changed, 7 insertions(+) diff --git a/confuse/core.py b/confuse/core.py index 7d00d9c..85f0e63 100644 --- a/confuse/core.py +++ b/confuse/core.py @@ -307,6 +307,9 @@ def as_path(self): def as_choice(self, choices): """Get the value from a list of choices. Equivalent to `get(Choice(choices))`. + + Sequences, dictionaries and :class:`Enum` types are supported, + see :class:`confuse.templates.Choice` for more details. """ return self.get(templates.Choice(choices)) diff --git a/confuse/templates.py b/confuse/templates.py index a46b57a..19e79d1 100644 --- a/confuse/templates.py +++ b/confuse/templates.py @@ -243,6 +243,9 @@ def convert(self, value, view): class Choice(Template): """A template that permits values from a sequence of choices. + + Sequences, dictionaries and :class:`Enum` types are supported, + see :meth:`__init__` for usage. """ def __init__(self, choices, default=REQUIRED): """Create a template that validates any of the values from the diff --git a/docs/api.rst b/docs/api.rst index 0a094f8..f2902f1 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -34,6 +34,7 @@ Templates .. automodule:: confuse.templates :members: :private-members: + :special-members: __init__ :show-inheritance: Utility