tox-dev / sphinx-autodoc-typehints

Type hints support for the Sphinx autodoc extension

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility with Sphinx.ext.napoleon

tommyip opened this issue · comments

Napoleon is a Sphinx extension which allow the use of Google / Numpy style docstrings. Currently, it doesn't work well with this extension, it can only strip the type hint from function definition and add the return type.
Is it possible to make it inject the type hint to the argument list in the docs?

Personally I have no interest in support Google/Numpy style docstrings. I don't even know what it would take to do what you want. Would you like to share an example?

There is already a fork for that: sphinx-autodoc-napoleon-typehints

Ok, sounds like I can close this issue then.

commented

I've only just looked at this, but it appears that this works perfectly fine with Napoleon, provided that you put sphinx_autodoc_typehints after sphinx.ext.napoleon. If I put this first, I get the problem @tommyip describes. A note in the readme saying Napoleon is supported with this caveat should be sufficient to fix the problem.

That much I can do :)

commented

Thanks! Also since I've noticed I didn't actually specify - the ordering I'm talking about is the extensions list in conf.py.

Yes, I understood.

For anyone else trying to get this to work with Napoleon, for me, this only works with the napoleon setting:

napoleon_use_param = True

Otherwise the type hints are removed from the function signature but not added to the docstring.

For anyone else trying to get this to work with Napoleon, for me, this only works with the napoleon setting:

napoleon_use_param = True

Otherwise the type hints are removed from the function signature but not added to the docstring.

I am using this and the type hints are still not added :(

@cmichelenstrofer Is this still a problem for you?

@jgarte Ahh, I forget how I solved it but I was able to work around this issue and get the desired behavior. So it's all good. I'm about to go on vacation or I would have looked into it more :) But here is the relevant conf.py file and the output documentation in case you are curious.