Getting rid of surprise spacing with <pre>

Paul Benedict pbenedict at apache.org
Mon Aug 1 16:17:57 UTC 2016


Dear Javadoc experts, I have two requests. It's based on this example:

/**
 * Hello.
 * <pre>
 * public int foo() {
 *     return 1;
 * }
 * </pre>
 */

I have some usability problems with the way Javadoc processes this code.

1) I understand <pre> is meant to retain formatting, but it's also too
literal with regards to how people want to express code samples. Above, the
use of <pre> and </pre> emits two new lines into the Javadoc, but I do find
that unnecessary. My intention here is to place the tags outside of my code
example so not to interfere with the way it looks in source. Couldn't there
be an enhancement that if <pre> and </pre> are found as the only token
after the asterisk/space combination, it would prevent emitting the new
line characters?

2) The other annoyance is that the space in the asterisk/space combination
is outputted! That doesn't make sense to me one bit. If the Javadoc
processor sees one long unbroken left-handed stanza of comment
continuation, I think the space should be ignored. That's clearly meant to
be a proper comment margin by the developer but not meant for the output.

I am merely just trying to get the extra whitespace removed without having
to mangle the source example in my comments. It just seems logical for
Javadoc to take a more natural approach to the way code is preformatted in
comments.

Thanks!

Cheers,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/javadoc-dev/attachments/20160801/aab8b7cd/attachment-0001.html>


More information about the javadoc-dev mailing list