[PATCH] D65690: [clang-doc] Add index in each info html file
This revision was automatically updated to reflect the committed changes. Closed by commit rL368070: [clang-doc] Add index in each info html file (authored by DiegoAstiazaran, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D65690?vs=213513&id=213669#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 Files: clang-tools-extra/trunk/clang-doc/Generators.cpp clang-tools-extra/trunk/clang-doc/Generators.h clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp clang-tools-extra/trunk/clang-doc/MDGenerator.cpp clang-tools-extra/trunk/clang-doc/Representation.cpp clang-tools-extra/trunk/clang-doc/Representation.h clang-tools-extra/trunk/clang-doc/YAMLGenerator.cpp clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css clang-tools-extra/trunk/clang-doc/assets/index.js clang-tools-extra/trunk/clang-doc/stylesheets/clang-doc-default-stylesheet.css clang-tools-extra/trunk/clang-doc/tool/CMakeLists.txt clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.cpp clang-tools-extra/trunk/unittests/clang-doc/ClangDocTest.h clang-tools-extra/trunk/unittests/clang-doc/GeneratorTest.cpp clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp Index: clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css === --- clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css +++ clang-tools-extra/trunk/clang-doc/assets/clang-doc-default-stylesheet.css @@ -0,0 +1,205 @@ +body,div { + margin: 0; + padding: 0; +} + +body[no-overflow] { + overflow: hidden; +} + +li>p:first-child { + margin-top: 0; +} + +li>p:last-child { + margin-bottom: 0; +} + +html { + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +*,*::before,*::after { + -webkit-box-sizing: inherit; + box-sizing: inherit; +} + +body,html { + color: #202124; + font: 400 16px/24px Roboto,sans-serif; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + height: 100%; + margin: 36px; + -webkit-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + text-size-adjust: 100%; +} + +body[devsite-framebox] { + overflow: hidden; + padding: 20px; +} + +body[sitemask--active] { + overflow: hidden; +} + +p { + margin: 16px 0; + padding: 0; +} + +:link,:visited { + color: #039be5; + outline: 0; + text-decoration: none; +} + +ul { + margin: 0; + padding-left: 40px; +} + +ul { + list-style: disc outside; +} + +li,li p { + margin: 12px 0; + padding: 0; +} + +*[visually-hidden] { + opacity: 0 !important; + pointer-events: none !important; + visibility: hidden !important; +} + +*[hidden] { + display: none !important; +} + +[render-hidden] { + display: inline !important; + position: absolute !important; + visibility: hidden !important; +} + +*[no-scroll] { + overflow: hidden; +} + +@supports (display: flex) { + body[ready] .devsite-wrapper { +display: -webkit-box; +display: -ms-flexbox; +display: flex; +-webkit-box-orient: vertical; +-webkit-box-direction: normal; +-ms-flex-direction: column; +flex-direction: column; + } +} + +@media screen and (max-width: 840px) { + body[devsite-book-nav--open] { +overflow: hidden; + } +} + +h1,h2,h3,h4,h5,h6 { + overflow: hidden; + padding: 0; + text-overflow: ellipsis; +} + +h1 { + color: #80868b; + font: 300 34px/40px Roboto,sans-serif; + letter-spacing: -0.01em; + margin: 40px 0 20px; +} + +[layout=docs] h2 { + border-bottom: 1px solid #e8eaed; + padding-bottom: 3px; +} + +h2 { + font: 300 24px/32px Roboto,sans-serif; + letter-spacing: -0.01em; + margin: 40px 0 20px; +} + +h3 { + font: 400 20px/32px Roboto,sans-serif; + margin: 32px 0 16px; +} + +h4,h5,h6 { + margin: 32px 0 16px; +} + +h4 { + font: 500 16px/24px Roboto,sans-serif; +} + +h5 { + font: 700 14px/24px Roboto,sans-serif; +} + +h6 { + font: 500 14px/24px Roboto,sans-serif; +} + +h1+h1,h1+h2,h1+h3,h1+h4,h1+h5,h1+h6,h2+h1,h2+h2,h2+h3,h2+h4,h2+h5,h2+h6,h3+h1,h3+h2,h3+h3,h3+h4,h3+h5,h3+h6,h4+h1,h4+h2,h4+h3,h4+h4,h4+h5,h4+h6,h5+h1,h5+h2,h5+h3,h5+h4,h5+h5,h5+h6,h6+h1,h6+h2,h6+h3,h6+h4,h6+h5,h6+h6 { + margin-top: 0; +} + +@media screen and (max-width: 600px) { + h1 { +font: 300 24px/32px Roboto,sans-serif; + } +} + +[scrollbars]::-webkit-scrollbar { + height: 8px; + width: 8px; +} + +[scrollbars]::-webkit-scrollbar-thumb { + background: rgba(128,134,139,.26); + border-radius: 8px; +} + +[no-horizontal-scrollbars]::-webkit-scrollbar { + height: 0; + width: 0; +} + +[scrollbars]::-webkit-scrollbar-corner { + background: 0; +} + +[background] h2 { + color: #fff; +} + +@media print { + body, html,
[PATCH] D65690: [clang-doc] Add index in each info html file
juliehockett accepted this revision. juliehockett added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65690: [clang-doc] Add index in each info html file
DiegoAstiazaran added inline comments. Comment at: clang-tools-extra/clang-doc/Generators.cpp:79 + +bool Generator::createResources(ClangDocContext &CDCtx) { + std::error_code OK; juliehockett wrote: > Why is this implementation in the generic Generator? It's fairly > HTML-specific -- neither of the other generators are able to parse and > include Javascript (since this does include the `var JsonIndex` bit). Moved to HTMLGenerator.cpp; it was there because I was first writing a JSON file which could be used for any generator. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65690: [clang-doc] Add index in each info html file
DiegoAstiazaran updated this revision to Diff 213513. DiegoAstiazaran marked 3 inline comments as done. DiegoAstiazaran added a comment. Moved serialization of Index to HTML generator. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 Files: clang-tools-extra/clang-doc/Generators.cpp clang-tools-extra/clang-doc/Generators.h clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/MDGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/YAMLGenerator.cpp clang-tools-extra/clang-doc/assets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/assets/index.js clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/unittests/clang-doc/CMakeLists.txt clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp clang-tools-extra/unittests/clang-doc/ClangDocTest.h clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp === --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -28,6 +28,7 @@ CDCtx.UserStylesheets.insert( CDCtx.UserStylesheets.begin(), "../share/clang/clang-doc-default-stylesheet.css"); + CDCtx.JsScripts.emplace_back("index.js"); return CDCtx; } @@ -56,6 +57,8 @@ namespace Namespace + + namespace Namespace Namespaces @@ -114,6 +117,8 @@ class r + + class r Defined at line 10 of test.cpp @@ -175,6 +180,8 @@ + + f @@ -212,6 +219,8 @@ + + enum class e @@ -281,6 +290,8 @@ + + f void f(int I, int J) Index: clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp === --- /dev/null +++ clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp @@ -0,0 +1,74 @@ +//===-- clang-doc/GeneratorTest.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "Serialize.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +TEST(GeneratorTest, emitIndex) { + Index Idx; + auto InfoA = llvm::make_unique(); + InfoA->Name = "A"; + InfoA->USR = serialize::hashUSR("1"); + Generator::addInfoToIndex(Idx, InfoA.get()); + auto InfoC = llvm::make_unique(); + InfoC->Name = "C"; + InfoC->USR = serialize::hashUSR("3"); + Reference RefB = Reference("B"); + RefB.USR = serialize::hashUSR("2"); + InfoC->Namespace = {std::move(RefB)}; + Generator::addInfoToIndex(Idx, InfoC.get()); + auto InfoD = llvm::make_unique(); + InfoD->Name = "D"; + InfoD->USR = serialize::hashUSR("4"); + auto InfoF = llvm::make_unique(); + InfoF->Name = "F"; + InfoF->USR = serialize::hashUSR("6"); + Reference RefD = Reference("D"); + RefD.USR = serialize::hashUSR("4"); + Reference RefE = Reference("E"); + RefE.USR = serialize::hashUSR("5"); + InfoF->Namespace = {std::move(RefE), std::move(RefD)}; + Generator::addInfoToIndex(Idx, InfoF.get()); + auto InfoG = llvm::make_unique(InfoType::IT_namespace); + Generator::addInfoToIndex(Idx, InfoG.get()); + + Index ExpectedIdx; + Index IndexA; + IndexA.Name = "A"; + ExpectedIdx.Children.emplace_back(std::move(IndexA)); + Index IndexB; + IndexB.Name = "B"; + Index IndexC; + IndexC.Name = "C"; + IndexB.Children.emplace_back(std::move(IndexC)); + ExpectedIdx.Children.emplace_back(std::move(IndexB)); + Index IndexD; + IndexD.Name = "D"; + Index IndexE; + IndexE.Name = "E"; + Index IndexF; + IndexF.Name = "F"; + IndexE.Children.emplace_back(std::move(IndexF)); + IndexD.Children.emplace_back(std::move(IndexE)); + ExpectedIdx.Children.emplace_back(std::move(IndexD)); + Index IndexG; + IndexG.Name = "GlobalNamespace"; + IndexG.RefType = InfoType::IT_namespace; + ExpectedIdx.Children.emplace_back(std::move(IndexG)); + + CheckIndex(ExpectedIdx, Idx); +} + +} // namespace doc +} // namespace clang Index: clang-tools-extra/unittests/clang-doc/ClangDocTest.h === --- clang-tools-extra/unittests/clang-doc/ClangDocTest.h +++ clang-tools-extra/unittests/clang-doc/ClangDocTest.h @@ -44,6 +44,8 @@ void CheckNamespaceInfo(NamespaceInfo *Expected, NamespaceInfo *Actual); void CheckRecordInfo(RecordInfo *Expected, Rec
[PATCH] D65690: [clang-doc] Add index in each info html file
juliehockett added inline comments. Comment at: clang-tools-extra/clang-doc/Generators.cpp:79 + +bool Generator::createResources(ClangDocContext &CDCtx) { + std::error_code OK; Why is this implementation in the generic Generator? It's fairly HTML-specific -- neither of the other generators are able to parse and include Javascript (since this does include the `var JsonIndex` bit). Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:665 +return false; + llvm::outs() << "Generating assets for docs...\n"; + for (const auto &FilePath : CDCtx.UserStylesheets) Can we move this to `ClangDocMain.cpp` right above where the function is called? That's where most of these types of status updates are. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65690: [clang-doc] Add index in each info html file
DiegoAstiazaran updated this revision to Diff 213171. DiegoAstiazaran marked 2 inline comments as done. DiegoAstiazaran added a comment. Fix format of index.js file CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 Files: clang-tools-extra/clang-doc/Generators.cpp clang-tools-extra/clang-doc/Generators.h clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/MDGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/YAMLGenerator.cpp clang-tools-extra/clang-doc/assets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/assets/index.js clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/unittests/clang-doc/CMakeLists.txt clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp clang-tools-extra/unittests/clang-doc/ClangDocTest.h clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp === --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -28,6 +28,7 @@ CDCtx.UserStylesheets.insert( CDCtx.UserStylesheets.begin(), "../share/clang/clang-doc-default-stylesheet.css"); + CDCtx.JsScripts.emplace_back("index.js"); return CDCtx; } @@ -56,6 +57,8 @@ namespace Namespace + + namespace Namespace Namespaces @@ -114,6 +117,8 @@ class r + + class r Defined at line 10 of test.cpp @@ -175,6 +180,8 @@ + + f @@ -212,6 +219,8 @@ + + enum class e @@ -281,6 +290,8 @@ + + f void f(int I, int J) Index: clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp === --- /dev/null +++ clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp @@ -0,0 +1,74 @@ +//===-- clang-doc/GeneratorTest.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "Serialize.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +TEST(GeneratorTest, emitIndex) { + Index Idx; + auto InfoA = llvm::make_unique(); + InfoA->Name = "A"; + InfoA->USR = serialize::hashUSR("1"); + Generator::addInfoToIndex(Idx, InfoA.get()); + auto InfoC = llvm::make_unique(); + InfoC->Name = "C"; + InfoC->USR = serialize::hashUSR("3"); + Reference RefB = Reference("B"); + RefB.USR = serialize::hashUSR("2"); + InfoC->Namespace = {std::move(RefB)}; + Generator::addInfoToIndex(Idx, InfoC.get()); + auto InfoD = llvm::make_unique(); + InfoD->Name = "D"; + InfoD->USR = serialize::hashUSR("4"); + auto InfoF = llvm::make_unique(); + InfoF->Name = "F"; + InfoF->USR = serialize::hashUSR("6"); + Reference RefD = Reference("D"); + RefD.USR = serialize::hashUSR("4"); + Reference RefE = Reference("E"); + RefE.USR = serialize::hashUSR("5"); + InfoF->Namespace = {std::move(RefE), std::move(RefD)}; + Generator::addInfoToIndex(Idx, InfoF.get()); + auto InfoG = llvm::make_unique(InfoType::IT_namespace); + Generator::addInfoToIndex(Idx, InfoG.get()); + + Index ExpectedIdx; + Index IndexA; + IndexA.Name = "A"; + ExpectedIdx.Children.emplace_back(std::move(IndexA)); + Index IndexB; + IndexB.Name = "B"; + Index IndexC; + IndexC.Name = "C"; + IndexB.Children.emplace_back(std::move(IndexC)); + ExpectedIdx.Children.emplace_back(std::move(IndexB)); + Index IndexD; + IndexD.Name = "D"; + Index IndexE; + IndexE.Name = "E"; + Index IndexF; + IndexF.Name = "F"; + IndexE.Children.emplace_back(std::move(IndexF)); + IndexD.Children.emplace_back(std::move(IndexE)); + ExpectedIdx.Children.emplace_back(std::move(IndexD)); + Index IndexG; + IndexG.Name = "GlobalNamespace"; + IndexG.RefType = InfoType::IT_namespace; + ExpectedIdx.Children.emplace_back(std::move(IndexG)); + + CheckIndex(ExpectedIdx, Idx); +} + +} // namespace doc +} // namespace clang Index: clang-tools-extra/unittests/clang-doc/ClangDocTest.h === --- clang-tools-extra/unittests/clang-doc/ClangDocTest.h +++ clang-tools-extra/unittests/clang-doc/ClangDocTest.h @@ -44,6 +44,8 @@ void CheckNamespaceInfo(NamespaceInfo *Expected, NamespaceInfo *Actual); void CheckRecordInfo(RecordInfo *Expected, RecordInfo *Actual);
[PATCH] D65690: [clang-doc] Add index in each info html file
DiegoAstiazaran added inline comments. Comment at: clang-tools-extra/clang-doc/assets/index.js:17 + return FilePath.substring(Path.length + 1) + Path = Path.substring(0, Path.lastIndexOf("/")); + } phosek wrote: > Wrong indentation? Yes, clang-format "missed" that because I forgot the semicolon in the previous line. Thanks, it has been fixed. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65690: [clang-doc] Add index in each info html file
phosek added inline comments. Comment at: clang-tools-extra/clang-doc/assets/index.js:17 + return FilePath.substring(Path.length + 1) + Path = Path.substring(0, Path.lastIndexOf("/")); + } Wrong indentation? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65690/new/ https://reviews.llvm.org/D65690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65690: [clang-doc] Add index in each info html file
DiegoAstiazaran created this revision. DiegoAstiazaran added reviewers: jakehehrlich, juliehockett, phosek. DiegoAstiazaran added a project: clang-tools-extra. Herald added subscribers: kadircet, arphaman, mgrang, mgorny. An index structure is created while generating the output file for each info. This structure is parsed to JSON and written to a file in the output directory. The html for the index is not rendered by clang-doc. A Javascript file is included in the output directory, this will read the JSON and insert HTML elements into the file. https://reviews.llvm.org/D65690 Files: clang-tools-extra/clang-doc/Generators.cpp clang-tools-extra/clang-doc/Generators.h clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/MDGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/YAMLGenerator.cpp clang-tools-extra/clang-doc/assets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/assets/index.js clang-tools-extra/clang-doc/stylesheets/clang-doc-default-stylesheet.css clang-tools-extra/clang-doc/tool/CMakeLists.txt clang-tools-extra/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/unittests/clang-doc/CMakeLists.txt clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp clang-tools-extra/unittests/clang-doc/ClangDocTest.h clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp === --- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp +++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp @@ -28,6 +28,7 @@ CDCtx.UserStylesheets.insert( CDCtx.UserStylesheets.begin(), "../share/clang/clang-doc-default-stylesheet.css"); + CDCtx.JsScripts.emplace_back("index.js"); return CDCtx; } @@ -56,6 +57,8 @@ namespace Namespace + + namespace Namespace Namespaces @@ -114,6 +117,8 @@ class r + + class r Defined at line 10 of test.cpp @@ -175,6 +180,8 @@ + + f @@ -212,6 +219,8 @@ + + enum class e @@ -281,6 +290,8 @@ + + f void f(int I, int J) Index: clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp === --- /dev/null +++ clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp @@ -0,0 +1,74 @@ +//===-- clang-doc/GeneratorTest.cpp ---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ClangDocTest.h" +#include "Generators.h" +#include "Representation.h" +#include "Serialize.h" +#include "gtest/gtest.h" + +namespace clang { +namespace doc { + +TEST(GeneratorTest, emitIndex) { + Index Idx; + auto InfoA = llvm::make_unique(); + InfoA->Name = "A"; + InfoA->USR = serialize::hashUSR("1"); + Generator::addInfoToIndex(Idx, InfoA.get()); + auto InfoC = llvm::make_unique(); + InfoC->Name = "C"; + InfoC->USR = serialize::hashUSR("3"); + Reference RefB = Reference("B"); + RefB.USR = serialize::hashUSR("2"); + InfoC->Namespace = {std::move(RefB)}; + Generator::addInfoToIndex(Idx, InfoC.get()); + auto InfoD = llvm::make_unique(); + InfoD->Name = "D"; + InfoD->USR = serialize::hashUSR("4"); + auto InfoF = llvm::make_unique(); + InfoF->Name = "F"; + InfoF->USR = serialize::hashUSR("6"); + Reference RefD = Reference("D"); + RefD.USR = serialize::hashUSR("4"); + Reference RefE = Reference("E"); + RefE.USR = serialize::hashUSR("5"); + InfoF->Namespace = {std::move(RefE), std::move(RefD)}; + Generator::addInfoToIndex(Idx, InfoF.get()); + auto InfoG = llvm::make_unique(InfoType::IT_namespace); + Generator::addInfoToIndex(Idx, InfoG.get()); + + Index ExpectedIdx; + Index IndexA; + IndexA.Name = "A"; + ExpectedIdx.Children.emplace_back(std::move(IndexA)); + Index IndexB; + IndexB.Name = "B"; + Index IndexC; + IndexC.Name = "C"; + IndexB.Children.emplace_back(std::move(IndexC)); + ExpectedIdx.Children.emplace_back(std::move(IndexB)); + Index IndexD; + IndexD.Name = "D"; + Index IndexE; + IndexE.Name = "E"; + Index IndexF; + IndexF.Name = "F"; + IndexE.Children.emplace_back(std::move(IndexF)); + IndexD.Children.emplace_back(std::move(IndexE)); + ExpectedIdx.Children.emplace_back(std::move(IndexD)); + Index IndexG; + IndexG.Name = "GlobalNamespace"; + IndexG.RefType = InfoType::IT_namespace; + ExpectedIdx.Children.emplace_back(std::move(IndexG)); + + CheckIndex(ExpectedIdx, Idx); +} + +} // namespace doc +} // namespace clang Index: clang-tools-extra/unittests/clang-doc/ClangDocTest.h