Skip to content

Commit

Permalink
Merge pull request #770 from MYoung25/docs/inheritance
Browse files Browse the repository at this point in the history
Add packageDocumentation and improve interface inheritance
  • Loading branch information
MYoung25 committed May 23, 2023
2 parents 8e99be5 + abdacbf commit 988ad4c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ private void generateCommandMiddlewareResolver(String configType) {
}

private void addInputAndOutputTypes() {
writer.writeDocs("@public");
writer.write("export { __MetadataBearer, $$Command };");

writeInputType(inputType.getName(), operationIndex.getInput(operation), symbol.getName());
writeOutputType(outputType.getName(), operationIndex.getOutput(operation), symbol.getName());
writer.write("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import software.amazon.smithy.model.knowledge.TopDownIndex;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.traits.DocumentationTrait;
import software.amazon.smithy.model.traits.PaginatedTrait;
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator;
import software.amazon.smithy.utils.SmithyInternalApi;
Expand All @@ -45,6 +46,12 @@ static void writeIndex(
ProtocolGenerator protocolGenerator,
TypeScriptWriter writer
) {

writer.write("/* eslint-disable */");
settings.getService(model).getTrait(DocumentationTrait.class).ifPresent(trait ->
writer.writeDocs(trait.getValue() + "\n\n" + "@packageDocumentation"));


if (settings.generateClient()) {
writeClientExports(settings, model, symbolProvider, writer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static String getResolvedConfigTypeName(Symbol symbol) {
@Override
public void run() {
writer.addImport("Client", "__Client", "@aws-sdk/smithy-client");
writer.write("export { __Client }\n");
writer.addImport("getRuntimeConfig", "__getRuntimeConfig",
Paths.get(".", CodegenUtils.SOURCE_FOLDER, "runtimeConfig").toString());

Expand Down Expand Up @@ -162,7 +163,7 @@ private void generateConfig() {
writer.writeDocs("@public");
// The default configuration type is always just the base-level
// Smithy configuration requirements.
writer.write("type $LType = Partial<__SmithyConfiguration<$T>>", configType,
writer.write("export type $LType = Partial<__SmithyConfiguration<$T>>", configType,
applicationProtocol.getOptionsType());
writer.write(" & ClientDefaults");

Expand Down Expand Up @@ -197,7 +198,7 @@ private void generateConfig() {
// each "Input" configuration type.
writer.write("");
writer.writeDocs("@public");
writer.write("type $LType = __SmithyResolvedConfiguration<$T>",
writer.write("export type $LType = __SmithyResolvedConfiguration<$T>",
resolvedConfigType, applicationProtocol.getOptionsType());
writer.write(" & Required<ClientDefaults>");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private void writeAdditionalFiles(
TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
writer.addImport("ServiceExceptionOptions", "__ServiceExceptionOptions",
TypeScriptDependency.AWS_SMITHY_CLIENT.packageName);
// Export ServiceException information to allow
// documentation inheritance to consume their types
writer.write("export { __ServiceException, __ServiceExceptionOptions }\n");
writer.writeDocs("@public\n\nBase exception class for all service exceptions from "
+ serviceName + " service.");
writer.openBlock("export class $L extends __ServiceException {", serviceExceptionName);
Expand Down

0 comments on commit 988ad4c

Please sign in to comment.