fix(codegen): strip empty self-closing HTML tags from documentation traits - #7773
Open
TrevorBurnham wants to merge 1 commit into
Open
fix(codegen): strip empty self-closing HTML tags from documentation traits#7773TrevorBurnham wants to merge 1 commit into
TrevorBurnham wants to merge 1 commit into
Conversation
…raits Adds a SanitizeDocumentation preprocessor that removes empty self-closing HTML tags (<p/>, <br/>, <hr/>) from Smithy DocumentationTrait values before code generation. These tags originate from upstream AWS service models and render as literal text in generated READMEs, JSDoc comments, and the published API reference docs. Fixes aws#7477
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.
Fixes #7477
Problem
Several upstream AWS service models contain empty self-closing HTML tags like
<p/>in theirsmithy.api#documentationtrait values. These tags pass through code generation unmodified and render as literal text in:README.mdfiles (e.g.clients/client-lambda/README.md)LambdaClient.ts)The Lambda client page is the one called out in the issue, but 30 service models are affected (RDS alone has 89 occurrences of
<p/>).Solution
Adds a new
SanitizeDocumentationcodegen integration that runs as apreprocessModelstep — before any code generation. It walks every shape in the Smithy model, findsDocumentationTraitvalues containing empty self-closing HTML tags (<p/>,<br/>,<hr/>), and strips them.Because this operates on the model before codegen, it fixes all downstream outputs at once: READMEs, JSDoc in
.tsfiles, and anything else that consumes the documentation trait. It's also resilient to future model updates that reintroduce these tags.Changes
codegen/smithy-aws-typescript-codegen/src/main/java/.../SanitizeDocumentation.javaTypeScriptIntegration.preprocessModel<p/>,<br/>,<hr/>(with optional whitespace)ModelTransformer.replaceShapesMETA-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegrationBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.