From 6c94047ec03cb89167e73506d4a169caa16437bc Mon Sep 17 00:00:00 2001 From: Vitor Hideyoshi Date: Sun, 22 Jun 2025 17:21:28 -0300 Subject: [PATCH] Adds Docs for Enum --- docs/source/usage.enum.rst | 37 +++++++++++++++++++++++++++++++++++++ docs/source/usage.rst | 3 ++- pyproject.toml | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 docs/source/usage.enum.rst diff --git a/docs/source/usage.enum.rst b/docs/source/usage.enum.rst new file mode 100644 index 0000000..ad3ea9b --- /dev/null +++ b/docs/source/usage.enum.rst @@ -0,0 +1,37 @@ +Enum Type +================== + +An enum type is a special data type that enables a variable to be a set of predefined constants. The enum type is used to define variables that can only take one out of a small set of possible values. + +It does not have any specific properties, but it has the generic properties: + +- default: Default value for the enum. +- description: Description of the enum field. + + +Examples +----------------- + + +.. code-block:: python + + from jambo import SchemaConverter + + schema = { + "title": "EnumExample", + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": ["active", "inactive", "pending"], + "description": "The status of the object.", + "default": "active", + }, + }, + "required": ["status"], + } + + Model = SchemaConverter.build(schema) + + obj = Model(status="active") + print(obj) # Output: EnumExample(status=status.ACTIVE) \ No newline at end of file diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 749dfc0..2b9855f 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -44,4 +44,5 @@ For more complex schemas and types see our documentation on usage.object usage.reference usage.allof - usage.anyof \ No newline at end of file + usage.anyof + usage.enum \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 830babc..201f92e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ repository = "https://github.com/HideyoshiNakazone/jambo.git" create-hooks = "bash .githooks/set-hooks.sh" tests = "python -m coverage run -m unittest discover -v" tests-report = "python -m coverage xml" +serve-docs = "sphinx-autobuild docs/source docs/build" # Build System [tool.hatch.version]