Skip to main content

Griffe extension adding support for data-class like things (pydantic, attrs, etc...)

Project description

griffe-fieldz

License PyPI Python Version CI codecov

Griffe extension adding support for dataclass-like things (pydantic, attrs, etc...). This extension will inject the fields of the data-class into the documentation, preventing you from duplicating field metadata in your docstrings.

It supports anything that fieldz supports, which is currently:

Installation

With pip:

pip install griffe-fieldz

To use the extension in a MkDocs project, use this configuration:

# mkdocs.yml
plugins:
- mkdocstrings:
    handlers:
      python:
        options:
          extensions:
          - griffe_fieldz

You may use any of the following options, provided as a dictionary under the griffe_fieldz key.

Option Description Default
include_inherited Include inherited fields in class parameters. False
include_private Include private fields in the documentation. False
add_fields_to Where in the documentation to add the detected fields. Must be one of:

- docstring-parameters: add fields to the Parameters section of the docstring
- docstring-attributes: add fields to the Attributes section of the docstring
- class-attributes: add fields as class attributes
docstring-parameters
remove_fields_from_members If True, fields are removed as class members. This is not encouraged (since fields are indeed class attributes), but will prevent duplication of the name in the docstring as well as the class. This value is ignored if add_fields_to is class-attributes. False
strip_annotated If True, strip the Annotated wrapper from type hints, showing only the inner type. For example, Annotated[int, Gt(0)] will be displayed simply as int. False

For example:

        options:
          extensions:
          - griffe_fieldz:
              include_inherited: false
              include_private: false
              add_fields_to: docstring-attributes
              remove_fields_from_members: false
              strip_annotated: false

Example

As an example playground for using this plugin to document pydantic, attrs, and other dataclass-like objects, see: https://github.com/tlambert03/fieldz-docs-example

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

griffe_fieldz-0.4.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

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

griffe_fieldz-0.4.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file griffe_fieldz-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for griffe_fieldz-0.4.0.tar.gz
Algorithm Hash digest
SHA256 91d25a8199df4be8a5175556d9d8e6f43ef45cf5e93e52b8babfe4cf1037d5ff
MD5 a858397bb24b69e75838712f8129fc2e
BLAKE2b-256 3baaeb58d641261f5222651db86976439dccde5dadeda42fb8c3445b1c85b7cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for griffe_fieldz-0.4.0.tar.gz:

Publisher: ci.yml on pyapp-kit/griffe-fieldz

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

File details

Details for the file griffe_fieldz-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: griffe_fieldz-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for griffe_fieldz-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92b7ed3fd86c1da35b2851a272913ef27439c9cc3c232c15cab7eda34d2a51ad
MD5 63bd658370c48823cd2bc64c1856788c
BLAKE2b-256 af68b7aa4caf9567863908b3b928e3ec141787044e3392d429e5b453f70bbfa4

See more details on using hashes here.

Provenance

The following attestation bundles were made for griffe_fieldz-0.4.0-py3-none-any.whl:

Publisher: ci.yml on pyapp-kit/griffe-fieldz

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