Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba1e65a

Browse filesBrowse 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 <peter.chou@mail.utoronto.ca>
1 parent e66d950 commit ba1e65a
Copy full SHA for ba1e65a

File tree

Expand file treeCollapse file tree

2 files changed

+429
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+429
-9
lines changed

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

Copy file name to clipboardExpand all lines: clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+22-3Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static json::Value extractValue(const RecordInfo &I,
372372

373373
maybeInsertLocation(I.DefLoc, CDCtx, RecordValue);
374374

375-
StringRef BasePath = I.getRelativeFilePath("");
375+
SmallString<64> BasePath = I.getRelativeFilePath("");
376376
extractScopeChildren(I.Children, RecordValue, BasePath, CDCtx);
377377
json::Value PublicMembers = Array();
378378
json::Array &PubMemberRef = *PublicMembers.getAsArray();
@@ -406,8 +406,26 @@ static json::Value extractValue(const RecordInfo &I,
406406

407407
static Error setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
408408
Info *I) {
409-
return createStringError(inconvertibleErrorCode(),
410-
"setupTemplateValue is unimplemented");
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});
428+
return Error::success();
411429
}
412430

413431
Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
@@ -418,6 +436,7 @@ Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
418436
extractValue(*static_cast<clang::doc::NamespaceInfo *>(I), CDCtx);
419437
if (auto Err = setupTemplateValue(CDCtx, V, I))
420438
return Err;
439+
assert(NamespaceTemplate && "NamespaceTemplate is nullptr.");
421440
NamespaceTemplate->render(V, OS);
422441
break;
423442
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.