Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep trailing doc comment spaces in IDL serializer #2116

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,13 @@ private void serializeTraits(Map<ShapeId, Trait> traits, TraitFeature... traitFe

private void serializeDocumentation(String documentation) {
// The documentation trait has a special syntax, which we always want to use.
codeWriter.setNewlinePrefix("/// ")
codeWriter
.pushState()
// See https://github.com/smithy-lang/smithy/issues/2115
.trimTrailingSpaces(false)
.setNewlinePrefix("/// ")
.write(documentation.replace("$", "$$"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what's the motivation for this replace btw? I didn't think $ had any special meaning in doc comments...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The write thing this goes through treats them specially as placeholders, so we have to escape them. The writer later turns it back into "$".

.setNewlinePrefix("");
.popState();
}

private void serializeTrait(Trait trait) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$version: "2.0"

namespace com.example

/// This line has trailing spaces
/// This line does not have trailing spaces
/// This line has one trailing space
/// Addresses https://github.com/smithy-lang/smithy/issues/2115
string TestString
Loading