Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] Improve the documentation of the Pydantic models #1293

Open
1 of 5 tasks
peterschmidt85 opened this issue May 31, 2024 · 3 comments · Fixed by #1295
Open
1 of 5 tasks

[Internal] Improve the documentation of the Pydantic models #1293

peterschmidt85 opened this issue May 31, 2024 · 3 comments · Fixed by #1295
Assignees
Labels
docs Improvements or additions to documentation internals

Comments

@peterschmidt85
Copy link
Contributor

peterschmidt85 commented May 31, 2024

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.Annotated via scripts/docs/gen_schema_reference.py. Remove the docstrings that are duplicated by typing_extensions.Annotated.
    • Switch to scripts/docs/gen_schema_reference.py for dstack.api.Task and dstack.api.Service, dstack.api.Resources, dstack.api.GPU, and dstack.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|python for scripts/docs/gen_schema_reference.py (to use the table format, include type, examples link, etc)
  • Maximum: Switch from mkdocstrings to scripts/docs/gen_schema_reference.py entirely for Python API reference generation by adding generation of the documentation for methods to scripts/docs/gen_schema_reference.py.
@peterschmidt85 peterschmidt85 added docs Improvements or additions to documentation internals labels May 31, 2024
@peterschmidt85 peterschmidt85 self-assigned this May 31, 2024
peterschmidt85 added a commit that referenced this issue May 31, 2024
[Docs]: Document possible values of target metrics in auto scaling configuration #1279
@pawamoy
Copy link

pawamoy commented May 31, 2024

@peterschmidt85
Copy link
Contributor Author

@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?

@pawamoy
Copy link

pawamoy commented May 31, 2024

griffe-pydantic is only available to sponsors (see the docs), the package on pypi does nothing. I didn't try griffe-fieldz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation internals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants