-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some documentation for the Javadoc patterns.
RELNOTES: Add Javadoc docs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=215200762
- Loading branch information
1 parent
d4db5fa
commit c57ec8c
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Javadoc's `@param` tag should not be used to document parameters which do not | ||
appear in the formal parameter list. This may indicate a typo, or an omission | ||
when refactoring. | ||
|
||
```java {.bad} | ||
/** | ||
* Parses {@code input} as a proto. | ||
* | ||
* @param inputBytes input bytes to parse. | ||
*/ | ||
MyProto parse(byte[] input) { | ||
... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
A non-standard Javadoc tag was used, or was used in the wrong way. For example, | ||
`@param` should be used as a block tag to describe parameters, but cannot be | ||
used inline to link to parameters (prefer `{@code paramName}` for that). | ||
|
||
```java {.bad} | ||
/** | ||
* Doubles {@param n} | ||
* | ||
* @returns two times n | ||
*/ | ||
int twoTimes(int n) { | ||
return 2 * n; | ||
} | ||
``` | ||
|
||
```java {.good} | ||
/** | ||
* Doubles {@code n} | ||
* | ||
* @return two times n | ||
*/ | ||
int twoTimes(int n) { | ||
return 2 * n; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
The `@throws` tag should not document a checked exception which is not actually | ||
thrown by the documented method. | ||
|
||
```java {.bad} | ||
/** | ||
* Validates {@code n}. | ||
* | ||
* @throws Exception if n is negative. | ||
*/ | ||
void validate(int n) { | ||
... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Methods which do not return anything should not have a `@return` tag. | ||
|
||
```java {.bad} | ||
/** | ||
* Frobnicates. | ||
* | ||
* @return a frobnicator | ||
*/ | ||
void frobnicator(int a) { | ||
... | ||
} | ||
``` |