-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
6418 autodoc typehints description #7018
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
6418 autodoc typehints description #7018
Conversation
2fa54e9
to
4d46668
Compare
This is awesome, thank you so much for revisiting this! I have put some time on my calendar to take a closer look this weekend but wanted to ping you since some time had passed since you requested review. The only thing that sticks out to me is how other domains could possibly take advantage of this event. Are there things missing from the call signature that other domains would want? Should the typehints extension fail if the domain is anything other than Python (given the intent to eventually merge into autodoc)? Or warn? |
The type of domain and objtype are passed to event handler for |
4d46668
to
67817ac
Compare
67817ac
to
5397664
Compare
I finished all my work. It's time to merge! |
@tk0miya (-sensei!!!!!!!!) this is absolutely fantastic. You are a magician. I was trying to modify napoleon but apparently it is not necessary for the bulk of this work. Napoleon Overrides (docs needed)I think this should very much stay as is and be considered a feature, I can document this pending return stuff below. If you manually annotate, this will override the injected def foo(arg: str) -> str:
"""
Some doc.
Parameters
----------
arg : int
This will get documented as ``int`` not ``str``. Remove `` : int`` and it will be ``str``.
Returns
-------
str
I am looking into this one. It is a slight problem.
""" I think it would be good to document the new options in napoleon. I can do that / it does not need to block this PR, just putting down notes. Napoleon Return ClausesFor return value, it would be nice if we could avoid manually specifying the return types. Return
------
+ A path is returned
- pathlib.Path
- A path is returned. This is the current design of napoleon (specify return type directly). I am trying to special-case this. It seems like it would be nice to have this as description for this PR, as well as generally (in general case, no I'm playing with this code here but wanted to send you a response while I continue looking into things. Misc Build Caching ProblemWhen testing, I noticed that if you have Thank you again so much for doing this, this is fantastic! |
Update re: return clauses. Google docstring is safe. I think. You can omit the return type. Though I can't actully figure out how to do "multiple-return-type" in the google format. Numpy seems to have a somewhat irreconcilable problem. Apparently it is setup to enable multiple return types, so format is
So this creates a conundrum. If we want to enable just writing the docstring directly under sphinx/sphinx/ext/napoleon/docstring.py Line 683 in 1ef607b
That field list is what matters. I played around with things but I think we have to add a new config var that says "only one return type for numpy" and then just
|
Thank you for investigation. That's very helpful to me. But as I commented at tk0miya#4, it would be better to merge this into 2.0. And let's discuss about napoleon in another PR. |
Feature or Bugfix
Purpose
sphinx.ext.autodoc.typehints
.autodoc_typehints = "description"
set.Tasks