[llvm-branch-commits] [clang-tools-extra] [clang-doc] Implement setupTemplateValue for HTMLMustacheGenerator (PR #138064)
Petr Hosek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue May 6 18:54:36 PDT 2025
================
@@ -406,8 +406,26 @@ static json::Value extractValue(const RecordInfo &I,
static Error setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
Info *I) {
- return createStringError(inconvertibleErrorCode(),
- "setupTemplateValue is unimplemented");
+ V.getAsObject()->insert({"ProjectName", CDCtx.ProjectName});
+ json::Value StylesheetArr = Array();
+ auto InfoPath = I->getRelativeFilePath("");
+ SmallString<128> RelativePath = computeRelativePath("", InfoPath);
+ for (const auto &FilePath : CDCtx.UserStylesheets) {
+ SmallString<128> StylesheetPath = RelativePath;
+ sys::path::append(StylesheetPath, sys::path::filename(FilePath));
+ sys::path::native(StylesheetPath, sys::path::Style::posix);
+ StylesheetArr.getAsArray()->emplace_back(StylesheetPath);
+ }
----------------
petrhosek wrote:
We shouldn't be calling `sys::path::native` repeatedly inside the loop.
```suggestion
SmallString<128> RelativePath = computeRelativePath("", InfoPath);
sys::path::native(RelativePath, sys::path::Style::posix);
for (const auto &FilePath : CDCtx.UserStylesheets) {
SmallString<128> StylesheetPath = RelativePath;
sys::path::append(StylesheetPath, sys::path::filename(FilePath), sys::path::Style::posix);
StylesheetArr.getAsArray()->emplace_back(StylesheetPath);
}
```
https://github.com/llvm/llvm-project/pull/138064
More information about the llvm-branch-commits
mailing list