Go to the documentation of this file.
11 #include "llvm/ADT/StringRef.h"
12 #include "llvm/Support/FileSystem.h"
13 #include "llvm/Support/Path.h"
24 return "*" +
Text.str() +
"*";
28 return "**" +
Text.str() +
"**";
34 llvm::raw_string_ostream Stream(Buffer);
35 for (
const auto &R :
Refs) {
36 if (&R !=
Refs.begin())
49 static void writeHeader(
const Twine &Text,
unsigned int Num, raw_ostream &
OS) {
50 OS << std::string(Num,
'#') +
" " +
Text <<
"\n\n";
57 OS <<
"*Defined at " << L.Filename <<
"#" << std::to_string(L.LineNumber)
60 OS <<
"*Defined at [" << L.Filename <<
"#" << std::to_string(L.LineNumber)
62 << llvm::sys::path::relative_path(L.Filename) <<
"#"
63 << std::to_string(L.LineNumber) <<
")"
70 if (I.
Kind ==
"FullComment") {
73 }
else if (I.
Kind ==
"ParagraphComment") {
77 }
else if (I.
Kind ==
"BlockCommandComment") {
81 }
else if (I.
Kind ==
"InlineCommandComment") {
83 }
else if (I.
Kind ==
"ParamCommandComment") {
86 }
else if (I.
Kind ==
"TParamCommandComment") {
89 }
else if (I.
Kind ==
"VerbatimBlockComment") {
92 }
else if (I.
Kind ==
"VerbatimBlockLineComment") {
95 }
else if (I.
Kind ==
"VerbatimLineComment") {
98 }
else if (I.
Kind ==
"HTMLStartTagComment") {
102 llvm::raw_string_ostream Attrs(Buffer);
103 for (
unsigned Idx = 0; Idx < I.
AttrKeys.size(); ++Idx)
108 }
else if (I.
Kind ==
"HTMLEndTagComment") {
110 }
else if (I.
Kind ==
"TextComment") {
113 OS <<
"Unknown comment kind: " << I.
Kind <<
".\n\n";
118 llvm::raw_ostream &
OS) {
121 llvm::sys::path::native(
Path, llvm::sys::path::Style::posix);
122 llvm::sys::path::append(
Path, llvm::sys::path::Style::posix,
128 llvm::raw_ostream &
OS) {
136 llvm::raw_string_ostream Members(Buffer);
138 for (
const auto &N : I.
Members)
139 Members <<
"| " << N <<
" |\n";
149 llvm::raw_ostream &
OS) {
151 llvm::raw_string_ostream Stream(Buffer);
153 for (
const auto &N : I.
Params) {
156 Stream << N.Type.Name +
" " + N.Name;
160 std::string Access = getAccessSpelling(I.
Access).str();
163 "(" + Stream.str() +
")"),
177 llvm::raw_ostream &
OS) {
227 llvm::raw_ostream &
OS) {
240 if (!Parents.empty() || !VParents.empty()) {
243 else if (VParents.empty())
246 writeLine(
"Inherits from " + Parents +
", " + VParents,
OS);
252 for (
const auto &Member : I.
Members) {
253 std::string Access = getAccessSpelling(Member.Access).str();
255 writeLine(Access +
" " + Member.Type.Name +
" " + Member.Name,
OS);
257 writeLine(Member.Type.Name +
" " + Member.Name,
OS);
284 OS <<
"##" << std::string(Level,
'#') <<
" ";
290 std::error_code FileErr;
291 llvm::SmallString<128> FilePath;
293 llvm::sys::path::append(FilePath,
"all_files.md");
294 llvm::raw_fd_ostream
OS(FilePath, FileErr, llvm::sys::fs::OF_None);
296 return llvm::createStringError(llvm::inconvertibleErrorCode(),
297 "error creating index file: " +
309 return llvm::Error::success();
313 std::error_code FileErr;
314 llvm::SmallString<128> FilePath;
316 llvm::sys::path::append(FilePath,
"index.md");
317 llvm::raw_fd_ostream
OS(FilePath, FileErr, llvm::sys::fs::OF_None);
319 return llvm::createStringError(llvm::inconvertibleErrorCode(),
320 "error creating index file: " +
325 if (!
C.Children.empty()) {
328 case InfoType::IT_namespace:
331 case InfoType::IT_record:
334 case InfoType::IT_enum:
337 case InfoType::IT_function:
340 case InfoType::IT_default:
343 OS <<
"* " <<
Type <<
": [" <<
C.Name <<
"](";
346 OS <<
C.Name <<
")\n";
349 return llvm::Error::success();
356 llvm::Error generateDocForInfo(
Info *I, llvm::raw_ostream &
OS,
361 const char *MDGenerator::Format =
"md";
363 llvm::Error MDGenerator::generateDocForInfo(
Info *I, llvm::raw_ostream &
OS,
366 case InfoType::IT_namespace:
369 case InfoType::IT_record:
372 case InfoType::IT_enum:
375 case InfoType::IT_function:
378 case InfoType::IT_default:
379 return createStringError(llvm::inconvertibleErrorCode(),
380 "unexpected InfoType");
382 return llvm::Error::success();
396 return llvm::Error::success();
399 static GeneratorRegistry::Add<MDGenerator>
MD(MDGenerator::Format,
400 "Generator for MD output.");
volatile int MDGeneratorAnchorSource
static void genMarkdown(const ClangDocContext &CDCtx, const RecordInfo &I, llvm::raw_ostream &OS)
Some operations such as code completion produce a set of candidates.
std::vector< CommentInfo > Description
std::vector< EnumInfo > ChildEnums
llvm::SmallString< 16 > getFileBaseName() const
Returns the basename that should be used for this Reference.
static void writeNameLink(const StringRef &CurrentPath, const Reference &R, llvm::raw_ostream &OS)
std::vector< FunctionInfo > ChildFunctions
static GeneratorRegistry::Add< MDGenerator > MD(MDGenerator::Format, "Generator for MD output.")
std::vector< Reference > ChildNamespaces
std::string getTagType(TagTypeKind AS)
static void writeLine(const Twine &Text, raw_ostream &OS)
llvm::Optional< std::string > RepositoryUrl
llvm::SmallVector< Reference, 4 > VirtualParents
llvm::SmallVector< MemberTypeInfo, 4 > Members
static llvm::Error serializeIndex(ClangDocContext &CDCtx)
llvm::SmallVector< SmallString< 16 >, 4 > Members
static void writeHeader(const Twine &Text, unsigned int Num, raw_ostream &OS)
static std::string genReferenceList(const llvm::SmallVectorImpl< Reference > &Refs)
llvm::SmallVector< Reference, 4 > Parents
llvm::SmallString< 64 > getRelativeFilePath(const StringRef &CurrentPath) const
Returns the path for this Reference relative to CurrentPath.
static std::string genItalic(const Twine &Text)
static void serializeReference(llvm::raw_fd_ostream &OS, Index &I, int Level)
static void writeFileDefinition(const ClangDocContext &CDCtx, const Location &L, raw_ostream &OS)
llvm::SmallVector< FieldTypeInfo, 4 > Params
static void writeDescription(const CommentInfo &I, raw_ostream &OS)
std::vector< Reference > ChildRecords
std::vector< FunctionInfo > ChildFunctions
static std::string genEmphasis(const Twine &Text)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::raw_string_ostream OS
std::vector< Reference > ChildRecords
static llvm::Error genIndex(ClangDocContext &CDCtx)
static const char * Format
Generator for Markdown documentation.
std::vector< EnumInfo > ChildEnums
llvm::Optional< Location > DefLoc
static void writeNewLine(raw_ostream &OS)
llvm::SmallString< 64 > getRelativeFilePath(const StringRef &CurrentPath) const
Returns the file path for this Info relative to CurrentPath.
std::vector< HeaderHandle > Path
std::vector< Index > Children