18#include "llvm/Support/Error.h"
19#include "llvm/Support/Path.h"
22using namespace llvm::json;
23using namespace llvm::mustache;
41 StringRef RelativeRootPath)
override;
44 SmallString<128> RelativeRootPath);
46 StringRef RootDir, llvm::StringMap<std::unique_ptr<doc::Info>> Infos,
53 auto ConvertToNative = [](std::string &&Path) -> std::string {
54 SmallString<128> PathBuf(Path);
55 llvm::sys::path::native(PathBuf);
56 return PathBuf.str().str();
59 std::string NamespaceFilePath =
61 std::string ClassFilePath =
63 std::string CommentFilePath =
65 std::string FunctionFilePath =
67 std::string EnumFilePath =
69 std::vector<std::pair<StringRef, StringRef>> Partials = {
70 {
"Comments", CommentFilePath},
71 {
"FunctionPartial", FunctionFilePath},
72 {
"EnumPartial", EnumFilePath}};
80 return Error::success();
85 SmallString<128> RelativeRootPath) {
86 V.getAsObject()->insert({
"ProjectName", CDCtx.
ProjectName});
87 json::Value StylesheetArr = Array();
88 sys::path::native(RelativeRootPath, sys::path::Style::posix);
90 auto *SSA = StylesheetArr.getAsArray();
93 SmallString<128> StylesheetPath = RelativeRootPath;
94 sys::path::append(StylesheetPath, sys::path::Style::posix,
95 sys::path::filename(FilePath));
96 SSA->emplace_back(StylesheetPath);
98 V.getAsObject()->insert({
"Stylesheets", StylesheetArr});
100 json::Value ScriptArr = Array();
101 auto *SCA = ScriptArr.getAsArray();
104 SmallString<128> JsPath = RelativeRootPath;
105 sys::path::append(JsPath, sys::path::Style::posix,
106 sys::path::filename(Script));
107 SCA->emplace_back(JsPath);
109 V.getAsObject()->insert({
"Scripts", ScriptArr});
110 return Error::success();
116 StringRef ObjTypeStr,
117 StringRef RelativeRootPath) {
118 if (ObjTypeStr ==
"namespace") {
123 }
else if (ObjTypeStr ==
"record") {
129 return Error::success();
145 return createStringError(inconvertibleErrorCode(),
"unexpected InfoType");
147 return Error::success();
153 if (Error Err =
copyFile(FilePath, ResourcePath))
155 for (
const auto &FilePath : CDCtx.
JsScripts)
156 if (Error Err =
copyFile(FilePath, ResourcePath))
158 return Error::success();
162 StringRef RootDir, llvm::StringMap<std::unique_ptr<doc::Info>> Infos,
170static GeneratorRegistry::Add<MustacheHTMLGenerator>
static const char * Format
Error createResources(ClangDocContext &CDCtx) override
Error generateDocForInfo(Info *I, raw_ostream &OS, const ClangDocContext &CDCtx) override
llvm::Error generateDocumentation(StringRef RootDir, llvm::StringMap< std::unique_ptr< doc::Info > > Infos, const ClangDocContext &CDCtx, std::string DirName) override
The main orchestrator for Mustache-based documentation.
Error generateDocForJSON(json::Value &JSON, raw_fd_ostream &OS, const ClangDocContext &CDCtx, StringRef ObjTypeStr, StringRef RelativeRootPath) override
Error setupTemplateFiles(const ClangDocContext &CDCtx) override
Initializes the template files from disk and calls setupTemplate to register partials.
Error setupTemplateResources(const ClangDocContext &CDCtx, json::Value &V, SmallString< 128 > RelativeRootPath)
llvm::Error copyFile(llvm::StringRef FilePath, llvm::StringRef OutDirectory)
static std::unique_ptr< MustacheTemplateFile > RecordTemplate
static GeneratorRegistry::Add< JSONGenerator > JSON(JSONGenerator::Format, "Generator for JSON output.")
static GeneratorRegistry::Add< MustacheHTMLGenerator > MHTML(MustacheHTMLGenerator::Format, "Generator for mustache HTML output.")
static std::unique_ptr< MustacheTemplateFile > NamespaceTemplate
volatile int MHTMLGeneratorAnchorSource
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Some operations such as code completion produce a set of candidates.
std::vector< std::string > UserStylesheets
llvm::StringMap< std::string > MustacheTemplates
std::vector< std::string > JsScripts
llvm::Error generateDocumentation(StringRef RootDir, llvm::StringMap< std::unique_ptr< doc::Info > > Infos, const clang::doc::ClangDocContext &CDCtx, std::string DirName) override
The main orchestrator for Mustache-based documentation.
llvm::Error setupTemplate(std::unique_ptr< MustacheTemplateFile > &Template, StringRef TemplatePath, std::vector< std::pair< StringRef, StringRef > > Partials)
Registers partials to templates.