|
7 | 7 | import static software.amazon.smithy.python.codegen.SymbolProperties.OPERATION_METHOD; |
8 | 8 |
|
9 | 9 | import java.util.List; |
| 10 | +import java.util.Optional; |
| 11 | + |
10 | 12 | import software.amazon.smithy.model.traits.InputTrait; |
11 | 13 | import software.amazon.smithy.model.traits.OutputTrait; |
| 14 | +import software.amazon.smithy.model.traits.StreamingTrait; |
12 | 15 | import software.amazon.smithy.python.codegen.GenerationContext; |
13 | 16 | import software.amazon.smithy.python.codegen.integrations.PythonIntegration; |
14 | 17 | import software.amazon.smithy.python.codegen.sections.*; |
@@ -116,12 +119,15 @@ public void append(PythonWriter pythonWriter, StructureSection section) { |
116 | 119 | var symbol = context.symbolProvider().toSymbol(shape); |
117 | 120 | String docsFileName = String.format("docs/models/%s.rst", |
118 | 121 | 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 |
119 | 127 | // 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) { |
125 | 131 | context.writerDelegator().useFileWriter(docsFileName, "", writer -> { |
126 | 132 | writer.write(generateHeader(symbol.getName())); |
127 | 133 | writer.write(".. autoclass:: " + symbol.toString() + "\n :members:\n"); |
|
0 commit comments