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.5.0.tar.gz (14.2 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.5.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: griffe_fieldz-0.5.0.tar.gz
  • Upload date:
  • Size: 14.2 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.5.0.tar.gz
Algorithm Hash digest
SHA256 dcf237a0def9f5c15e15aa5cf07b3d0a4edf4f7d6a2d713a45afe29c8af9bc8e
MD5 51263ccade8662bb155b6fb8fc61e8f5
BLAKE2b-256 1c7fb57a27807536590f0cabdd2e6c0faac78c7d6a740e096684c51c503b7003

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: griffe_fieldz-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d363e56a7468019a7184ea3995277a1f20507bb9a345408c1f7014ae06878ebf
MD5 8bf3bf368cc49ea68a9f842be1606a75
BLAKE2b-256 ce669daa3118d9bf4443778d6ee31b024c79766eeb116b275eca71597adae43a

See more details on using hashes here.

Provenance

The following attestation bundles were made for griffe_fieldz-0.5.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