Reputation: 105203
This is what I'm trying to do:
/**
* <pre>
* {@code
* @XmlRootElement
* public final class Page {
* }
* }
* </pre>
*/
I'm expecting it to be formatted like:
@XmlRootElement
public final class Page {
}
But I'm getting:
@XmlRootElement
public final class Page {
}
Replacing these HTML entities with real symbols (@
, {
, }
) leads to javadoc warnings and absolutely incorrect formatting. What is a workaround?
Upvotes: 38
Views: 25509
Reputation: 4337
Since Java 23 (JEP 467) you may use ///
for Markdown comments:
/// ```
/// @XmlRootElement
/// public final class Page {
/// }
/// ```
Upvotes: 2
Reputation: 4337
Since Java 18 (JEP 413) you may use @snippet
tag:
/**
* -- ex: looping through List of Map objects --
* {@snippet :
* @XmlRootElement
* public final class Page {
* }
* }
*/
Upvotes: 6
Reputation: 1189
It is old question but I figured out why it was not working for me.
This was not working:
<pre>{@code
@Autowired
But when all written in one line it works.
<pre>
{@code @Autowired
Upvotes: 0
Reputation: 799
<pre>
<code>
{@literal@}Override
public String toString() {
return "blah";
}
</code>
</pre>
This works for me.
Upvotes: 31
Reputation: 105203
This is how it finally works for me:
/**
* <pre>
* @XmlRootElement
* public final class Page {
* }
* </pre>
*/
Upvotes: 40
Reputation: 115388
wrap your code snippet with <pre><code></code></pre>
. These are special HTML tags that allow you to forget about escaping of special characters.
Upvotes: 7