14 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H 15 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H 17 #include "clang/AST/Type.h" 18 #include "clang/Basic/Specifiers.h" 19 #include "clang/Tooling/StandaloneExecution.h" 20 #include "llvm/ADT/Optional.h" 21 #include "llvm/ADT/SmallVector.h" 22 #include "llvm/ADT/StringExtras.h" 53 auto FirstCI = std::tie(
Kind,
Text,
Name, Direction, ParamName, CloseName,
54 SelfClosing, Explicit, AttrKeys, AttrValues, Args);
64 llvm::deref<std::equal_to<>>{});
72 auto FirstCI = std::tie(
Kind,
Text,
Name, Direction, ParamName, CloseName,
73 SelfClosing, Explicit, AttrKeys, AttrValues, Args);
79 if (FirstCI < SecondCI)
82 if (FirstCI == SecondCI) {
83 return std::lexicographical_compare(
85 Other.
Children.end(), llvm::deref<std::less<>>());
102 bool SelfClosing =
false;
103 bool Explicit =
false;
105 llvm::SmallVector<SmallString<16>, 4>
107 llvm::SmallVector<SmallString<16>, 4>
109 llvm::SmallVector<SmallString<16>, 4>
111 std::vector<std::unique_ptr<CommentInfo>>
121 : Name(Name), Path(Path), IsInGlobalNamespace(Path.empty()) {}
123 : USR(USR), Name(Name), RefType(IT) {}
127 : USR(USR), Name(Name), RefType(IT), Path(Path),
128 IsInGlobalNamespace(Path.empty()) {}
131 return std::tie(USR,
Name, RefType) ==
148 bool IsInGlobalNamespace =
false;
155 : Type(Type, Field, IT) {}
157 : Type(Type, Field, IT, Path) {}
170 llvm::StringRef
Name)
171 :
TypeInfo(Type, Field, IT, Path), Name(Name) {}
175 :
TypeInfo(RefName, Path), Name(Name) {}
188 llvm::StringRef
Name, AccessSpecifier Access)
189 :
FieldTypeInfo(Type, Field, IT, Path, Name), Access(Access) {}
191 AccessSpecifier Access)
194 AccessSpecifier Access)
198 return std::tie(
Type,
Name, Access) ==
206 AccessSpecifier Access = AccessSpecifier::AS_public;
212 : LineNumber(LineNumber), Filename(std::move(Filename)) {}
214 : LineNumber(LineNumber), Filename(std::move(Filename)),
215 IsFileInRootDir(IsFileInRootDir) {}
218 return std::tie(LineNumber,
Filename) ==
227 return std::tie(LineNumber,
Filename) <
233 bool IsFileInRootDir =
false;
242 : USR(USR), IT(IT), Name(Name) {}
244 : USR(USR), IT(IT), Name(Name), Path(Path) {}
248 virtual ~
Info() =
default;
254 llvm::SmallVector<Reference, 4>
260 void mergeBase(
Info &&I);
261 bool mergeable(
const Info &Other);
263 llvm::SmallString<16> extractName()
const;
267 llvm::Expected<Reference> getEnclosingScope();
297 :
Info(IT, USR, Name, Path) {}
302 llvm::SmallVector<Location, 2>
Loc;
313 bool IsMethod =
false;
316 llvm::SmallVector<FieldTypeInfo, 4>
Params;
321 AccessSpecifier Access = AccessSpecifier::AS_public;
337 TagTypeKind TagType = TagTypeKind::TTK_Struct;
340 bool IsTypeDef =
false;
341 llvm::SmallVector<MemberTypeInfo, 4>
346 llvm::SmallVector<Reference, 4>
349 std::vector<BaseRecordInfo>
364 AccessSpecifier Access,
bool IsParent)
365 :
RecordInfo(USR, Name, Path), IsVirtual(IsVirtual), Access(Access),
366 IsParent(IsParent) {}
369 bool IsVirtual =
false;
372 AccessSpecifier Access = AccessSpecifier::AS_public;
373 bool IsParent =
false;
386 llvm::SmallVector<SmallString<16>, 4>
Members;
393 :
Reference(Name), JumpToSection(JumpToSection) {}
411 llvm::Expected<std::unique_ptr<Info>>
412 mergeInfos(std::vector<std::unique_ptr<Info>> &Values);
420 std::vector<std::string> JsScripts);
421 tooling::ExecutionContext *
ECtx;
443 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_DOC_REPRESENTATION_H Location(int LineNumber, SmallString< 16 > Filename, bool IsFileInRootDir)
std::vector< Index > Children
llvm::SmallVector< Reference, 4 > Namespace
MemberTypeInfo(llvm::StringRef RefName, StringRef Path, llvm::StringRef Name, AccessSpecifier Access)
Info(InfoType IT, SymbolID USR)
std::vector< BaseRecordInfo > Bases
SymbolInfo(InfoType IT, SymbolID USR)
RecordInfo(SymbolID USR, StringRef Name, StringRef Path)
llvm::Optional< std::string > RepositoryUrl
llvm::Optional< Location > DefLoc
std::vector< std::string > JsScripts
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))
NamespaceInfo(SymbolID USR, StringRef Name)
Reference(llvm::StringRef Name, StringRef Path)
std::vector< FunctionInfo > ChildFunctions
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))
FieldTypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path, llvm::StringRef Name)
BaseRecordInfo(SymbolID USR, StringRef Name, StringRef Path, bool IsVirtual, AccessSpecifier Access, bool IsParent)
bool operator==(const SymbolID &Other) const
llvm::SmallVector< Location, 2 > Loc
bool operator==(const TypeInfo &Other) const
Index(StringRef Name, StringRef JumpToSection)
llvm::Optional< SmallString< 16 > > JumpToSection
std::vector< FunctionInfo > ChildFunctions
MemberTypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path, llvm::StringRef Name, AccessSpecifier Access)
std::vector< EnumInfo > ChildEnums
std::vector< HeaderHandle > Path
bool operator==(const Reference &Other) const
static llvm::cl::opt< bool > PublicOnly("public", llvm::cl::desc("Document only public declarations."), llvm::cl::init(false), llvm::cl::cat(ClangDocCategory))
std::vector< Reference > ChildRecords
FunctionInfo(SymbolID USR)
Info(InfoType IT, SymbolID USR, StringRef Name, StringRef Path)
Reference(llvm::StringRef Name)
bool operator==(const MemberTypeInfo &Other) const
llvm::SmallVector< Reference, 4 > VirtualParents
MemberTypeInfo(llvm::StringRef RefName, llvm::StringRef Name, AccessSpecifier Access)
static llvm::cl::opt< std::string > ProjectName("project-name", llvm::cl::desc("Name of project."), llvm::cl::cat(ClangDocCategory))
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name, StringRef Path)
Location(int LineNumber, SmallString< 16 > Filename)
llvm::SmallVector< FieldTypeInfo, 4 > Params
NamespaceInfo(SymbolID USR)
std::string Filename
Filename as a string.
static llvm::cl::opt< std::string > OutDirectory("output", llvm::cl::desc("Directory for outputting generated files."), llvm::cl::init("docs"), llvm::cl::cat(ClangDocCategory))
llvm::SmallVector< SmallString< 16 >, 4 > Members
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))
SymbolInfo(InfoType IT, SymbolID USR, StringRef Name)
bool operator<(const Ref &L, const Ref &R)
bool operator<(const Location &Other) const
std::vector< CommentInfo > Description
std::vector< std::string > UserStylesheets
llvm::Expected< std::unique_ptr< Info > > mergeInfos(std::vector< std::unique_ptr< Info >> &Values)
RecordInfo(SymbolID USR, StringRef Name)
static constexpr llvm::StringLiteral Name
FieldTypeInfo(llvm::StringRef RefName, StringRef Path, llvm::StringRef Name)
TypeInfo(llvm::StringRef RefName, StringRef Path)
llvm::SmallString< 128 > Path
llvm::SmallVector< Reference, 4 > Parents
Reference(SymbolID USR, StringRef Name, InfoType IT)
std::vector< std::unique_ptr< HTMLNode > > Children
bool operator==(const Location &Other) const
tooling::ExecutionContext * ECtx
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
TypeInfo(SymbolID Type, StringRef Field, InfoType IT)
std::vector< Reference > ChildNamespaces
std::vector< Reference > ChildRecords
SmallString< 32 > Filename
NamespaceInfo(SymbolID USR, StringRef Name, StringRef Path)
std::vector< EnumInfo > ChildEnums
bool operator==(const FieldTypeInfo &Other) const
llvm::SmallVector< MemberTypeInfo, 4 > Members
Reference(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
TypeInfo(SymbolID Type, StringRef Field, InfoType IT, StringRef Path)
Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
std::array< uint8_t, 20 > SymbolID
llvm::SmallString< 128 > Path
Info(InfoType IT, SymbolID USR, StringRef Name)
FieldTypeInfo(llvm::StringRef RefName, llvm::StringRef Name)
std::vector< std::string > FilesToCopy
TypeInfo(llvm::StringRef RefName)
const SymbolIndex * Index