[clang-tools-extra] [clang-doc] fix CSS, JS paths for HTML Mustache generation (PR #160360)

Erick Velez via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 23 11:36:58 PDT 2025


https://github.com/evelez7 created https://github.com/llvm/llvm-project/pull/160360

Resource creation not using the correct path after the patch that placed
HTML files into their own directory.

>From e6c68b9f0081606b62a1cfa1d80ccbe69fc946c3 Mon Sep 17 00:00:00 2001
From: Erick Velez <erickvelez7 at gmail.com>
Date: Tue, 23 Sep 2025 09:34:27 -0700
Subject: [PATCH] [clang-doc] fix CSS, JS paths for HTML Mustache generation

Resource creation not using the correct path after the patch that placed
HTML files into their own directory.
---
 clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp        | 5 +++--
 .../unittests/clang-doc/HTMLMustacheGeneratorTest.cpp        | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index 1ab40aacbfe09..b37dc272ea156 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -274,11 +274,12 @@ Error MustacheHTMLGenerator::generateDocForInfo(Info *I, raw_ostream &OS,
 }
 
 Error MustacheHTMLGenerator::createResources(ClangDocContext &CDCtx) {
+  std::string ResourcePath(CDCtx.OutDirectory + "/html");
   for (const auto &FilePath : CDCtx.UserStylesheets)
-    if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
+    if (Error Err = copyFile(FilePath, ResourcePath))
       return Err;
   for (const auto &FilePath : CDCtx.JsScripts)
-    if (Error Err = copyFile(FilePath, CDCtx.OutDirectory))
+    if (Error Err = copyFile(FilePath, ResourcePath))
       return Err;
   return Error::success();
 }
diff --git a/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp b/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
index 602058f5d9eb8..66575d85380f8 100644
--- a/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
+++ b/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp
@@ -75,14 +75,14 @@ TEST(HTMLMustacheGeneratorTest, createResources) {
       << "Failed to create resources with valid UserStylesheets and JsScripts";
   {
     SmallString<256> PathBuf;
-    llvm::sys::path::append(PathBuf, RootTestDirectory.path(),
+    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "html",
                             "clang-doc-mustache.css");
     verifyFileContents(PathBuf, "CSS");
   }
 
   {
     SmallString<256> PathBuf;
-    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "mustache.js");
+    llvm::sys::path::append(PathBuf, RootTestDirectory.path(), "html", "mustache.js");
     verifyFileContents(PathBuf, "JavaScript");
   }
 }



More information about the cfe-commits mailing list