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

Fix multiline doc comment parsing on members #498

Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
### Bug Fixes

* Fixed a bug where `passthroughBehavior` was misspelled as `passThroughBehavior`
in APIGateway OpenAPI output for integrations and mock integrations.
in APIGateway OpenAPI output for integrations and mock integrations. ([#495](https://github.com/awslabs/smithy/pull/495))
* Fixed a bug where only the last line in a multiline doc comment on a
member would be successfully parsed. ([#498](https://github.com/awslabs/smithy/pull/498))

## 1.0.6 (2020-06-24)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ private String parseDocCommentLine() {
int start = position();
consumeRemainingCharactersOnLine();
br();
sp();
return StringUtils.stripEnd(sliceFrom(start), " \t\r\n");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import software.amazon.smithy.model.shapes.ResourceShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.traits.DocumentationTrait;
import software.amazon.smithy.model.traits.StringTrait;
import software.amazon.smithy.model.validation.ValidatedResultException;

public class IdlModelLoaderTest {
Expand Down Expand Up @@ -116,4 +118,17 @@ public void limitsRecursion() {

assertThat(e.getMessage(), containsString("Parser exceeded the maximum allowed depth of"));
}

@Test
public void handlesMultilineDocComments() {
Model model = Model.assembler()
.addImport(getClass().getResource("multiline-comments.smithy"))
.assemble()
.unwrap();

Shape shape = model.expectShape(ShapeId.from("smithy.example#MyStruct$myMember"));
String docs = shape.getTrait(DocumentationTrait.class).map(StringTrait::getValue).orElse("");

assertThat(docs, equalTo("This is the first line.\nThis is the second line."));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace smithy.example

structure MyStruct {
/// This is the first line.
/// This is the second line.
myMember: String
}