Skip to content

Improve rendering of javadoc content#1981

Open
kwin wants to merge 2 commits into
masterfrom
feature/improve-content-rendering
Open

Improve rendering of javadoc content#1981
kwin wants to merge 2 commits into
masterfrom
feature/improve-content-rendering

Conversation

@kwin

@kwin kwin commented Jul 20, 2026

Copy link
Copy Markdown
Member

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:

  • Your pull request should address just one issue, without pulling in other changes.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body.
    Note that commits might be squashed by a maintainer on merge.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied.
    This may not always be possible but is a best-practice.
  • Run mvn verify to make sure basic checks pass.
    A more thorough check will be performed on your pull request automatically.
  • You have run the integration tests successfully (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.

kwin added 2 commits July 20, 2026 12:13
Render all inline tags in the same way as the standard doclet.
Some code simplifications.
@kwin
kwin force-pushed the feature/improve-content-rendering branch from 7cc1e9c to 74050ec Compare July 20, 2026 18:55
@kwin
kwin marked this pull request as ready for review July 20, 2026 19:24
@kwin
kwin requested review from cstamas and gnodet July 20, 2026 19:24

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PLAINescapeHtml(), LINKrenderAsCode().

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants