[llvm-branch-commits] [clang-tools-extra] [clang-doc] add namespaces to JSON generator (PR #143209)
Paul Kirth via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jun 9 15:40:04 PDT 2025
================
@@ -171,5 +171,78 @@ TEST(JSONGeneratorTest, emitRecordJSON) {
})raw";
EXPECT_EQ(Expected, Actual.str());
}
+
+TEST(JSONGeneratorTest, emitNamespaceJSON) {
+ NamespaceInfo I;
+ I.Name = "Namespace";
+ I.Path = "path/to/A";
+ I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+ I.Children.Namespaces.emplace_back(
+ EmptySID, "ChildNamespace", InfoType::IT_namespace,
+ "path::to::A::Namespace::ChildNamespace", "path/to/A/Namespace");
+ I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+ "path::to::A::Namespace::ChildStruct",
+ "path/to/A/Namespace");
+ I.Children.Functions.emplace_back();
+ I.Children.Functions.back().Name = "OneFunction";
+ I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+ I.Children.Enums.emplace_back();
+ I.Children.Enums.back().Name = "OneEnum";
+
+ auto G = getJSONGenerator();
+ assert(G);
+ std::string Buffer;
+ llvm::raw_string_ostream Actual(Buffer);
+ auto Err = G->generateDocForInfo(&I, Actual, ClangDocContext());
+ assert(!Err);
+ std::string Expected = R"raw({
+ "Enums": [
+ {
+ "Name": "OneEnum",
+ "Scoped": false,
+ "USR": "0000000000000000000000000000000000000000"
+ }
+ ],
+ "Functions": [
+ {
+ "IsStatic": false,
+ "Name": "OneFunction",
+ "ReturnType": {
+ "IsBuiltIn": false,
+ "IsTemplate": false,
+ "Name": "",
+ "QualName": "",
+ "USR": "0000000000000000000000000000000000000000"
+ },
+ "USR": "0000000000000000000000000000000000000000"
+ }
+ ],
+ "Name": "Namespace",
+ "Namespace": [
+ "A"
+ ],
+ "NamespacePath": "path/to/A/Namespace",
----------------
ilovepi wrote:
Are these file paths going to work on Windows?
https://github.com/llvm/llvm-project/pull/143209
More information about the llvm-branch-commits
mailing list