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

Support autodoc_typehints setting #21

Open
blink1073 opened this issue Mar 13, 2023 · 3 comments
Open

Support autodoc_typehints setting #21

blink1073 opened this issue Mar 13, 2023 · 3 comments

Comments

@blink1073
Copy link

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.

@caseyjconger
Copy link

I second this! I was just searching for how to do this after switching to autodoc2.

@chrisjsewell
Copy link
Member

I think an option to this makes sense 👍 Happy to recieve PRs

@mm21
Copy link

mm21 commented Feb 12, 2024

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants