You love pydantic
Perfect, let's go. But wait, sphinx' autodoc does not integrate too well with pydantic models
Don't worry - just pip install autodoc_pydantic
Features
-
๐ฌ provides default values, alias and constraints for model fields -
๐ adds references between validators and corresponding fields -
๐ includes collapsable model json schema -
๐ natively integrates with autodoc extension -
๐ defines explicit pydantic prefixes for models, settings, fields, validators and model config -
๐ shows summary section for model configuration and validators -
๐ hides overloaded and redundant model class signature -
๐ sorts fields, validators and model config within models by type -
๐ Supportspydantic >= 1.5.0
andsphinx >= 3.4.0
Comparison between autodoc sphinx and autodoc pydantic
To see those features in action, jump over to the example documentation to compare the appearance of standard sphinx autodoc with autodoc_pydantic.
Documentation
For more details, please visit the official documentation:
Acknowledgements
Thanks to great open source projects sphinx, pydantic and poetry (and so many more)