Initial Work on Documentation

This commit is contained in:
2025-06-19 23:51:33 -03:00
parent 040ffcba66
commit c504efe23b
13 changed files with 772 additions and 1 deletions

37
docs/source/conf.py Normal file
View File

@@ -0,0 +1,37 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "jambo"
copyright = "2025, Vitor Hideyoshi"
author = "Vitor Hideyoshi"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
]
templates_path = ["_templates"]
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
# -- Options for autodoc -----------------------------------------------------
add_module_names = False
python_use_unqualified_type_names = True

33
docs/source/index.rst Normal file
View File

@@ -0,0 +1,33 @@
.. jambo documentation master file, created by
sphinx-quickstart on Thu Jun 19 22:20:35 2025.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Jambo - JSON Schema to Pydantic Converter
=========================================
This is the documentation for Jambo, a tool that converts JSON Schema definitions into Pydantic models.
Welcome to Jambo's documentation!
Jambo is a Python package that automatically converts JSON Schema definitions into Pydantic models. It's designed to streamline schema validation and enforce type safety using Pydantic's powerful validation features.
Created to simplifying the process of dynamically generating Pydantic models for AI frameworks like LangChain, CrewAI, and others.
Installation
------------------
You can install Jambo using pip:
.. code-block:: bash
pip install jambo
.. toctree::
:maxdepth: 2
:caption: Contents:
usage
modules

View File

@@ -0,0 +1,85 @@
jambo.parser package
====================
Submodules
----------
jambo.parser.allof\_type\_parser module
---------------------------------------
.. automodule:: jambo.parser.allof_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.anyof\_type\_parser module
---------------------------------------
.. automodule:: jambo.parser.anyof_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.array\_type\_parser module
---------------------------------------
.. automodule:: jambo.parser.array_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.boolean\_type\_parser module
-----------------------------------------
.. automodule:: jambo.parser.boolean_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.float\_type\_parser module
---------------------------------------
.. automodule:: jambo.parser.float_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.int\_type\_parser module
-------------------------------------
.. automodule:: jambo.parser.int_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.object\_type\_parser module
----------------------------------------
.. automodule:: jambo.parser.object_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.ref\_type\_parser module
-------------------------------------
.. automodule:: jambo.parser.ref_type_parser
:members:
:undoc-members:
:show-inheritance:
jambo.parser.string\_type\_parser module
----------------------------------------
.. automodule:: jambo.parser.string_type_parser
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: jambo.parser
:members:
:undoc-members:
:show-inheritance:

30
docs/source/jambo.rst Normal file
View File

@@ -0,0 +1,30 @@
jambo package
=============
Subpackages
-----------
.. toctree::
:maxdepth: 4
jambo.parser
jambo.types
Submodules
----------
jambo.schema\_converter module
------------------------------
.. automodule:: jambo.schema_converter
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: jambo
:members:
:undoc-members:
:show-inheritance:

View File

@@ -0,0 +1,29 @@
jambo.types package
===================
Submodules
----------
jambo.types.json\_schema\_type module
-------------------------------------
.. automodule:: jambo.types.json_schema_type
:members:
:undoc-members:
:show-inheritance:
jambo.types.type\_parser\_options module
----------------------------------------
.. automodule:: jambo.types.type_parser_options
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: jambo.types
:members:
:undoc-members:
:show-inheritance:

7
docs/source/modules.rst Normal file
View File

@@ -0,0 +1,7 @@
jambo
=====
.. toctree::
:maxdepth: 4
jambo

40
docs/source/usage.rst Normal file
View File

@@ -0,0 +1,40 @@
Using Jambo
===================
Jambo is designed to be easy to use, it doesn't require any complex setup or configuration.
Below a example of how to use Jambo to convert a JSON Schema into a Pydantic model.
.. code-block:: python
from jambo import SchemaConverter
schema = {
"title": "Person",
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
},
"required": ["name"],
}
Person = SchemaConverter.build(schema)
obj = Person(name="Alice", age=30)
print(obj)
# Output: Person(name='Alice', age=30)
The :py:meth:`SchemaConverter.build <jambo.SchemaConverter.build>` static method takes a JSON Schema dictionary and returns a Pydantic model class. You can then instantiate this class with the required fields, and it will automatically validate the data according to the schema.
If passed a description inside the schema it will also add it to the Pydantic model using the `description` field. This is useful for AI Frameworks as: LangChain, CrewAI and others, as they use this description for passing context to LLMs.
For more complex schemas and types see our documentation on
.. toctree::
:maxdepth: 2
:caption: Contents:
usage.string

View File

@@ -0,0 +1,46 @@
String Type
=================
The String type has the following supported properties:
- maxLength: Maximum length of the string.
- minLength: Minimum length of the string.
- pattern: Regular expression pattern that the string must match.
- format: A string format that can be used to validate the string (e.g., "email", "uri").
And the additional generic properties:
- default: Default value for the string.
- description: Description of the string field.
Examples
-----------------
1. Basic String with maxLength and minLength:
.. code-block:: python
from jambo import SchemaConverter
schema = {
"title": "StringExample",
"type": "object",
"properties": {
"email": {
"type": "string",
"minLength": 5,
"maxLength": 50,
},
},
"required": ["email"],
}
Model = SchemaConverter.build(schema)
obj = Model(email="this_is_a_valid_string")
print(obj)
# Output: StringExample(email='this_is_a_valid_string')
2. String with pattern and format: