Skip to content

Commit

Permalink
fix: generate jsdocs for operations with no documentation (#971)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Sep 28, 2023
1 parent 2f70f10 commit f574977
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .changeset/four-kids-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeId;
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.traits.DeprecatedTrait;
import software.amazon.smithy.model.traits.DocumentationTrait;
import software.amazon.smithy.model.traits.ErrorTrait;
import software.amazon.smithy.model.traits.InternalTrait;
import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait;
import software.amazon.smithy.typescript.codegen.documentation.StructureExampleGenerator;
import software.amazon.smithy.typescript.codegen.endpointsV2.EndpointsParamNameMap;
Expand Down Expand Up @@ -139,9 +141,23 @@ private void generateClientCommand() {
.append("\n")
.append(getThrownExceptions());

writer.writeShapeDocs(
boolean operationHasDocumentation = operation.hasTrait(DocumentationTrait.class);

if (operationHasDocumentation) {
writer.writeShapeDocs(
operation,
shapeDoc -> shapeDoc + additionalDocs);
shapeDoc -> shapeDoc + additionalDocs
);
} else {
boolean isPublic = !operation.hasTrait(InternalTrait.class);
boolean isDeprecated = operation.hasTrait(DeprecatedTrait.class);

writer.writeDocs(
(isPublic ? "@public\n" : "@internal\n")
+ (isDeprecated ? "@deprecated\n" : "")
+ additionalDocs
);
}

writer.openBlock(
"export class $L extends $$Command<$T, $T, $L> {", "}",
Expand Down

0 comments on commit f574977

Please sign in to comment.