[clang-tools-extra] [clang-doc] Add --asset option to clang-doc (PR #94717)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 10 14:45:16 PDT 2024


================
@@ -131,12 +137,85 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
   return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
 }
 
+llvm::Error GetAssetFiles(clang::doc::ClangDocContext &CDCtx) {
+  std::error_code Code;
+  for (auto DirIt = llvm::sys::fs::directory_iterator(UserAssetPath, Code),
+            DirEnd = llvm::sys::fs::directory_iterator();
+       !Code && DirIt != DirEnd; DirIt.increment(Code)) {
+    llvm::SmallString<128> FilePath = llvm::SmallString<128>(DirIt->path());
+    if (!Code) {
+      return llvm::createFileError(FilePath, Code);
+    }
+    if (llvm::sys::fs::is_regular_file(FilePath)) {
+      if (llvm::sys::path::extension(FilePath) == ".css") {
+        CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
+                                     std::string(FilePath));
+      } else if (llvm::sys::path::extension(FilePath) == ".js") {
+        CDCtx.FilesToCopy.emplace_back(FilePath.str());
+      }
+    }
+  }
+}
----------------
ilovepi wrote:

Isn't this missing a return statement for `success()`? Locally I'm also seeing errors w/ this code and the error creation. I'd suggest making sure LLVM_ENABLE_ASSERTIONS=On shows up in your CMake config (see https://www.llvm.org/docs/CMake.html#llvm-related-variables).

https://github.com/llvm/llvm-project/pull/94717


More information about the cfe-commits mailing list