-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
doc: Add API documentation to 3 undocumented public methods #3854
Conversation
Added documentation for 3 undocumented public methods and lowered the threshold for documentation to 32 issue: #1876
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Rohitesh-Kumar-Jain , thanks a lot for this first contribution! We love docs contributions in Spoon, so it's very much appreciated.
I have added some comments on your PR for potential improvements. Could you please look them over and see what you can do?
@@ -303,6 +303,10 @@ boolean isInModel(CtElement element) { | |||
return false; | |||
} | |||
|
|||
/** | |||
* Builds a Pattern, if the pattern isn't built yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the pattern is already built? Could you document that behavior with an @throws
and a mention in the general description?
@@ -303,6 +303,10 @@ boolean isInModel(CtElement element) { | |||
return false; | |||
} | |||
|
|||
/** | |||
* Builds a Pattern, if the pattern isn't built yet | |||
* @return {@link Pattern} which is built after executing this method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, avoid specifying the type of a parameter or return value in the Javadoc. It's already documented in the method header, and is automatically included in the generated documentation. Duplicating the types from the method header in the Javadoc is redundant, and from experience, it often leads to the types in the Javadoc being forgotten and going out-of-date :)
So, I'd suggest something like this:
* @return {@link Pattern} which is built after executing this method | |
* @return the built pattern |
Note: Sometimes it is appropriate to add
@link
tags that relate to the types of parameters and return values if it's the easiest way to describe a concept, but as a general rule, I find that it's better not to duplicate that information.
* If the environment in which spoon is executed tries to preserve the original line number and the the passed | ||
* indexes of CtElement e are known then it will generate new lines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite what this method does. When preserving line numbers, this method adds as many lines as needed for the current line to match the end line of the given element.
* @param e is a {@link CtElement} on which new lines are going to be generated | ||
* @return {@link PrinterHelper} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before, avoid specifying the types of parameters and return values in the Javadoc. Say something about them instead.
/** | ||
* Creates a new {@link RtMethod} | ||
* @param method is passed as Method | ||
* @return {@link RtMethod} | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Javadoc does not really say anything, it mostly just duplicates the method header.
What this method does is to wrap a Method
in an RtMethod
. Note that it's entirely fine to have a Javadoc without a general description. That is to say with only tags, like so:
/** | |
* Creates a new {@link RtMethod} | |
* @param method is passed as Method | |
* @return {@link RtMethod} | |
*/ | |
/** | |
* @param method Say something about the parameter | |
* @return Say something about the return value | |
*/ |
Could you try to improve this Javadoc to say something meaningful?
Hi @slarse, I am so glad that you reviewed my PR and gave feedback, I will address all the comments in the next commit. After resolving issues with this PR, I would love to work on other issues as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your revision, now the docs are really shaping up. I've added some final comments, I think with one more revision this will be ready to merge.
As I think you misunderstood one of my previous comments: don't hesitate to ask about anything you think is unclear!
* @throws SpoonException if the patter has been built already | ||
* @return the built patter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos :)
* @throws SpoonException if the patter has been built already | |
* @return the built patter | |
* @throws SpoonException if the pattern has been built already | |
* @return the built pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out :)
One thing I am curious about is why one of my commits failed 1 out of 7 tests (locally I passed all the test cases), when I committed the same changes again, it passed all 7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a connection timeout, it had nothing to do with your work: https://github.com/INRIA/spoon/runs/2186431693#step:8:3661
We have some problems with an old Maven repository that we used to use, it goes offline from time to time. The last traces of it are being removed (#3860).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting me know the cause.
* @param e is a CtElement whose line number will be preserved by adding newlines | ||
* @return PrinterHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you misinterpreted my feedback about referring to types: just writing e.g. CtElement
is less informative than {@link CtElment}
, and it still refers explicitly to the type. Look for example at this standard library Javadoc. The Javadoc describes the semantic meaning of the values, not their types. Note also that the type of each parameter is very evident in the Javadoc as they appear in the signature, so unless it actually helps understand something, I would omit the explicit types.
What I meant was something like this:
// no; refers explicitly to the type, which is already specified in the method header
* @param e is a {@link CtElement} whose line number will be preserved by adding newlines
// no; also refers explicitly to the type, but there will be no clickable link in the Javadoc HTML
* @param e is a CtElement whose line number will be preserved by adding newlines
// yes; does not refer explicitly to the type, we just say "element", which is more general
* @param e element whose line number will be preserved by adding newlines
To be clear, if you need to refer to the type, use @link
tags. If you don't need to refer to the type, describe the value in natural language without the type name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sharing the example and clearing things up, for now on I will just ask if something isn't clear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for now on I will just ask if something isn't clear to me.
Very good!
* @param method is the Method which is to be wrapped in a RtMethod | ||
* @return an object of RtMethod after calling the parameterized constructor of the RtMethod class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param
is good in terms of information, but the comment about types still applies. If you want to refer to types (which isn't unreasonable here; this method just wraps an object of one type in an object of another type), then use @link
.
The @return
is much too specific. Only write what's actually important to a caller of the method. Does it matter how the wrapper is created? What if we change RtMethod
to a fluent API instead, should that matter to this method? I would suggest something like @return a wrapper around the passed method
instead, because that describes the semantics of the value, and not the details of its type or how it came to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions, I will incorporate the necessary changes in the next commit.
@Rohitesh-Kumar-Jain Could you make a final pass over your PR and check that you've fixed everything you want to fix, and then ping me when you're happy with it? |
Hi @slarse this commit seems fine to me, excited to see what lies ahead of this PR. |
@Rohitesh-Kumar-Jain I'm satisfied as well. @monperrus Ping for final approval. |
@Rohitesh-Kumar-Jain congratulations and thank you very much for your first contribution. Welcome to the Spoon community! Thanks @slarse for the shepherding. |
Hi @monperrus, |
Hi,
Added documentation for 3 undocumented public methods and lowered the threshold for documentation to 32
issue: #1876
I hope the documentations makes some sense :P
Best,
Rohitesh