I am using mkdocs
to produce automatic documentation for my project. However, for classes inheriting from pydantic.BaseModel
, I find it tedious to include a docstring for each field with a description and data type, because this information is already included in the pydantic.Field
arguments. Here's an example:
class MyModel(BaseModel):
"""This text is good.
:param field_1: redundant description and default value.
:type field_1: redundant type
"""
field_1: int = Field(default=3, description="description")
Is there a way to add support for pydantic
models? I looked through the internet, but it's a rabbit hole, and I'm pretty novice to this whole process. Any help is appreciated!
You might be interested in the griffe-fieldz extension for Griffe, the tool that extracts information from Python sources (statically or dynamically).
There's also the griffe-pydantic extension, which I created myself (I'm the maintainer of mkdocstrings), but it's only available to sponsors for now.