================
@@ -647,6 +648,54 @@ static SmallString<16> determineFileName(Info *I,
SmallString<128> &Path) {
return FileName;
}
+// Creates a JSON file above the global namespace directory.
+// An index can be used to create the top-level HTML index page or the Markdown
+// index file.
+static Error serializeIndex(const ClangDocContext &CDCtx, StringRef RootDir) {
+ if (CDCtx.Idx.Children.empty())
+ return Error::success();
+
+ json::Value ObjVal = Object();
+ Object &Obj = *ObjVal.getAsObject();
+ if (!CDCtx.ProjectName.empty())
+ Obj["ProjectName"] = CDCtx.ProjectName;
+
+ auto IndexCopy = CDCtx.Idx;
+ IndexCopy.sort();
+ json::Value IndexArray = json::Array();
+ auto &IndexArrayRef = *IndexArray.getAsArray();
+
+ if (IndexCopy.Children.empty()) {
+ // If the index is empty, default to displaying the global namespace.
+ IndexCopy.Children.emplace_back(GlobalNamespaceID, "",
+ InfoType::IT_namespace, "GlobalNamespace");
+ } else {
+ IndexArrayRef.reserve(CDCtx.Idx.Children.size());
+ }
+
+ for (auto &Idx : IndexCopy.Children) {
+ if (!Idx.Children.empty()) {
----------------
ilovepi wrote:
```suggestion
if (Idx.Children.empty())
continue;
```
Then you can avoid some indentation in the loop.
https://github.com/llvm/llvm-project/pull/171899
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits