clang-tools 22.0.0git
ClangDocMain.cpp File Reference
#include "BitcodeReader.h"
#include "ClangDoc.h"
#include "Generators.h"
#include "Representation.h"
#include "support/Utils.h"
#include "clang/ASTMatchers/ASTMatchersInternal.h"
#include "clang/Tooling/AllTUsExecution.h"
#include "clang/Tooling/CommonOptionsParser.h"
#include "clang/Tooling/Execution.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/raw_ostream.h"
#include <atomic>
#include <mutex>
#include <string>

Go to the source code of this file.

Enumerations

enum  OutputFormatTy {
  md , yaml , html , mustache ,
  json
}

Functions

static llvm::cl::extrahelp CommonHelp (CommonOptionsParser::HelpMessage)
static llvm::cl::OptionCategory ClangDocCategory ("clang-doc options")
static llvm::cl::opt< std::string > ProjectName ("project-name", llvm::cl::desc("Name of project."), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< bool > IgnoreMappingFailures ("ignore-map-errors", llvm::cl::desc("Continue if files are not mapped correctly."), llvm::cl::init(true), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > OutDirectory ("output", llvm::cl::desc("Directory for outputting generated files."), llvm::cl::init("docs"), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > BaseDirectory ("base", llvm::cl::desc(R"(Base Directory for generated documentation. URLs will be rooted at this directory for HTML links.)"), llvm::cl::init(""), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< bool > PublicOnly ("public", llvm::cl::desc("Document only public declarations."), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< bool > DoxygenOnly ("doxygen", llvm::cl::desc("Use only doxygen-style comments to generate docs."), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory))
static llvm::cl::list< std::string > UserStylesheets ("stylesheets", llvm::cl::CommaSeparated, llvm::cl::desc("CSS stylesheets to extend the default styles."), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > UserAssetPath ("asset", llvm::cl::desc("User supplied asset path to " "override the default css and js files for html output"), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > SourceRoot ("source-root", llvm::cl::desc(R"( Directory where processed files are stored. Links to definition locations will only be generated if the file is in this dir.)"), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > RepositoryUrl ("repository", llvm::cl::desc(R"( URL of repository that hosts code. Used for links to definition locations.)"), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< std::string > RepositoryCodeLinePrefix ("repository-line-prefix", llvm::cl::desc("Prefix of line code for repository."), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< bool > FTimeTrace ("ftime-trace", llvm::cl::desc(R"( Turn on time profiler. Generates clang-doc-tracing.json)"), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory))
static llvm::cl::opt< OutputFormatTyFormatEnum ("format", llvm::cl::desc("Format for outputted docs."), llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml", "Documentation in YAML format."), clEnumValN(OutputFormatTy::md, "md", "Documentation in MD format."), clEnumValN(OutputFormatTy::html, "html", "Documentation in HTML format."), clEnumValN(OutputFormatTy::mustache, "mustache", "Documentation in mustache HTML format"), clEnumValN(OutputFormatTy::json, "json", "Documentation in JSON format")), llvm::cl::init(OutputFormatTy::yaml), llvm::cl::cat(ClangDocCategory))
static std::string getFormatString ()
static std::string getExecutablePath (const char *Argv0, void *MainAddr)
static llvm::Error getAssetFiles (clang::doc::ClangDocContext &CDCtx)
static llvm::Error getDefaultAssetFiles (const char *Argv0, clang::doc::ClangDocContext &CDCtx)
static llvm::Error getHtmlAssetFiles (const char *Argv0, clang::doc::ClangDocContext &CDCtx)
static llvm::Error getMustacheHtmlFiles (const char *Argv0, clang::doc::ClangDocContext &CDCtx)
static void sortUsrToInfo (llvm::StringMap< std::unique_ptr< doc::Info > > &USRToInfo)
 Make the output of clang-doc deterministic by sorting the children of namespaces and records.
static llvm::Error handleMappingFailures (llvm::Error Err)
static llvm::Error createDirectories (llvm::StringRef OutDirectory)
int main (int argc, const char **argv)

Variables

static llvm::ExitOnError ExitOnErr

Enumeration Type Documentation

◆ OutputFormatTy

Enumerator
md 
yaml 
html 
mustache 
json 

Definition at line 106 of file ClangDocMain.cpp.

Function Documentation

◆ BaseDirectory()

llvm::cl::opt< std::string > BaseDirectory ( "base" ,
llvm::cl::desc(R"(Base Directory for generated documentation.URLs will be rooted at this directory for HTML links.)") ,
llvm::cl::init("") ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

◆ ClangDocCategory()

◆ CommonHelp()

llvm::cl::extrahelp CommonHelp ( CommonOptionsParser::HelpMessage )
static

◆ createDirectories()

llvm::Error createDirectories ( llvm::StringRef OutDirectory)
static

Definition at line 265 of file ClangDocMain.cpp.

◆ DoxygenOnly()

llvm::cl::opt< bool > DoxygenOnly ( "doxygen" ,
llvm::cl::desc("Use only doxygen-style comments to generate docs.") ,
llvm::cl::init(false) ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

◆ FormatEnum()

llvm::cl::opt< OutputFormatTy > FormatEnum ( "format" ,
llvm::cl::desc("Format for outputted docs.") ,
llvm::cl::values(clEnumValN(OutputFormatTy::yaml, "yaml", "Documentation in YAML format."), clEnumValN(OutputFormatTy::md, "md", "Documentation in MD format."), clEnumValN(OutputFormatTy::html, "html", "Documentation in HTML format."), clEnumValN(OutputFormatTy::mustache, "mustache", "Documentation in mustache HTML format"), clEnumValN(OutputFormatTy::json, "json", "Documentation in JSON format")) ,
llvm::cl::init(OutputFormatTy::yaml) ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory(), html, md, and yaml.

Referenced by getFormatString().

◆ FTimeTrace()

llvm::cl::opt< bool > FTimeTrace ( "ftime-trace" ,
llvm::cl::desc(R"(Turn on time profiler. Generates clang-doc-tracing.json)") ,
llvm::cl::init(false) ,
llvm::cl::cat(ClangDocCategory)  )
static

◆ getAssetFiles()

llvm::Error getAssetFiles ( clang::doc::ClangDocContext & CDCtx)
static

Definition at line 149 of file ClangDocMain.cpp.

References Argv0.

◆ getDefaultAssetFiles()

llvm::Error getDefaultAssetFiles ( const char * Argv0,
clang::doc::ClangDocContext & CDCtx )
static

Definition at line 169 of file ClangDocMain.cpp.

◆ getExecutablePath()

std::string getExecutablePath ( const char * Argv0,
void * MainAddr )
static

Definition at line 145 of file ClangDocMain.cpp.

◆ getFormatString()

std::string getFormatString ( )
static

Definition at line 124 of file ClangDocMain.cpp.

References ClangDocCategory(), ExitOnErr, FormatEnum(), html, json, md, mustache, and yaml.

◆ getHtmlAssetFiles()

llvm::Error getHtmlAssetFiles ( const char * Argv0,
clang::doc::ClangDocContext & CDCtx )
static

Definition at line 201 of file ClangDocMain.cpp.

◆ getMustacheHtmlFiles()

llvm::Error getMustacheHtmlFiles ( const char * Argv0,
clang::doc::ClangDocContext & CDCtx )
static

Definition at line 212 of file ClangDocMain.cpp.

References Argv0, and UserAssetPath().

◆ handleMappingFailures()

llvm::Error handleMappingFailures ( llvm::Error Err)
static

Definition at line 253 of file ClangDocMain.cpp.

References clang::doc::IT_record.

◆ IgnoreMappingFailures()

llvm::cl::opt< bool > IgnoreMappingFailures ( "ignore-map-errors" ,
llvm::cl::desc("Continue if files are not mapped correctly.") ,
llvm::cl::init(true) ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

◆ main()

int main ( int argc,
const char ** argv )

Definition at line 272 of file ClangDocMain.cpp.

References OutDirectory().

◆ OutDirectory()

llvm::cl::opt< std::string > OutDirectory ( "output" ,
llvm::cl::desc("Directory for outputting generated files.") ,
llvm::cl::init("docs") ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

Referenced by clang::doc::copyFile(), and main().

◆ ProjectName()

llvm::cl::opt< std::string > ProjectName ( "project-name" ,
llvm::cl::desc("Name of project.") ,
llvm::cl::cat(ClangDocCategory)  )
static

◆ PublicOnly()

◆ RepositoryCodeLinePrefix()

llvm::cl::opt< std::string > RepositoryCodeLinePrefix ( "repository-line-prefix" ,
llvm::cl::desc("Prefix of line code for repository.") ,
llvm::cl::cat(ClangDocCategory)  )
static

◆ RepositoryUrl()

◆ sortUsrToInfo()

void sortUsrToInfo ( llvm::StringMap< std::unique_ptr< doc::Info > > & USRToInfo)
static

Make the output of clang-doc deterministic by sorting the children of namespaces and records.

Definition at line 239 of file ClangDocMain.cpp.

◆ SourceRoot()

llvm::cl::opt< std::string > SourceRoot ( "source-root" ,
llvm::cl::desc(R"(Directory where processed files are stored.Links to definition locations will only begenerated if the file is in this dir.)") ,
llvm::cl::cat(ClangDocCategory)  )
static

◆ UserAssetPath()

llvm::cl::opt< std::string > UserAssetPath ( "asset" ,
llvm::cl::desc("User supplied asset path to " "override the default css and js files for html output") ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

Referenced by getMustacheHtmlFiles().

◆ UserStylesheets()

llvm::cl::list< std::string > UserStylesheets ( "stylesheets" ,
llvm::cl::CommaSeparated ,
llvm::cl::desc("CSS stylesheets to extend the default styles.") ,
llvm::cl::cat(ClangDocCategory)  )
static

References ClangDocCategory().

Variable Documentation

◆ ExitOnErr

llvm::ExitOnError ExitOnErr
static

Definition at line 122 of file ClangDocMain.cpp.

Referenced by getFormatString().