[clang-tools-extra] [clang-doc] Add HTMLMustacheGenerator methods (PR #138061)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Fri May 16 16:20:54 PDT 2025
================
@@ -70,18 +70,116 @@ class MustacheTemplateFile : public Template {
MustacheTemplateFile(StringRef TemplateStr) : Template(TemplateStr) {}
};
+static std::unique_ptr<MustacheTemplateFile> NamespaceTemplate = nullptr;
+
+static std::unique_ptr<MustacheTemplateFile> RecordTemplate = nullptr;
+
+static Error setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
+ return Error::success();
+}
+
Error MustacheHTMLGenerator::generateDocs(
StringRef RootDir, StringMap<std::unique_ptr<doc::Info>> Infos,
const clang::doc::ClangDocContext &CDCtx) {
+ if (auto Err = setupTemplateFiles(CDCtx))
+ return Err;
+ // Track which directories we already tried to create.
+ StringSet<> CreatedDirs;
+ // Collect all output by file name and create the necessary directories.
+ StringMap<std::vector<doc::Info *>> FileToInfos;
+ for (const auto &Group : Infos) {
+ doc::Info *Info = Group.getValue().get();
+
+ SmallString<128> Path;
+ sys::path::native(RootDir, Path);
+ sys::path::append(Path, Info->getRelativeFilePath(""));
+ if (!CreatedDirs.contains(Path)) {
+ if (std::error_code EC = sys::fs::create_directories(Path))
+ return createStringError(EC, "failed to create directory '%s'.",
+ Path.c_str());
----------------
ilovepi wrote:
ah, no dice. We hit a static assert in Format.h
```
error: static assertion failed due to requirement 'std::is_scalar_v<llvm::StringRef>': format can't be used with non fundamental / non pointer type
85 | static_assert(std::is_scalar_v<Arg>
```
https://github.com/llvm/llvm-project/pull/138061
More information about the cfe-commits
mailing list