Skip to content

Commit 28fc4ad

Browse files
authored
feat(docfx): support Doxygen 1.9.7 output (#13852)
1 parent 539e120 commit 28fc4ad

3 files changed

Lines changed: 60 additions & 4 deletions

File tree

docfx/README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ git clone https://github.com/microsoft/vcpkg.git $HOME/vcpkg
3838

3939
```
4040
cd google-cloud-cpp
41-
cmake -S . -B .build -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
42-
PUBLISH=$PWD/build-out/fedora-latest-cmake-publish-docs/cmake-out/google/cloud
43-
cmake --build .build/ --target docfx/all \
41+
cmake -GNinja -S . -B build-out/.docfx -DGOOGLE_CLOUD_CPP_INTERNAL_DOCFX=ON \
42+
--toolchain $HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
43+
PUBLISH=$PWD/build-out/fedora-latest-publish-docs/publish-docs/__default__/cmake-out/google/cloud
44+
cmake --build build-out/.docfx --target docfx/all \
4445
&& rm -f $HOME/doc-pipeline/testdata/cpp/* \
45-
&& env -C $HOME/doc-pipeline/testdata/cpp $PWD/.build/docfx/doxygen2docfx $PUBLISH/xml/cloud.doxygen.xml cloud 2.9.0
46+
&& env -C $HOME/doc-pipeline/testdata/cpp $PWD/build-out/.docfx/docfx/doxygen2docfx $PUBLISH/xml/cloud.doxygen.xml cloud 2.9.0
4647
```
4748

4849
### Run the DocFX pipeline over the generated files
@@ -85,3 +86,14 @@ env -C $HOME/doc-pipeline \
8586
TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/docfx \
8687
TRAMPOLINE_DOCKERFILE=docfx/Dockerfile ci/trampoline_v2.sh
8788
```
89+
90+
## Detecting Doxygen schema changes
91+
92+
From time to time we update Doxygen and that may result in schema changes.
93+
Detecting these changes may be useful to design the corresponding changes to the
94+
`doxygen2docfx` tool.
95+
96+
The schema definition can be found in the [Doxygen GitHub Repository]. Look for
97+
[xml/compound.xsd](https://github.com/doxygen/doxygen/blob/master/templates/xml/compound.xsd)
98+
99+
[doxygen github repository]: https://github.com/doxygen/doxygen

docfx/doxygen2yaml.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ bool IgnoreForRecurse(pugi::xml_node node) {
5959
// This is a title for a sectionref (a "group" of member functions),
6060
// maybe we can add this to break down each compound ToC.
6161
"header",
62+
// Starting with Doxygen 1.9.7 any namespace members that are defined
63+
// in a group appear as `member` children in the namespace, with just a
64+
// `refid` pointing to its location. We need to skip these. They lack
65+
// enough information to create a valid YAML element describing them.
66+
"member",
6267
};
6368
}();
6469
auto const name = std::string{node.name()};

docfx/doxygen2yaml_test.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,45 @@ TEST(Doxygen2Yaml, NamespaceDeprecated) {
10791079
EXPECT_EQ(actual, kExpected);
10801080
}
10811081

1082+
TEST(Doxygen2Yaml, NamespaceMemberRefid) {
1083+
auto constexpr kXml =
1084+
R"xml(<?xml version='1.0' encoding='UTF-8' standalone='no'?>
1085+
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.9.7" xml:lang="en-US">
1086+
<compounddef id="namespacegoogle_1_1cloud" kind="namespace" language="C++">
1087+
<compoundname>google::cloud</compoundname>
1088+
<member refid="group__terminate_1gacc215b41a0bf17a7ea762fd5bb205348" kind="typedef"><name>TerminateHandler</name></member>
1089+
</compounddef>
1090+
</doxygen>)xml";
1091+
1092+
auto constexpr kExpected = R"yml(### YamlMime:UniversalReference
1093+
items:
1094+
- uid: namespacegoogle_1_1cloud
1095+
name: "google::cloud"
1096+
id: namespacegoogle_1_1cloud
1097+
parent: test-only-parent-id
1098+
type: namespace
1099+
langs:
1100+
- cpp
1101+
syntax:
1102+
contents: |
1103+
namespace google::cloud { ... };
1104+
)yml";
1105+
1106+
pugi::xml_document doc;
1107+
doc.load_string(kXml);
1108+
auto selected = doc.select_node("//*[@id='namespacegoogle_1_1cloud']");
1109+
ASSERT_TRUE(selected);
1110+
YAML::Emitter yaml;
1111+
TestPre(yaml);
1112+
YamlContext ctx;
1113+
ctx.parent_id = "test-only-parent-id";
1114+
ctx.library_root = "google/cloud";
1115+
ASSERT_TRUE(AppendIfNamespace(yaml, ctx, selected.node()));
1116+
TestPost(yaml);
1117+
auto const actual = EndDocFxYaml(yaml);
1118+
EXPECT_EQ(actual, kExpected);
1119+
}
1120+
10821121
TEST(Doxygen2Yaml, Class) {
10831122
auto constexpr kExpected = R"yml(### YamlMime:UniversalReference
10841123
items:

0 commit comments

Comments
 (0)