Initial Work on Documentation
This commit is contained in:
29
docs/Makefile
Normal file
29
docs/Makefile
Normal file
@@ -0,0 +1,29 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SPHINXAPIDOC ?= sphinx-apidoc
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
SCANEDDIR = ../jambo
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
rescan:
|
||||
$(SPHINXAPIDOC) -f -o $(SOURCEDIR) $(SCANEDDIR) $(EXCLUDEDIR)
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
@@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.https://www.sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
||||
37
docs/source/conf.py
Normal file
37
docs/source/conf.py
Normal 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
33
docs/source/index.rst
Normal 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
|
||||
85
docs/source/jambo.parser.rst
Normal file
85
docs/source/jambo.parser.rst
Normal 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
30
docs/source/jambo.rst
Normal 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:
|
||||
29
docs/source/jambo.types.rst
Normal file
29
docs/source/jambo.types.rst
Normal 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
7
docs/source/modules.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
jambo
|
||||
=====
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
jambo
|
||||
40
docs/source/usage.rst
Normal file
40
docs/source/usage.rst
Normal 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
|
||||
46
docs/source/usage.string.rst
Normal file
46
docs/source/usage.string.rst
Normal 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:
|
||||
Reference in New Issue
Block a user