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-1.0.1.tar.gz (117.3 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-1.0.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pydantic_kitbash-1.0.1.tar.gz
Algorithm Hash digest
SHA256 44ad7f851cbba3c9fdbc1e705d2b36bca455befbdc361d86ad53af421e2b2eb1
MD5 3328ef7d7aa16ddc6f426f751f85169d
BLAKE2b-256 e65d2d1916a0aafc290768ee06b233f5c8c1debb65562e853fc0b6220bf6d5f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_kitbash-1.0.1.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-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_kitbash-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a8055cea6f2e18e5e45336436107b527ae6ab7d32b686eeec95a7aaec18adf2
MD5 081c44e3004624b5e66647a1d92ccd84
BLAKE2b-256 0254c24ce86ecf25c67a4fe7f0f47fe742daf4ccafb3ba4c770baa0d88623778

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_kitbash-1.0.1-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