2 years ago
#69723
Valentin Dumitru
document pydantic.BaseSettings/BaseModel based classes with sphinx autoapi
I wrote a class like this:
class ComponentData(pydantic.BaseSetting):
"""dummy doc-string"""
att1: str = pydantic.Field(default="def1")
"""dummy attribute doc-string"""
att2: str = pydantic.Field(default="def2")
"""dummy attribute doc-string"""
the autoapi generated documentation with sphinx-autoapi
(https://sphinx-autoapi.readthedocs.io/en/latest/index.html) looks like:
class ComponentData(
__pydantic_self__,
_env_file: Union[pathlib.Path, str, None] = env_file_sentinel,
_env_file_encoding: Optional[str] = None,
_secrets_dir: Union[pathlib.Path, str, None] = None,
**values: Any
)
I would love to have it like this:
class ComponentData(
__pydantic_self__,
_env_file: Union[pathlib.Path, str, None] = env_file_sentinel,
_env_file_encoding: Optional[str] = None,
_secrets_dir: Union[pathlib.Path, str, None] = None,
att1: str = "def1",
att2: str = "def2"
)
.. basically, to have **values
replaced by the actual list of supported attributes with their default values.
I know this is possible with autodoc
, but how do I make it work with autoapi
?
python
python-sphinx
pydantic
0 Answers
Your Answer