-
Notifications
You must be signed in to change notification settings - Fork 602
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
Automatically add type annotations to all API functions #192
Conversation
f5d7188
to
42c43b8
Compare
7ed7436
to
28507f1
Compare
Hey Phil! Nice, I played around with it! 😄 I think it's really cool and I only have some minor stylistic remarks.
Now let's look at
PS:
|
about your first questions: i’m using the numpydoc extension to parse the strings into a structure that I can modify. the normal way to render this structure back to a string is doing This however doesn’t give us the original format, but instead the reStructuredText outpt of numpydoc. What do you mean with |
OK, got the formatting issues. Let's discuss at the office. Let's stick with |
28507f1
to
727c1a4
Compare
So I switched everything to Napoleon after all. Far simpler and prettier. I no longer parse the docstrings, and opted for a different approach: If a line contains only the name of a parameter, it will be amended with type info. Since no fancy parsing is involved, that could theoretically go wrong. On the other hand, the docstrings now stay in the same format and the probability for a line to consist of just the parameter name (and e.g. no |
7f3366f
to
a6c9c69
Compare
5d2bfab
to
8ddb075
Compare
8ddb075
to
7f5fe05
Compare
@falexwolf what do you say? |
Looks very good to me! Also the plain text docstrings look good. A few small things remain, for instance that the |
Yeah, that’s sphinx-doc/sphinx#4826 |
Fixes #58.
readthedocs
For RTD I switched from numpydoc to napoleon, with the same customizations as in anndata:
docstrings
The docstring part is implemented via
obj.getdoc()
, a method invoked by IPython if available, which means that it leaves__doc__
alone.As an example, it converts
scanpy.api.Neighbors.compute_neighbors
’ docs like this, leaving alone explicit type/default info and adding info from the signature.A huge advantage here is that by removing explicit info, we gain always-up-to-date defaults and types. Whenever we change something, we can’t forget to change everything else anymore.
↓↓↓