-
Notifications
You must be signed in to change notification settings - Fork 269
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
Convert Docstrings to Numpy Style #347
Comments
I'm happy with the suggested format. |
+1 |
1 similar comment
👍 |
I reckon we can close this one now. Anyone object? |
Fine by me. |
Have we converted them all? |
Fair point. I don't believe we have for everything. Main components: I On Mon, 25 Jul 2016, 16:56 Marc Harper, notifications@github.com wrote:
|
I'll pick this up next. |
What's your opinion on my last comment on #457? I suspect using annotations might be a better option. |
So the idea would be that the docstrings would no longer need:
or
is that the idea? I guess when viewing the docstrings (via a notebook for example) the type annotation would be visible so that that would not be 'lost' and we would still have a docstring that describes what is going on right? Could you explain what we would use that autodoc plugin for? We're not currently autodoc'ing anything apart from the strategies. |
there's quite a good example here: https://pypi.python.org/pypi/sphinx-autodoc-napoleon-typehints |
The docstrings remain but argument types and return value types move into the annotations. |
Just so that I understand, the advantage of that is two fold:
That's a different plugin to the one you pasted on #457 right? I'm still not sure I understand what the purpose of it is (having looked through both of the plugins). Is that actually rewriting the docstring (:confused:) in the source code or is it for the purpose of autodoc'ing when it comes to our documentation? (Just attempting to understand.) |
Yes, there are a couple of different sphinx plugins doing the same job. That last one just had a nicer description. |
No, we still keep the Parameters and Returns, but they no longer specify the types of each entry. That's done instead within the annotations |
An example from match.py: The current docstring for the init method starts with
which defines the type of each parameter. This would become:
|
Thanks for clarifying, I understand now. I'll simply go through and add the |
Is this how new contributions should be documented? |
I would suggest we keep with the status quo for now (so use numpy style). Until we actually change things it's best to stick with the same message. |
Ordinary Numpy docstrings please. The new style will only become possible once we drop python 2. |
Latest numpydoc docs are at https://numpydoc.readthedocs.io/en/latest/ |
If/when someone works on this could I suggest we don't include variable types for cases where type annotations have been included? |
I thought about doing this while rereading he library. Started with actions in #1193. Vince, while doing that I did think that types are redundant in cases where annotation are already there. In that case what would the format for returns be? Let's look at |
Awesome! Would be really cool if you could pick this up :) So currently we have:
My suggestion would be to match numpy style when the type is omitted: see which has:
So in our case I think this would be something like:
|
Also feel free to improve the type hints. For example in this case it's a tuple of Actions, which can be specified more precisely than |
Our docstrings currently use a variety of formats and we should agree a standard.
My suggestion is that we use Numpydoc (/~https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt) since it's the closest to anything we currently have.
Tasks required are:
The text was updated successfully, but these errors were encountered: