From db0f2c90089ec19115255ad320afc292e57407ec Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Wed, 10 Apr 2024 09:42:09 -0700 Subject: [PATCH] Add docs to generated cpp code (#12) --- .../eventstreamrpc/cpp/client/Client.h.ftl | 7 ++++ .../cpp/model/macros/StructUnion.h.ftl | 37 +++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/client/Client.h.ftl b/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/client/Client.h.ftl index 0bb26eb..ec66dbd 100644 --- a/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/client/Client.h.ftl +++ b/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/client/Client.h.ftl @@ -44,6 +44,13 @@ using namespace Aws::Eventstreamrpc; <#list operations as operation> <#assign OperationPascalCaseName = operation.getId().getName()/> +<#if operation.hasTrait("documentation")> + /** + <#list operation.findTrait("documentation").get().getValue()?split("\n") as docLine> + * ${docLine} + + */ + <#if context.getOutputEventStreamInfo(operation).isPresent()> std::shared_ptr<${OperationPascalCaseName}Operation> New${OperationPascalCaseName}(std::shared_ptr<${OperationPascalCaseName}StreamHandler> streamHandler) noexcept; <#else> diff --git a/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/model/macros/StructUnion.h.ftl b/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/model/macros/StructUnion.h.ftl index b404a54..5894ef8 100644 --- a/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/model/macros/StructUnion.h.ftl +++ b/smithy-event-stream-rpc-cpp/src/main/resources/software/amazon/smithy/eventstreamrpc/cpp/model/macros/StructUnion.h.ftl @@ -14,6 +14,9 @@ <#else> <#local BaseClass = "AbstractShapeBase"/> +<#if convertedShape.hasTrait("documentation")> +<@placeIndents quantity=indents/>/** ${convertedShape.findTrait("documentation").get().getValue()} */ + <@placeIndents quantity=indents/>class ${export} ${PascalCaseMemberName} : public ${BaseClass} <@placeIndents quantity=indents/>{ <@placeIndents quantity=indents/> public: @@ -29,31 +32,30 @@ <#local PascalCase = fn_camel_to_pascal.apply(memberShape.getMemberName())> <#local camelCase = memberShape.getMemberName()> <#local memberTargetShape = context.getShape(memberShape.getTarget())> + <#local memberDocMessage = ""> + <#if memberShape.hasTrait("documentation")> + <#local memberDocMessage += " * " + memberShape.findTrait("documentation").get().getValue() + "\n"> + <#if memberShape.hasTrait("deprecated")> - <#local deprecationMessage = "/* Deprecated"> + <#local memberDocMessage += " * @deprecated"> <#if memberShape.findTrait("deprecated").get().getSince().isPresent()> - <#local deprecationMessage = deprecationMessage + " in " + memberShape.findTrait("deprecated").get().getSince().get()> + <#local memberDocMessage += " in " + memberShape.findTrait("deprecated").get().getSince().get()> <#if memberShape.findTrait("deprecated").get().getMessage().isPresent()> - <#local deprecationMessage = deprecationMessage + " " + memberShape.findTrait("deprecated").get().getMessage().get()> + <#local memberDocMessage += " " + memberShape.findTrait("deprecated").get().getMessage().get()> - <#local deprecationMessage = deprecationMessage + " */"> -<@placeIndents quantity=indents/> ${deprecationMessage} + <#local memberDocMessage += "\n"> - <#if memberTargetShape.hasTrait("documentation")> - <#local docMessage = "/* " + memberTargetShape.findTrait("documentation").get().getValue() + " */"> -<@placeIndents quantity=indents/> ${docMessage} + <#if memberDocMessage?length gt 0> + <#local memberDocMessage = "/**\n" + memberDocMessage + " */"> <#if memberTargetShape.hasTrait("enum")> +<@placeIndents quantity=indents/> ${memberDocMessage} <@placeIndents quantity=indents/> void Set${PascalCase}(${memberTargetShape.getId().name} ${camelCase}) noexcept; - <#if memberShape.hasTrait("deprecated")> -<@placeIndents quantity=indents/> ${deprecationMessage} - - <#if memberTargetShape.hasTrait("documentation")> -<@placeIndents quantity=indents/> ${docMessage} - +<@placeIndents quantity=indents/> ${memberDocMessage} <@placeIndents quantity=indents/> Aws::Crt::Optional<${memberTargetShape.getId().name}> Get${PascalCase}() noexcept; <#else> +<@placeIndents quantity=indents/> ${memberDocMessage} <@placeIndents quantity=indents/> void Set${PascalCase}(const ${context.getTypeName(memberShape)}& ${camelCase}) noexcept { <#if shape.getDataShape().get().getType().name() == "UNION"> <@placeIndents quantity=indents/> m_${camelCase} = ${camelCase}; @@ -62,12 +64,7 @@ <@placeIndents quantity=indents/> m_${camelCase} = ${camelCase}; <@placeIndents quantity=indents/> } - <#if memberShape.hasTrait("deprecated")> -<@placeIndents quantity=indents/> ${deprecationMessage} - - <#if memberTargetShape.hasTrait("documentation")> -<@placeIndents quantity=indents/> ${docMessage} - +<@placeIndents quantity=indents/> ${memberDocMessage} <#if convertedShape.hasTrait("error") && PascalCase == "Message"> <@placeIndents quantity=indents/> Aws::Crt::Optional<${context.getTypeName(memberShape)}> Get${PascalCase}() noexcept override { <#else>