Skip to content
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

Merged
merged 5 commits into from
Mar 26, 2021
Merged

doc: Add API documentation to 3 undocumented public methods #3854

merged 5 commits into from
Mar 26, 2021

Conversation

Rohitesh-Kumar-Jain
Copy link
Contributor

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

Added documentation for 3 undocumented public methods and lowered the threshold for documentation to 32
issue: #1876
@Rohitesh-Kumar-Jain Rohitesh-Kumar-Jain changed the title doc: Add API documentation to 3 undocumented public methods review: doc: Add API documentation to 3 undocumented public methods Mar 22, 2021
@slarse slarse self-requested a review March 23, 2021 15:24
Copy link
Collaborator

@slarse slarse left a 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
Copy link
Collaborator

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
Copy link
Collaborator

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:

Suggested change
* @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.

Comment on lines 234 to 235
* 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
Copy link
Collaborator

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.

Comment on lines 236 to 237
* @param e is a {@link CtElement} on which new lines are going to be generated
* @return {@link PrinterHelper}
Copy link
Collaborator

@slarse slarse Mar 23, 2021

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.

Comment on lines 140 to 144
/**
* Creates a new {@link RtMethod}
* @param method is passed as Method
* @return {@link RtMethod}
*/
Copy link
Collaborator

@slarse slarse Mar 23, 2021

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:

Suggested change
/**
* 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?

@Rohitesh-Kumar-Jain
Copy link
Contributor Author

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.

Copy link
Collaborator

@slarse slarse left a 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,

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!

Comment on lines 308 to 309
* @throws SpoonException if the patter has been built already
* @return the built patter
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typos :)

Suggested change
* @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

Copy link
Contributor Author

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.

Copy link
Collaborator

@slarse slarse Mar 25, 2021

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).

Copy link
Contributor Author

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.

Comment on lines 235 to 236
* @param e is a CtElement whose line number will be preserved by adding newlines
* @return PrinterHelper
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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!

Comment on lines 141 to 142
* @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
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@slarse
Copy link
Collaborator

slarse commented Mar 25, 2021

@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?

@Rohitesh-Kumar-Jain
Copy link
Contributor Author

@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.

@slarse
Copy link
Collaborator

slarse commented Mar 25, 2021

@Rohitesh-Kumar-Jain I'm satisfied as well.

@monperrus Ping for final approval.

@monperrus monperrus changed the title review: doc: Add API documentation to 3 undocumented public methods doc: Add API documentation to 3 undocumented public methods Mar 26, 2021
@monperrus monperrus merged commit 668a18b into INRIA:master Mar 26, 2021
@monperrus
Copy link
Collaborator

@Rohitesh-Kumar-Jain congratulations and thank you very much for your first contribution. Welcome to the Spoon community!

Thanks @slarse for the shepherding.

@Rohitesh-Kumar-Jain
Copy link
Contributor Author

Hi @monperrus,
I am glad to make the first contribution, I will look up for some other issues to work upon.
If you want to suggest a particular issue, I will be happy to work on it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
  NODES
COMMUNITY 3
Note 3
Project 3
USERS 1