Skip to content

Commit 0e79403

Browse files
authored
impl(docfx): use typealias for typedefs (#11541)
DocFX recognizes `typealias` as, well, aliases for types. A separate PR tweaks it to support typealiases in namespaces, but these changes make the aliases visible in the generated documentation.
1 parent b68a1e9 commit 0e79403

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

docfx/doxygen2syntax.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,9 @@ void AppendTypedefSyntax(YAML::Emitter& yaml, YamlContext const& ctx,
308308
yaml << YAML::Key << "syntax" << YAML::Value //
309309
<< YAML::BeginMap //
310310
<< YAML::Key << "contents" << YAML::Value << YAML::Literal //
311-
<< TypedefSyntaxContent(node);
311+
<< TypedefSyntaxContent(node) //
312+
<< YAML::Key << "aliasof" << YAML::Value << YAML::DoubleQuoted
313+
<< HtmlEscape(LinkedTextType(node.child("type")));
312314
AppendLocation(yaml, ctx, node, "name");
313315
yaml << YAML::EndMap;
314316
}

docfx/doxygen2syntax_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ TEST(Doxygen2Syntax, Typedef) {
547547
contents: |
548548
using google::cloud::BackgroundThreadsFactory =
549549
std::function< std::unique_ptr< BackgroundThreads >()>;
550+
aliasof: "std::function&lt; std::unique_ptr&lt; BackgroundThreads &gt;()&gt;"
550551
source:
551552
id: BackgroundThreadsFactory
552553
path: google/cloud/grpc_options.h

docfx/doxygen2yaml.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ bool AppendIfTypedef(YAML::Emitter& yaml, YamlContext const& ctx,
211211
std::string_view{node.child("qualifiedname").child_value()};
212212
yaml << YAML::BeginMap //
213213
<< YAML::Key << "uid" << YAML::Value << id //
214-
<< YAML::Key << "name" << YAML::Value << YAML::Literal << name //
214+
<< YAML::Key << "name" << YAML::Value << YAML::DoubleQuoted << name //
215215
<< YAML::Key << "fullName" //
216-
<< YAML::Value << YAML::Literal << full_name //
216+
<< YAML::Value << YAML::DoubleQuoted << full_name //
217217
<< YAML::Key << "id" << YAML::Value << id //
218218
<< YAML::Key << "parent" << YAML::Value << ctx.parent_id //
219-
<< YAML::Key << "type" << YAML::Value << "typedef" //
219+
<< YAML::Key << "type" << YAML::Value << "typealias" //
220220
<< YAML::Key << "langs" << YAML::BeginSeq << "cpp" << YAML::EndSeq; //
221221
AppendTypedefSyntax(yaml, ctx, node);
222222
AppendDescription(yaml, node);

docfx/doxygen2yaml_test.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -551,19 +551,18 @@ TEST(Doxygen2Yaml, Typedef) {
551551
auto constexpr kExpected = R"yml(### YamlMime:UniversalReference
552552
items:
553553
- uid: namespacegoogle_1_1cloud_1a1498c1ea55d81842f37bbc42d003df1f
554-
name: |
555-
BackgroundThreadsFactory
556-
fullName: |
557-
google::cloud::BackgroundThreadsFactory
554+
name: "BackgroundThreadsFactory"
555+
fullName: "google::cloud::BackgroundThreadsFactory"
558556
id: namespacegoogle_1_1cloud_1a1498c1ea55d81842f37bbc42d003df1f
559557
parent: test-only-parent-id
560-
type: typedef
558+
type: typealias
561559
langs:
562560
- cpp
563561
syntax:
564562
contents: |
565563
using google::cloud::BackgroundThreadsFactory =
566564
std::function< std::unique_ptr< BackgroundThreads >()>;
565+
aliasof: "std::function&lt; std::unique_ptr&lt; BackgroundThreads &gt;()&gt;"
567566
source:
568567
id: BackgroundThreadsFactory
569568
path: google/cloud/grpc_options.h
@@ -842,19 +841,18 @@ TEST(Doxygen2Yaml, SectionDef) {
842841
auto constexpr kExpected = R"yml(### YamlMime:UniversalReference
843842
items:
844843
- uid: structgoogle_1_1cloud_1_1AccessTokenLifetimeOption_1ad6b8a4672f1c196926849229f62d0de2
845-
name: |
846-
Type
847-
fullName: |
848-
google::cloud::AccessTokenLifetimeOption::Type
844+
name: "Type"
845+
fullName: "google::cloud::AccessTokenLifetimeOption::Type"
849846
id: structgoogle_1_1cloud_1_1AccessTokenLifetimeOption_1ad6b8a4672f1c196926849229f62d0de2
850847
parent: test-only-parent-id
851-
type: typedef
848+
type: typealias
852849
langs:
853850
- cpp
854851
syntax:
855852
contents: |
856853
using google::cloud::AccessTokenLifetimeOption::Type =
857854
std::chrono::seconds;
855+
aliasof: "std::chrono::seconds"
858856
source:
859857
id: Type
860858
path: google/cloud/credentials.h

0 commit comments

Comments
 (0)