Kitbash is a Sphinx extension that generates reference documentation for Pydantic models.
Kitbash parses a model to describe its fields in a Sphinx document. It can target an entire model or specific fields. When covering a specific field, you can add reStructuredText to the field's docstring to supplement the standard output.
The kitbash-field directive documents an individual field:
.. kitbash-field:: my_model my_fieldThe kitbash-model directive directive documents an entire model:
.. kitbash-model:: my_modelBypasses the field's examples on the page. Use this when the examples are incomplete or unhelpful.
.. kitbash-field:: my_model my_field
:skip-examples:Replaces the field's description with the directive content instead of appending to it. Use this to modify field descriptions inherited from libraries.
.. kitbash-field:: upstream_model my_field
:override-description:
This text replaces the field's description.
Overrides the field's type on the page. Use this when the type is overly verbose, malformed, or unhelpful.
.. kitbash-field:: my_model my_field
:override-type: AnyAdds a prefix to the field name on the page. The prefix is separated by a period (.).
This example makes the field render as permissions.my_field:
.. kitbash-field:: my_model my_field
:prepend-name: permissionsAdds a suffix to the field name on the page. The suffix is separated by a period (.).
This example makes the field render as my_field.v1:
.. kitbash-field:: my_model my_field
:append-name: v1Overrides the reStructuredText label for a field. By default, Kitbash adds a label for
each entry, formatted as <page-filename>-<field-name>. This example renames the label
to dev-my-field:
.. kitbash-field:: my_model my_field
:label: dev-my-fieldBy default, directive content is appended to the description. Use this to provide additional context or information on fields sourced from libraries.
.. kitbash-field:: my_model my_field
This is appended to the field's description.
If the override-description option is included, the directive content will replace the
entire field description.
Kitbash is published on PyPI and can be installed with:
pip install pydantic-kitbashAfter adding Kitbash to your Python project, update Sphinx's conf.py file to include
Kitbash as one of its extensions:
extensions = [
"pydantic_kitbash",
]You can report any issues or bugs on the project's GitHub repository.
Kitbash is covered by the Ubuntu Code of Conduct.
Kitbash is released under the LGPL-3.0 license.
@ 2025 Canonical Ltd.