Skip to content

Commit 80bfd62

Browse files
authored
impl(docfx): weave syntax in existing YAML (#11160)
1 parent 4535334 commit 80bfd62

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

docfx/doxygen2yaml.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "docfx/doxygen2yaml.h"
1616
#include "docfx/doxygen2markdown.h"
17+
#include "docfx/doxygen2syntax.h"
1718
#include "docfx/doxygen_errors.h"
1819
#include "docfx/yaml_emit.h"
1920
#include <sstream>
@@ -135,6 +136,7 @@ bool AppendIfEnum(YAML::Emitter& yaml, YamlContext const& ctx,
135136
<< YAML::Key << "parent" << YAML::Value << ctx.parent_id //
136137
<< YAML::Key << "type" << YAML::Value << "enum" //
137138
<< YAML::Key << "langs" << YAML::BeginSeq << "cpp" << YAML::EndSeq; //
139+
AppendEnumSyntax(yaml, ctx, node);
138140
auto const summary = Summary(node);
139141
if (!summary.empty()) {
140142
yaml << YAML::Key << "summary" << YAML::Value << YAML::Literal << summary;
@@ -164,6 +166,7 @@ bool AppendIfTypedef(YAML::Emitter& yaml, YamlContext const& ctx,
164166
<< YAML::Key << "parent" << YAML::Value << ctx.parent_id //
165167
<< YAML::Key << "type" << YAML::Value << "typedef" //
166168
<< YAML::Key << "langs" << YAML::BeginSeq << "cpp" << YAML::EndSeq; //
169+
AppendTypedefSyntax(yaml, ctx, node);
167170
auto const summary = Summary(node);
168171
if (!summary.empty()) {
169172
yaml << YAML::Key << "summary" << YAML::Value << YAML::Literal << summary;

docfx/doxygen2yaml_test.cc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ TEST(Doxygen2Yaml, Enum) {
217217
type: enum
218218
langs:
219219
- cpp
220+
syntax:
221+
contents: |
222+
enum class google::cloud::Idempotency {
223+
kIdempotent,
224+
kNonIdempotent,
225+
};
226+
source:
227+
id: Idempotency
228+
path: google/cloud/idempotency.h
229+
startLine: 55
230+
remote:
231+
repo: https://github.com/googleapis/google-cloud-cpp/
232+
branch: main
233+
path: google/cloud/idempotency.h
220234
summary: |
221235
Whether a request is [idempotent](https://en.wikipedia.org/wiki/Idempotence).
222236
@@ -315,6 +329,18 @@ TEST(Doxygen2Yaml, Typedef) {
315329
type: typedef
316330
langs:
317331
- cpp
332+
syntax:
333+
contents: |
334+
using google::cloud::BackgroundThreadsFactory =
335+
std::function< std::unique_ptr< BackgroundThreads >()>;
336+
source:
337+
id: BackgroundThreadsFactory
338+
path: google/cloud/grpc_options.h
339+
startLine: 148
340+
remote:
341+
repo: https://github.com/googleapis/google-cloud-cpp/
342+
branch: main
343+
path: google/cloud/grpc_options.h
318344
summary: |
319345
A short description of the thing.
320346
@@ -350,6 +376,18 @@ TEST(Doxygen2Yaml, SectionDef) {
350376
type: typedef
351377
langs:
352378
- cpp
379+
syntax:
380+
contents: |
381+
using google::cloud::AccessTokenLifetimeOption::Type =
382+
std::chrono::seconds;
383+
source:
384+
id: Type
385+
path: google/cloud/credentials.h
386+
startLine: 301
387+
remote:
388+
repo: https://github.com/googleapis/google-cloud-cpp/
389+
branch: main
390+
path: google/cloud/credentials.h
353391
)yml";
354392

355393
pugi::xml_document doc;

0 commit comments

Comments
 (0)