File: UnescapedEntity.md

package info (click to toggle)
error-prone-java 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 23,204 kB
  • sloc: java: 222,992; xml: 1,319; sh: 25; makefile: 7
file content (34 lines) | stat: -rw-r--r-- 848 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Javadocs are interpreted as HTML, so special characters such as `<`, `>`, and
`&` must be escaped.

Text within `@code`, `@literal` and `@link` tags is exempt from this.

```java
/** Returns whether n > 3. */
boolean greaterThanThree(int n);
```

Could be rendered as one of these instead:

```java
/** Returns whether n &gt; 3. */
boolean greaterThanThree(int n);

/** Returns whether {@code n > 3}. */
boolean greaterThanThree(int n);
```

A common pitfall is type parameters. The following Javadoc is valid, but
contains an unknown HTML tag (`Integer`):

```java
/** Returns an Iterable<Integer> of prime numbers. */
Iterable<Integer> generatePrimes();
```

Prefer writing generic types as `{@code Iterable<Integer>}` (or `{@link }`).

## Suppression

Suppress by applying `@SuppressWarnings("UnescapedEntity")` to the element being
documented.