clang-tools 22.0.0git
clang::doc::MustacheGenerator Struct Referenceabstract

#include <Generators.h>

Inheritance diagram for clang::doc::MustacheGenerator:
[legend]

Public Member Functions

Expected< std::string > getInfoTypeStr (llvm::json::Object *Info, StringRef Filename)
SmallString< 128 > getRelativePathToRoot (StringRef PathToFile, StringRef DocsRootPath)
 Used to find the relative path from the file to the format's docs root.
virtual ~MustacheGenerator ()=default
virtual llvm::Error setupTemplateFiles (const ClangDocContext &CDCtx)=0
 Initializes the template files from disk and calls setupTemplate to register partials.
virtual llvm::Error generateDocForJSON (llvm::json::Value &JSON, llvm::raw_fd_ostream &OS, const ClangDocContext &CDCtx, StringRef ObjectTypeStr, StringRef RelativeRootPath)=0
 Populates templates with data from JSON and calls any specifics for the format.
llvm::Error setupTemplate (std::unique_ptr< MustacheTemplateFile > &Template, StringRef TemplatePath, std::vector< std::pair< StringRef, StringRef > > Partials)
 Registers partials to templates.
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.
Public Member Functions inherited from clang::doc::Generator
virtual ~Generator ()=default
virtual llvm::Error createResources (ClangDocContext &CDCtx)
virtual llvm::Error generateDocForInfo (Info *I, llvm::raw_ostream &OS, const ClangDocContext &CDCtx)=0

Additional Inherited Members

Static Public Member Functions inherited from clang::doc::Generator
static void addInfoToIndex (Index &Idx, const doc::Info *Info)

Detailed Description

Definition at line 95 of file Generators.h.

Constructor & Destructor Documentation

◆ ~MustacheGenerator()

virtual clang::doc::MustacheGenerator::~MustacheGenerator ( )
virtualdefault

Member Function Documentation

◆ generateDocForJSON()

virtual llvm::Error clang::doc::MustacheGenerator::generateDocForJSON ( llvm::json::Value & JSON,
llvm::raw_fd_ostream & OS,
const ClangDocContext & CDCtx,
StringRef ObjectTypeStr,
StringRef RelativeRootPath )
pure virtual

Populates templates with data from JSON and calls any specifics for the format.

For example, for HTML it will render the paths for CSS and JS.

References clang::doc::JSON().

Referenced by generateDocumentation().

◆ generateDocumentation()

Error clang::doc::MustacheGenerator::generateDocumentation ( StringRef RootDir,
llvm::StringMap< std::unique_ptr< doc::Info > > Infos,
const clang::doc::ClangDocContext & CDCtx,
std::string DirName )
overridevirtual

The main orchestrator for Mustache-based documentation.

  1. Initializes templates files from disk by calling setupTemplateFiles.
  2. Calls the JSON generator to write JSON to disk.
  3. Iterates over the JSON files, recreates the directory structure from JSON, and calls generateDocForJSON for each file.
  4. A file of the desired format is created.

Implements clang::doc::Generator.

Reimplemented in clang::doc::MustacheHTMLGenerator.

Definition at line 68 of file Generators.cpp.

References clang::doc::createFileOpenError(), clang::doc::findGeneratorByName(), generateDocForJSON(), clang::doc::JSONGenerator::generateDocumentation(), getInfoTypeStr(), getRelativePathToRoot(), and setupTemplateFiles().

Referenced by clang::doc::MustacheHTMLGenerator::generateDocumentation().

◆ getInfoTypeStr()

Expected< std::string > clang::doc::MustacheGenerator::getInfoTypeStr ( llvm::json::Object * Info,
StringRef Filename )

Definition at line 158 of file Generators.cpp.

Referenced by generateDocumentation().

◆ getRelativePathToRoot()

SmallString< 128 > clang::doc::MustacheGenerator::getRelativePathToRoot ( StringRef PathToFile,
StringRef DocsRootPath )

Used to find the relative path from the file to the format's docs root.

Mainly used for the HTML resource paths.

Definition at line 173 of file Generators.cpp.

References clang::doc::computeRelativePath().

Referenced by generateDocumentation().

◆ setupTemplate()

Error clang::doc::MustacheGenerator::setupTemplate ( std::unique_ptr< MustacheTemplateFile > & Template,
StringRef TemplatePath,
std::vector< std::pair< StringRef, StringRef > > Partials )

Registers partials to templates.

Definition at line 55 of file Generators.cpp.

References clang::doc::MustacheTemplateFile::createMustacheFile().

Referenced by clang::doc::MustacheHTMLGenerator::setupTemplateFiles().

◆ setupTemplateFiles()

virtual llvm::Error clang::doc::MustacheGenerator::setupTemplateFiles ( const ClangDocContext & CDCtx)
pure virtual

Initializes the template files from disk and calls setupTemplate to register partials.

Implemented in clang::doc::MustacheHTMLGenerator.

Referenced by generateDocumentation().


The documentation for this struct was generated from the following files: