Skip to content

Commit

Permalink
Keep trailing doc comment spaces in IDL serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jan 26, 2024
1 parent dc2ae9e commit e671ac9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
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("$", "$$"))
.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

0 comments on commit e671ac9

Please sign in to comment.