Skip to content

[clang-doc] Implement setupTemplateValue for HTMLMustacheGenerator #138064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025

Conversation

ilovepi
Copy link
Contributor

@ilovepi ilovepi commented May 1, 2025

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

@llvmbot
Copy link
Member

llvmbot commented May 1, 2025

@llvm/pr-subscribers-clang-tools-extra

Author: Paul Kirth (ilovepi)

Changes

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>


Full diff: https://github.com/llvm/llvm-project/pull/138064.diff

1 Files Affected:

  • (modified) clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp (+20)
diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index 29392f8bf17b9..1f0a88c269cfa 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -406,7 +406,27 @@ static json::Value extractValue(const RecordInfo &I,
 
 static void setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
                                Info *I) {
+  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);
+  }
+  V.getAsObject()->insert({"Stylesheets", StylesheetArr});
+
+  json::Value ScriptArr = Array();
+  for (auto Script : CDCtx.JsScripts) {
+    SmallString<128> JsPath = RelativePath;
+    sys::path::append(JsPath, sys::path::filename(Script));
+    ScriptArr.getAsArray()->emplace_back(JsPath);
+  }
+  V.getAsObject()->insert({"Scripts", ScriptArr});
 }
+
 Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
                                                 const ClangDocContext &CDCtx) {
   switch (I->IT) {

@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 5af67bc to 888f545 Compare May 6, 2025 21:33
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch 2 times, most recently from 6f9a69e to 6d7732b Compare May 6, 2025 22:51
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 888f545 to e215c97 Compare May 6, 2025 22:51
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from e215c97 to d832772 Compare May 7, 2025 01:59
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 6d7732b to 5c5d241 Compare May 7, 2025 01:59
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from d832772 to e66d950 Compare May 7, 2025 02:54
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 5c5d241 to ba1e65a Compare May 7, 2025 02:54
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from e66d950 to 8a5872d Compare May 7, 2025 03:23
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from ba1e65a to 51e8a50 Compare May 7, 2025 03:23
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 8a5872d to 0e2e6ad Compare May 7, 2025 03:25
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 51e8a50 to 775f79d Compare May 7, 2025 03:25
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 0e2e6ad to ac8c55e Compare May 7, 2025 03:26
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 174283d to bda0fff Compare May 13, 2025 22:48
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 1566219 to 0e6ab7d Compare May 13, 2025 22:48
@ilovepi ilovepi requested a review from evelez7 May 13, 2025 23:16
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 0e6ab7d to c7f6fb8 Compare May 16, 2025 23:38
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch 2 times, most recently from fa0b1fb to ef64af7 Compare May 17, 2025 00:14
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch 2 times, most recently from fa76fb7 to d0754f4 Compare May 17, 2025 00:33
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch 2 times, most recently from 6e5e448 to d3bedfc Compare May 17, 2025 05:42
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from d0754f4 to 8e0b4fc Compare May 17, 2025 05:42
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from d3bedfc to 973b240 Compare May 20, 2025 18:26
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 8e0b4fc to 51bd30a Compare May 20, 2025 18:26
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 973b240 to 603c1b6 Compare May 20, 2025 21:05
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch 2 times, most recently from c97f7af to 6880c2f Compare May 22, 2025 21:18
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 603c1b6 to 5e56a52 Compare May 22, 2025 21:18
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 6880c2f to afa7c63 Compare May 22, 2025 21:21
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 5e56a52 to c93706d Compare May 22, 2025 21:22
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from afa7c63 to 03f3e44 Compare May 23, 2025 21:58
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from c93706d to 011f297 Compare May 23, 2025 21:58
Copy link
Contributor Author

ilovepi commented May 23, 2025

Merge activity

  • May 23, 10:52 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 23, 10:57 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 23, 10:59 PM UTC: @ilovepi merged this pull request with Graphite.

@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-json branch from 03f3e44 to 0c7122c Compare May 23, 2025 22:54
Base automatically changed from users/ilovepi/clang-doc-mustache-json to main May 23, 2025 22:56
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. The tests here are disabled by
default until we can use lit tests via tool support, since we cannot
read files in the unit tests.

Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
@ilovepi ilovepi force-pushed the users/ilovepi/clang-doc-mustache-template-setup branch from 011f297 to 72da18f Compare May 23, 2025 22:56
@ilovepi ilovepi merged commit 26fe803 into main May 23, 2025
5 of 7 checks passed
@ilovepi ilovepi deleted the users/ilovepi/clang-doc-mustache-template-setup branch May 23, 2025 22:59
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
…lvm#138064)

This patch implements the business logic for setupTemplateValue, which
was split from llvm#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants