Skip to content

Commit 93ac1bf

Browse files
ilovepiPeterChou1
andcommitted
[clang-doc] Implement setupTemplateValue for HTMLMustacheGenerator
This patch implements the business logic for setupTemplateValue, which was split from #133161. The implementation configures the relative path relationships between the various HTML components, and prepares them prior to their use in the generator. Co-authored-by: Peter Chou <[email protected]>
1 parent 5af67bc commit 93ac1bf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,27 @@ static json::Value extractValue(const RecordInfo &I,
406406

407407
static void setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
408408
Info *I) {
409+
V.getAsObject()->insert({"ProjectName", CDCtx.ProjectName});
410+
json::Value StylesheetArr = Array();
411+
auto InfoPath = I->getRelativeFilePath("");
412+
SmallString<128> RelativePath = computeRelativePath("", InfoPath);
413+
for (const auto &FilePath : CDCtx.UserStylesheets) {
414+
SmallString<128> StylesheetPath = RelativePath;
415+
sys::path::append(StylesheetPath, sys::path::filename(FilePath));
416+
sys::path::native(StylesheetPath, sys::path::Style::posix);
417+
StylesheetArr.getAsArray()->emplace_back(StylesheetPath);
418+
}
419+
V.getAsObject()->insert({"Stylesheets", StylesheetArr});
420+
421+
json::Value ScriptArr = Array();
422+
for (auto Script : CDCtx.JsScripts) {
423+
SmallString<128> JsPath = RelativePath;
424+
sys::path::append(JsPath, sys::path::filename(Script));
425+
ScriptArr.getAsArray()->emplace_back(JsPath);
426+
}
427+
V.getAsObject()->insert({"Scripts", ScriptArr});
409428
}
429+
410430
Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
411431
const ClangDocContext &CDCtx) {
412432
switch (I->IT) {

0 commit comments

Comments
 (0)