Properly format javadocs#1168
Merged
Merged
Conversation
mtdowling
approved these changes
May 4, 2026
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.
Convert Smithy documentation traits to properly formatted Javadoc
Smithy's
@documentationtrait accepts Markdown, and AWS service models use raw HTML in their documentation traits. Previously, this content was written to Javadoc comments as-is, producing poorly formatted output with excessive whitespace, missing paragraph separation, invalid HTML nesting, and no line wrapping.This change introduces a proper conversion pipeline that produces clean, well-formatted Javadoc from both Markdown and HTML input.
Pipeline
Input (Markdown or HTML)
<p>inside<li>, remove empty<p>)What changed
New dependencies:
org.commonmark:commonmark:0.28.0(BSD-2-Clause, no transitive deps) for Markdown to HTMLorg.jsoup:jsoup:1.22.2(MIT, no transitive deps) for HTML parsing and DOM manipulationMarkdownToJavadoc(new) - Converts documentation trait values to Javadoc-compatible HTML:<p>tag (Javadoc convention)<p>prefix<ul>,<li>, etc.) pretty-printed on their own lines with 2-space indentation{@literal @}blocks@escaped as{@literal @}to prevent Javadoc tag conflicts<,>,&in text properly encoded as HTML entitiesList<String>) preserved asList<String>instead of being parsed as HTML<li><p>text</p></li>simplified to<li>text</li>)<p>elements removed<pre>{@code ...}</pre>JavadocFormatterInterceptor(simplified) - Reduced from 230 lines to 110. Now only handles wrapping content in/** ... */delimiters,prefixing lines with
*, escaping*, and{@snippet}blocks. All HTML formatting and line wrapping moved toMarkdownToJavadoc.DocumentationTraitInterceptor(updated) - Passes nesting-dependent max width to the converter based on whether the Javadoc is for a class ora member.
Before / After
(Examples used the trascribestreaming model)
Before (AudioStream.java):
After:
Before (MedicalScribeInputStream.java):
After:
Testing
Added unit tests
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.