lmstudio-ai / venvstacks

Virtual environment stacks for Python
http://venvstacks.lmstudio.ai/
MIT License
173 stars 5 forks source link

Improve the structure of the API docs #33

Open ncoghlan opened 1 month ago

ncoghlan commented 1 month ago

The current API docs are essentially just a sphinx-autogen dump with a bit of manual cleanup to address misfires like including the entire str, Sequence, Mapping, and dict APIs on types that implement those interfaces.

As parts of the API stabilise, their documentation should move away from relying on autosummary and towards regular toctree directives.

Public functions that are missing docstrings should have them added.

The TypedDict metadata is also incorrect (the mapping fields are listed as attributes, which is technically true of the class definition, but not true of the objects that a typechecker will classify as providing that interface).

Finally, while the one-page-per-entity layout is apparently more search-engine friendly, it makes it hard to see how the various interfaces relate to each other, so it's likely worth pushing at least the module level functions and the basic type definitions up to the relevant module pages.

ncoghlan commented 2 weeks ago

As part of this, the docstrings should be reformatted to use a fully supported docstring syntax.

The default option is https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html, but that's pretty boilerplate heavy.

So instead, I'm leaning towards enabling the https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html and using Google-style docstrings: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-google (that's an aesthetic preference, as I genuinely don't like the way the NumPy syntax looks when reading code)

This will mean turning on the ruff lint settings to expect docstrings to be in Google format (see https://docs.astral.sh/ruff/settings/#lint_select and https://docs.astral.sh/ruff/settings/#lintpydocstyle )