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

Compatibility with Sphinx.ext.napoleon #15

Closed
tommyip opened this issue Mar 29, 2017 · 15 comments
Closed

Compatibility with Sphinx.ext.napoleon #15

tommyip opened this issue Mar 29, 2017 · 15 comments

Comments

@tommyip
Copy link

tommyip commented Mar 29, 2017

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?

@agronholm
Copy link
Collaborator

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?

@wheerd
Copy link
Contributor

wheerd commented Mar 30, 2017

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

@agronholm
Copy link
Collaborator

Ok, sounds like I can close this issue then.

@evanunderscore
Copy link

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.

@agronholm
Copy link
Collaborator

That much I can do :)

@agronholm agronholm reopened this Apr 30, 2017
@evanunderscore
Copy link

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

@agronholm
Copy link
Collaborator

Yes, I understood.

@kylebarron
Copy link

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.

@cmichelenstrofer
Copy link

cmichelenstrofer commented Jul 20, 2022

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 :(

@jgarte
Copy link

jgarte commented Dec 22, 2022

@cmichelenstrofer Is this still a problem for you?

@cmichelenstrofer
Copy link

cmichelenstrofer commented Dec 22, 2022

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

@jstet
Copy link

jstet commented May 10, 2023

@cmichelenstrofer would you be so kind to post your workaround again?

@cmichelenstrofer
Copy link

cmichelenstrofer commented May 10, 2023

@cmichelenstrofer would you be so kind to post your workaround again?

@jstet
The issue was that the organization name in GitHub changed. I just updated the links above.

@MLopez-Ibanez
Copy link

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.

The README.md should mention this!

@gaborbernat
Copy link
Member

PR welcome.

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

10 participants