[Internal] Improve the documentation of the Pydantic models
Problem
Currently, the reference pages generate the documentation for Pydantic models from two different sources: from the Pydantic fields (via typing_extensions.Annotated and scripts/docs/gen_schema_reference.py - for YAML schema) and from docstrings (via mkdocstrings - for the Python API). This leads to having the documentation of the Pydantic fields duplicated.
Solution
- [ ] Minimum: For Pydantic models that don't have methods, in Python API reference, switch to
typing_extensions.Annotatedviascripts/docs/gen_schema_reference.py. Remove the docstrings that are duplicated bytyping_extensions.Annotated.- [x] Switch to
scripts/docs/gen_schema_reference.pyfordstack.api.Taskanddstack.api.Service,dstack.api.Resources,dstack.api.GPU, anddstack.api.Disk - [ ] Include the dostrings for the Pydantic class into the documentation generated by
scripts/docs/gen_schema_reference.py - [ ] Implement a setting
format: yaml|pythonforscripts/docs/gen_schema_reference.py(to use the table format, include type, examples link, etc)
- [x] Switch to
- [ ] Maximum: Switch from
mkdocstringstoscripts/docs/gen_schema_reference.pyentirely for Python API reference generation by adding generation of the documentation for methods toscripts/docs/gen_schema_reference.py.
You might be interested in https://mkdocstrings.github.io/griffe-pydantic/ and https://github.com/pyapp-kit/griffe-fieldz :slightly_smiling_face:
@pawamoy Thanks a lot for sharing this. Actually, I tried I suppose both but couldn't find a way to make them work. It simply didn't render any annotated fields.
Do you have any experience with any of these two?
griffe-pydantic is only available to sponsors (see the docs), the package on pypi does nothing. I didn't try griffe-fieldz.
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale. Please reopen the issue if it is still relevant.