Uh oh!
There was an error while loading. Please reload this page.
Improve getResults docstring to follow google documentation - #105
Conversation
ocefpaf
commented
Sep 29, 2017
I am 👍 to remove the PS: you can push the HTML to your forked |
emiliom
commented
Sep 29, 2017
Guys, thanks for all the progress you've made on the odm2api sphinx docs system in the last 24 hours!! One comment on this PR, but it's really a more general convention comment/question: I think I'd prefer not to have text that says what the default parameter values are, and let the reader just see it from the function definition. It's more work to add text, more error prone, and adds what I think is unnecessary text clutter. @ocefpaf, what do you think? |
emiliom
commented
Sep 29, 2017
👍
Yes, please! |
lsetiawan
commented
Sep 29, 2017
How do I do this? |
| >>> ReadODM2.getAffiliations(personfirst='John', | ||
| ... personlast='Smith') | ||
| >>> read.getAffiliations(orgcode='Acme') | ||
| >>> ReadODM2.getAffiliations(orgcode='Acme') |
There was a problem hiding this comment.
Is it helpful to have the module (ReadODM2) shown in the examples?? Seems like visual clutter to me.
This is a general comment, not specific to getAffiliations
There was a problem hiding this comment.
Is it helpful to have the module (
ReadODM2) shown in the examples?? Seems like visual clutter to me.
ReadODM2 is the parent class of this method, right? I guessed that read was an instance of that class. If getAffiliations is a static method it should be called with ReadODM2().getAffiliations, no? If not I guess that the confusing part is naming the instance the same name as the parent class, but I am OK with the examples.
There was a problem hiding this comment.
@emiliom, @ocefpaf I am following what pycharm is telling me. I get unresolved reference warning.. I can change to whatever.
If getAffiliations is a static method it should be called with ReadODM2().getAffiliations, no?
getAffiliations is not a static method.
Here's an example of the usage:
- https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/Sample.py#L38.
ReadODM2get instantiated and then the functions are used.
There was a problem hiding this comment.
Ah, I'd forgotten that getAffiliations was a ReadODM2 class method. This makes sense now. I was assuming (w/o checking, sorry ...) that ReadODM2 was simply a module reference.
My bad.
There was a problem hiding this comment.
I am following what pycharm is telling me
That is b/c pycharm is probably trying to lint that fragment of code. The original example probably omitted the instantiation of the class.
read=ReadODM2()There was a problem hiding this comment.
So keep
ReadODM2?
If that is a class method, yes. I need to check the code but it does not look like it.
See https://stackoverflow.com/questions/17134653/difference-between-class-and-instance-methods
If that is an instance method than you need to add more to the example, like:
read = ReadODM2()
read.<method>
There was a problem hiding this comment.
My executive decision: keep it for now, so we can move forward with the PR. We can discuss again later, elsewhere, to lay out general conventions.
There was a problem hiding this comment.
Like I suspected it is not a class method. Without an instance this cannot be called:
Wrong:
fromodm2api.ODM2.servicesimportReadODM2ReadODM2.getAffiliations(ids=[39,40])
---------------------------------------------------------------------------TypeErrorTraceback (mostrecentcalllast)
<ipython-input-4-82d16725b458>in<module>()
---->1ReadODM2.getAffiliations(ids=[39,40])
TypeError: unboundmethodgetAffiliations() mustbecalledwithReadODM2instanceasfirstargument (gotnothinginstead)Mocked "correct" example by instantiating an instance:
r=ReadODM2(session)
r.getAffiliations(ids=[39,40])
<returnsidsfromsession>There was a problem hiding this comment.
Thanks for the follow-up, @ocefpaf. @lsetiawan, let's start compiling elsewhere a list of conventions we'll follow.
ocefpaf
commented
Sep 29, 2017
You have to create a |
emiliom
commented
Sep 29, 2017
I suspect this comment of mine may have gotten lost in the barrage of other comments; pasting it just in case. |
ocefpaf
commented
Sep 29, 2017
Nope. I it just took some reading of the docstring to understand what you meant.
That is a matter of preference but I usually like to specify the default in the docstrings to explain them.
In this particular case they are all |
lsetiawan
commented
Sep 29, 2017
If function has a default value other than
This sounds good. Thanks for input! 😄 |
emiliom
commented
Sep 29, 2017
Executive decision, for now (again, to move forward with the PR): remove from the text from the docstring in this case. But more generally, let's also not include that text when there is no explanation in the docstring. Of course, we can revisit that "decision" later!! |
emiliom
commented
Sep 29, 2017
Travis-CI is passing. Looks like it's ready to merge, and we have no outstanding comments? If so, @ocefpaf please merge. I have a meeting in 2 minutes. |
emiliom
commented
Sep 29, 2017
Let me know when these changes (plus, I assume, more modules being listed) are available at http://odm2.github.io/ODM2PythonAPI/ |
ocefpaf
commented
Sep 29, 2017
They are up as soon as Travis-CI finished the "docs" task, see https://travis-ci.org/ODM2/ODM2PythonAPI So it should be 2-3 minutes more 😄 |
emiliom
commented
Sep 29, 2017
I don't see it updated at http://odm2.github.io/ODM2PythonAPI/ or http://odm2.github.io/ODM2PythonAPI/py-modindex.html |
ocefpaf
commented
Sep 29, 2017
I don't think @lsetiawan changed the docs, only the docstrings. @lsetiawan do you want to wait until you write everything to add it to the |
emiliom
commented
Sep 29, 2017
I'd rather do a partial test first, with a partial listing in modules.rst, to ensure the workflow is in place and Don and I know what to do. Then next week we can update odm2api docstrings, and the overall set of sphinx documents, at our own pace. |
emiliom
commented
Sep 29, 2017
.... including the two methods whose docstrings @lsetiawan has fleshed out |
lsetiawan
commented
Sep 29, 2017
lsetiawan
commented
Sep 29, 2017
@ocefpaf can we only expose certain functions not whole module? |
ocefpaf
commented
Sep 29, 2017
You probably can by overriding the auto-discover functionality of sphinx. |
emiliom
commented
Sep 29, 2017
Woo-hoo!!! Awesome! 🕺
@lsetiawan, is there a reason why you'd like to "hide" some functions? I think we should be exposing everything right now, the whole module. If your concern is the lack of a docstring (or a docstring not yet properly formatted), that's not a reason to hide it. |
lsetiawan
commented
Sep 29, 2017
If that's fine then we can expose this whole module. |
emiliom
commented
Sep 29, 2017
Yup, let's do that! This will be a work in progress, but already a vast improvement in odm2api documentation!! |
emiliom
commented
Sep 29, 2017
I missed the fact that was on your fork ... Still, great to see that we're almost there, but I'll hold off on the wild ecstatic dancing until it's on http://odm2.github.io/ODM2PythonAPI/index.html |
Overview
This PR relates to #97. It applies google docstring standard to
getResultsmostly.Also fixes a bit of
getAffiliationsdocstring. For example, removing:obj:and changingreadtoReadODM2.Demo