Skip to content

fix(codegen): strip empty self-closing HTML tags from documentation traits - #7773

Open
TrevorBurnham wants to merge 1 commit into
aws:mainfrom
TrevorBurnham:fix/sanitize-empty-html-tags-in-docs
Open

fix(codegen): strip empty self-closing HTML tags from documentation traits#7773
TrevorBurnham wants to merge 1 commit into
aws:mainfrom
TrevorBurnham:fix/sanitize-empty-html-tags-in-docs

Conversation

@TrevorBurnham

Copy link
Copy Markdown
Contributor

Fixes #7477

Problem

Several upstream AWS service models contain empty self-closing HTML tags like <p/> in their smithy.api#documentation trait values. These tags pass through code generation unmodified and render as literal text in:

  • Generated README.md files (e.g. clients/client-lambda/README.md)
  • JSDoc/TSDoc comments in generated TypeScript source (e.g. LambdaClient.ts)
  • The published API reference at docs.aws.amazon.com

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 SanitizeDocumentation codegen integration that runs as a preprocessModel step — before any code generation. It walks every shape in the Smithy model, finds DocumentationTrait values 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 .ts files, and anything else that consumes the documentation trait. It's also resilient to future model updates that reintroduce these tags.

Changes

  • New file: codegen/smithy-aws-typescript-codegen/src/main/java/.../SanitizeDocumentation.java
    • Implements TypeScriptIntegration.preprocessModel
    • Uses a regex to match <p/>, <br/>, <hr/> (with optional whitespace)
    • Replaces affected shapes via ModelTransformer.replaceShapes
  • Modified: META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration
    • Registers the new integration

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…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
@TrevorBurnham
TrevorBurnham requested a review from a team as a code owner February 23, 2026 03:33
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.

HTML P tag in documentation

1 participant