Repository navigation
fix: preserve preformatted help descriptions - #1214
Open
efegokdemir wants to merge 3 commits into
Open
efegokdemir wants to merge 3 commits into
efegokdemir wants to merge 3 commits into
Conversation
Signed-off-by: Efe Gökdemir <efe@rexcode.co.uk>
gnodet-bot
reviewed
Oct 17, 2026
gnodet-bot
left a comment
There was a problem hiding this comment.
Correct fix for MPLUGIN-535 — the sentinel-char approach, the preformatted counter, and the whitespace-preservation logic all look sound. Two items worth cleaning up before merge.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Comment on lines
+95
to
+103
| if (name.equals("pre")) { | ||
| preformatted--; | ||
| preformattedEndsWithNewline = accum.length() > 0 && accum.charAt(accum.length() - 1) == '\n'; | ||
| accum.append(PRE_END); | ||
| } | ||
| if (name.equals("pre")) { | ||
| if (!preformattedEndsWithNewline) { | ||
| accum.append('\n'); | ||
| } |
There was a problem hiding this comment.
if (name.equals("pre")) block — the two consecutive if blocks can be merged. After the first block appends PRE_END, name is still "pre", so the second check is always true when the first was true. Merge them into a single block:
Suggested change
| if (name.equals("pre")) { | |
| preformatted--; | |
| preformattedEndsWithNewline = accum.length() > 0 && accum.charAt(accum.length() - 1) == '\n'; | |
| accum.append(PRE_END); | |
| } | |
| if (name.equals("pre")) { | |
| if (!preformattedEndsWithNewline) { | |
| accum.append('\n'); | |
| } | |
| if (name.equals("pre")) { | |
| preformatted--; | |
| preformattedEndsWithNewline = accum.length() > 0 && accum.charAt(accum.length() - 1) == '\n'; | |
| accum.append(PRE_END); | |
| if (!preformattedEndsWithNewline) { | |
| accum.append('\n'); | |
| } | |
| ``` |
Comment on lines
86
to
+93
| } | ||
|
|
||
| @Test | ||
| void preformattedTextPreservesWhitespace() { | ||
| String test = | ||
| "For example:<pre>\n <binary>\n <url>https://example.test/plugin.exe</url>\n </binary>\n</pre>"; | ||
| assertEquals( | ||
| "For example:\n <binary>\n <url>https://example.test/plugin.exe</url>\n </binary>\n", |
There was a problem hiding this comment.
💡 Consider adding edge-case tests for robustness:
<pre>content that does not end with a newline (tests thepreformattedEndsWithNewlinebranch)- Multiple
<pre>blocks in the same input - Nested
<pre>handling (if expected to be unsupported, a comment saying so would help)
The current test only covers the trailing-newline path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #845 (MPLUGIN-535) by preserving whitespace in JavaDoc
<pre>blocks when generating plain-text plugin help output. Previously, code examples were flattened and their indentation was lost.Codex assisted with repository analysis, implementation, and test preparation. The change has been reviewed locally, and all changed lines and validation results are disclosed here for human maintainer review.
Changes
<pre>content to plain text.help-basic-jdk11regression coverage for a multi-line XML example.Testing
mvn -pl maven-plugin-tools-generators -am -Dspotless.check.skip=true -Dspotless.apply.skip=true test -q✅mvn -pl maven-plugin-plugin -am -DskipTests -DskipITs -Dspotless.check.skip=true -Dspotless.apply.skip=true install -q✅mvn -pl maven-plugin-plugin -Prun-its -Dinvoker.test=help-basic-jdk11 -Dspotless.check.skip=true -Dspotless.apply.skip=true integration-test -qhelp-basic-jdk11output comparison from the generatedhelp.logagainstexpected-help.txt✅git diff --check✅palantir-java-formatfails withNoSuchFieldErroragainst the installed JDK 27 compiler APINotes
The production fix is shared by both legacy and Maven 4 help templates. The generated fixture output was verified independently because the repository's Groovy invoker hook is not compatible with the installed JDK 27. The commit is cryptographically signed and includes the required
Signed-off-bytrailer.