Skip to content

fix: Strip backslash before ^ in generated docstrings#707

Open
Alan4506 wants to merge 1 commit into
smithy-lang:developfrom
Alan4506:fix/docstring-escape-caret
Open

fix: Strip backslash before ^ in generated docstrings#707
Alan4506 wants to merge 1 commit into
smithy-lang:developfrom
Alan4506:fix/docstring-escape-caret

Conversation

@Alan4506
Copy link
Copy Markdown
Contributor

@Alan4506 Alan4506 commented Jun 1, 2026

Description of changes:
The MarkdownConverter strips unnecessary backslash escapes that pandoc adds for markdown syntax characters. However, ^ was missing from the strip list. When pandoc converts service documentation containing a literal ^ character, it escapes it to \^ because ^ is a markdown superscript marker in some extensions. This \^ then ends up in the generated Python docstring as an invalid escape sequence, causing pyright reportInvalidStringEscapeSequence errors.

This issue was identified during generation of DynamoDB client using its model file: one of its smithy.api#documentation contains a sequence: <p>4500-6500 third sleep/delay (500 * 2^2)</p>\n.

This PR adds ^ to the regex character class in postProcessPandocOutput() so that \^ is correctly stripped to ^ in generated docstrings. This aligns with how we handled a similar issue before in another PR.

Verified by generating the DynamoDB client with the fix. smithy build --aut passes ruff and pyright cleanly, and there is no \^ in generated code.

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

@Alan4506 Alan4506 requested a review from a team as a code owner June 1, 2026 21:51
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