Skip to main content

Sphinx extension for documenting Pydantic models.

Project description

pydantic-kitbash

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.

Basic usage

The kitbash-field directive documents an individual field:

.. kitbash-field:: my_model my_field

The kitbash-model directive directive documents an entire model:

.. kitbash-model:: my_model

Options

skip-examples

Bypasses the field's examples on the page. Use this when the examples are incomplete or unhelpful.

.. kitbash-field:: my_model my_field
    :skip-examples:

override-description

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.

override-type

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: Any

prepend-name

Adds 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: permissions

append-name

Adds 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: v1

label

Overrides 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-field

Directive content

By 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.

Project setup

Kitbash is published on PyPI and can be installed with:

pip install pydantic-kitbash

After adding Kitbash to your Python project, update Sphinx's conf.py file to include Kitbash as one of its extensions:

extensions = [
    "pydantic_kitbash",
]

Community and support

You can report any issues or bugs on the project's GitHub repository.

Kitbash is covered by the Ubuntu Code of Conduct.

License and copyright

Kitbash is released under the LGPL-3.0 license.

@ 2025 Canonical Ltd.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_kitbash-0.1.0.tar.gz (155.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_kitbash-0.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_kitbash-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic_kitbash-0.1.0.tar.gz
  • Upload date:
  • Size: 155.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydantic_kitbash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 521dc4fca918ee166a3698a395030302a9149250da36228955973bea4181bee3
MD5 a22f8ef204de3dc9c38ea518c95d7d33
BLAKE2b-256 aed84de8c19adb92940638e4bc050cad0e9e8e93baf0464d89e68d173c2e4032

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_kitbash-0.1.0.tar.gz:

Publisher: release-publish.yaml on canonical/pydantic-kitbash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_kitbash-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_kitbash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27ecec790bccf38f6d91070ea416a2100626766fce6098d3ca3ffc4c67b78b1f
MD5 7e1cc3013aa9d86fcf0f765e4b128ed2
BLAKE2b-256 df1b492282cfbc7b80ad176284eb9be03e1aebd4c0f32134018e9edfde5cd9e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_kitbash-0.1.0-py3-none-any.whl:

Publisher: release-publish.yaml on canonical/pydantic-kitbash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page