[clang-tools-extra] [clang-doc] Add a top-level index.html page (PR #171899)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 16 10:59:03 PST 2025
================
@@ -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;
----------------
ilovepi wrote:
Seeing this pattern again is making me wonder if we should have helper:
```c++
void insertNonEmpty(StringRef Key, StringRef Val, JSONObject Obj){
if(!Val.empty())
Obj[Key] = Value;
}
```
Do you think that would be useful? or make it easier to reason about?
https://github.com/llvm/llvm-project/pull/171899
More information about the cfe-commits
mailing list