Skip to content

Commit 51364b6

Browse files
committed
Remove substring check
1 parent 2bed14b commit 51364b6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsRstDocFileGenerator.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
import static software.amazon.smithy.python.codegen.SymbolProperties.OPERATION_METHOD;
88

99
import java.util.List;
10+
import java.util.Optional;
11+
1012
import software.amazon.smithy.model.traits.InputTrait;
1113
import software.amazon.smithy.model.traits.OutputTrait;
14+
import software.amazon.smithy.model.traits.StreamingTrait;
1215
import software.amazon.smithy.python.codegen.GenerationContext;
1316
import software.amazon.smithy.python.codegen.integrations.PythonIntegration;
1417
import software.amazon.smithy.python.codegen.sections.*;
@@ -116,12 +119,15 @@ public void append(PythonWriter pythonWriter, StructureSection section) {
116119
var symbol = context.symbolProvider().toSymbol(shape);
117120
String docsFileName = String.format("docs/models/%s.rst",
118121
symbol.getName());
122+
123+
boolean isStreaming = Optional.ofNullable(shape.getAllMembers().get("body"))
124+
.map(member -> context.model().expectShape(member.getTarget()))
125+
.map(memberShape -> memberShape.hasTrait(StreamingTrait.class))
126+
.orElse(false); // Input and output shapes are typically skipped since they are generated
119127
// Input and output shapes are typically skipped since they are generated
120-
// on the operation's page. Shapes ending with "OperationOutput" are
121-
// wrappers around streaming output shapes. These should be documented
122-
// because the streaming class refers to and documents the wrapped class
123-
// and will link to the wrapper class.
124-
if (!shape.hasTrait(InputTrait.class) && !shape.hasTrait(OutputTrait.class) || symbol.getName().endsWith("OperationOutput")) {
128+
// on the operation's page. The exception to this is the output of
129+
// streaming operations where we have a different output shape defined.
130+
if (!shape.hasTrait(InputTrait.class) && !shape.hasTrait(OutputTrait.class) || isStreaming) {
125131
context.writerDelegator().useFileWriter(docsFileName, "", writer -> {
126132
writer.write(generateHeader(symbol.getName()));
127133
writer.write(".. autoclass:: " + symbol.toString() + "\n :members:\n");

0 commit comments

Comments
 (0)