Improve rendering of javadoc content#1981
Conversation
Render all inline tags in the same way as the standard doclet. Some code simplifications.
7cc1e9c to
74050ec
Compare
gnodet
left a comment
There was a problem hiding this comment.
Good improvement overall — replacing the fragile regex-based Javadoc tag post-processing with a proper SimpleDocTreeVisitor is the right approach. The handling of {@value}, {@systemProperty}, HTML elements, and entities is well done.
Bug — {@code} / {@literal} rendering swapped:
In visitLiteral (line 502), the condition node.getKind() == DocTree.Kind.LITERAL routes {@literal} through renderAsCode() and {@code} through escapeHtml(). Per the Javadoc spec:
{@code text}(Kind.CODE) should render as<code>text</code>{@literal text}(Kind.LITERAL) should render as plain escaped text
The condition should check DocTree.Kind.CODE instead. The sibling visitLink method in the same file demonstrates the correct pattern: LINK_PLAIN → escapeHtml(), LINK → renderAsCode().
The test at line 84 validates the swapped behavior — the expected string shows plain text for {@code} and <code> tags for {@literal}, which matches the buggy code but contradicts the spec.
Suggested fix:
if (node.getKind() == DocTree.Kind.CODE) {
return renderAsCode(node.getBody().getBody());
} else {
return escapeHtml(node.getBody().getBody());
}Minor: renderContent Javadoc has @param tags without descriptions.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Render all inline tags in the same way as the standard doclet. Some code simplifications.
Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.