Open blink1073 opened 1 year ago
I second this! I was just searching for how to do this after switching to autodoc2.
I think an option to this makes sense 👍 Happy to recieve PRs
I came up with a way to do this by hacking around in the docutils tree to copy the type hint nodes from the signature into the parameter list. I'm working on an extension to do the same thing by patching Sphinx where it generates the field list for parameters, which is a bit less hacky.
Here's an example of what it looks like: https://mm21.github.io/trilium-alchemy/build/autodoc2/trilium_alchemy/trilium_alchemy.core.html#trilium_alchemy.core.Session
It also changes the list from bullets to a definition list, which I find more clean and readable. The downside is it will only work reliably when there's exactly one signature.
(I may have also added the references to the default values, but can't remember now if that's a vanilla autodoc2 thing.)
The
autodoc_typehints
setting lets you put the type hints in the parameter list instead of the signature. This is also how https://github.com/tox-dev/sphinx-autodoc-typehints handles type hints, which can be a lot easier to read for complex function signatures.