Skip to content

Commit

Permalink
Suggest using code as per[]
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 551547582
  • Loading branch information
java-team-github-bot authored and Error Prone Team committed Jul 27, 2023
1 parent 7af50cc commit 25c361a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docs/bugpattern/javadoc/InvalidBlockTag.md
Expand Up @@ -18,19 +18,31 @@ int twoTimes(int n) {
}
```

Note that any Javadoc line starting with `@`, even embedded inside `<pre>` and
`{@code ...}`, is interpereted as a block tag by the Javadoc parser. As such, if
you wish your Javadoc to include a code block containing an annotation, you
should generally avoid `{@code ...}` and instead write the HTML yourself,
manually escaping the `@` entity.
Note that any Javadoc line starting with `@`, even embedded inside `<pre>` is
interpreted as a block tag by the Javadoc parser. As such, if you wish your
Javadoc to include a code block containing an annotation, you should surround
the snippet with `{@code ...}`. Alternatively, and if you are using a version of
javadoc prior to JDK 15, you may escape the symbol using `{@literal @}`

```java
/**
* Designed to be overridden, such as:
*
* <pre>{@code
* class Foo {
* @Override public String toString() {return "";}
* }
* }</pre>
*/
```

```java
/**
* Designed to be overridden, such as:
*
* <pre>
* class Foo {
* &#64;Override public String toString() {return "";}
* {@literal @}Override public String toString() {return "";}
* }
* </pre>
*/
Expand Down

0 comments on commit 25c361a

Please sign in to comment.