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

Suggest using code as per[] #4023

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions docs/bugpattern/javadoc/InvalidBlockTag.md
Original file line number Diff line number Diff line change
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
Loading