Skip to content

Commit 310e845

Browse files
committed
Use doc comment syntax for request comment blocks
1 parent d5fdf0a commit 310e845

File tree

5 files changed

+96
-84
lines changed

5 files changed

+96
-84
lines changed

include/ClientGenerator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Generator
4141
const std::string& getClientNamespace() const noexcept;
4242

4343
bool outputHeader() const noexcept;
44+
void outputRequestComment(std::ostream& headerFile) const noexcept;
4445
void outputGetRequestDeclaration(std::ostream& headerFile) const noexcept;
4546
bool outputResponseFieldType(std::ostream& headerFile, const ResponseField& responseField,
4647
size_t indent = 0) const noexcept;

samples/client/MutateClient.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,26 @@ static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen:
2626
#include <string>
2727
#include <vector>
2828

29-
namespace graphql::mutation::CompleteTaskMutation {
3029

31-
/** Operation: mutation CompleteTaskMutation
32-
**
33-
** # Copyright (c) Microsoft Corporation. All rights reserved.
34-
** # Licensed under the MIT License.
35-
**
36-
** mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}) {
37-
** completedTask: completeTask(input: $input) {
38-
** completedTask: task {
39-
** completedTaskId: id
40-
** title
41-
** isComplete
42-
** }
43-
** clientMutationId
44-
** }
45-
** }
46-
**
47-
**/
30+
/// <summary>
31+
/// Operation: mutation CompleteTaskMutation
32+
/// </summary>
33+
/// <code class="language-graphql">
34+
/// # Copyright (c) Microsoft Corporation. All rights reserved.
35+
/// # Licensed under the MIT License.
36+
///
37+
/// mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}) {
38+
/// completedTask: completeTask(input: $input) {
39+
/// completedTask: task {
40+
/// completedTaskId: id
41+
/// title
42+
/// isComplete
43+
/// }
44+
/// clientMutationId
45+
/// }
46+
/// }
47+
/// </code>
48+
namespace graphql::mutation::CompleteTaskMutation {
4849

4950
// Return the original text of the request document.
5051
const std::string& GetRequestText() noexcept;

samples/client/QueryClient.h

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,51 +26,52 @@ static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen:
2626
#include <string>
2727
#include <vector>
2828

29-
namespace graphql::query::Query {
3029

31-
/** Operation: query (default)
32-
**
33-
** # Copyright (c) Microsoft Corporation. All rights reserved.
34-
** # Licensed under the MIT License.
35-
**
36-
** query {
37-
** appointments {
38-
** edges {
39-
** node {
40-
** id
41-
** subject
42-
** when
43-
** isNow
44-
** __typename
45-
** }
46-
** }
47-
** }
48-
** tasks {
49-
** edges {
50-
** node {
51-
** id
52-
** title
53-
** isComplete
54-
** __typename
55-
** }
56-
** }
57-
** }
58-
** unreadCounts {
59-
** edges {
60-
** node {
61-
** id
62-
** name
63-
** unreadCount
64-
** __typename
65-
** }
66-
** }
67-
** }
68-
**
69-
** # Read a field with an enum type
70-
** testTaskState
71-
** }
72-
**
73-
**/
30+
/// <summary>
31+
/// Operation: query (default)
32+
/// </summary>
33+
/// <code class="language-graphql">
34+
/// # Copyright (c) Microsoft Corporation. All rights reserved.
35+
/// # Licensed under the MIT License.
36+
///
37+
/// query {
38+
/// appointments {
39+
/// edges {
40+
/// node {
41+
/// id
42+
/// subject
43+
/// when
44+
/// isNow
45+
/// __typename
46+
/// }
47+
/// }
48+
/// }
49+
/// tasks {
50+
/// edges {
51+
/// node {
52+
/// id
53+
/// title
54+
/// isComplete
55+
/// __typename
56+
/// }
57+
/// }
58+
/// }
59+
/// unreadCounts {
60+
/// edges {
61+
/// node {
62+
/// id
63+
/// name
64+
/// unreadCount
65+
/// __typename
66+
/// }
67+
/// }
68+
/// }
69+
///
70+
/// # Read a field with an enum type
71+
/// testTaskState
72+
/// }
73+
/// </code>
74+
namespace graphql::query::Query {
7475

7576
// Return the original text of the request document.
7677
const std::string& GetRequestText() noexcept;

samples/client/SubscribeClient.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@ static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen:
2626
#include <string>
2727
#include <vector>
2828

29-
namespace graphql::subscription::TestSubscription {
3029

31-
/** Operation: subscription TestSubscription
32-
**
33-
** # Copyright (c) Microsoft Corporation. All rights reserved.
34-
** # Licensed under the MIT License.
35-
**
36-
** subscription TestSubscription {
37-
** nextAppointment: nextAppointmentChange {
38-
** nextAppointmentId: id
39-
** when
40-
** subject
41-
** isNow
42-
** }
43-
** }
44-
**
45-
**/
30+
/// <summary>
31+
/// Operation: subscription TestSubscription
32+
/// </summary>
33+
/// <code class="language-graphql">
34+
/// # Copyright (c) Microsoft Corporation. All rights reserved.
35+
/// # Licensed under the MIT License.
36+
///
37+
/// subscription TestSubscription {
38+
/// nextAppointment: nextAppointmentChange {
39+
/// nextAppointmentId: id
40+
/// when
41+
/// subject
42+
/// isNow
43+
/// }
44+
/// }
45+
/// </code>
46+
namespace graphql::subscription::TestSubscription {
4647

4748
// Return the original text of the request document.
4849
const std::string& GetRequestText() noexcept;

src/ClientGenerator.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ static_assert(graphql::internal::MinorVersion == )cpp"
165165
166166
)cpp";
167167

168+
outputRequestComment(headerFile);
169+
168170
NamespaceScope clientNamespaceScope { headerFile, getClientNamespace() };
169171
PendingBlankLine pendingSeparator { headerFile };
170172

@@ -281,25 +283,31 @@ Response parseResponse(response::Value&& response);
281283
return true;
282284
}
283285

284-
void Generator::outputGetRequestDeclaration(std::ostream& headerFile) const noexcept
286+
void Generator::outputRequestComment(std::ostream& headerFile) const noexcept
285287
{
286288
headerFile << R"cpp(
287-
/** Operation: )cpp"
289+
/// <summary>
290+
/// Operation: )cpp"
288291
<< _requestLoader.getOperationType() << ' '
289292
<< _requestLoader.getOperationDisplayName() << R"cpp(
290-
**
293+
/// </summary>
294+
/// <code class="language-graphql">
291295
)cpp";
292296

293297
std::istringstream request { std::string { _requestLoader.getRequestText() } };
294298

295299
for (std::string line; std::getline(request, line);)
296300
{
297-
headerFile << R"cpp( ** )cpp" << line << std::endl;
301+
headerFile << R"cpp(/// )cpp" << line << std::endl;
298302
}
299303

300-
headerFile << R"cpp( **
301-
**/
304+
headerFile << R"cpp(/// </code>
305+
)cpp";
306+
}
302307

308+
void Generator::outputGetRequestDeclaration(std::ostream& headerFile) const noexcept
309+
{
310+
headerFile << R"cpp(
303311
// Return the original text of the request document.
304312
const std::string& GetRequestText() noexcept;
305313

0 commit comments

Comments
 (0)