13#include "llvm/Support/YAMLTraits.h"
14#include "llvm/Support/raw_ostream.h"
23LLVM_YAML_IS_SEQUENCE_VECTOR(
Location)
26LLVM_YAML_IS_SEQUENCE_VECTOR(
EnumInfo)
32LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::SmallString<16>)
39template <>
struct ScalarEnumerationTraits<
clang::AccessSpecifier> {
40 static void enumeration(IO &IO, clang::AccessSpecifier &Value) {
41 IO.enumCase(Value,
"Public", clang::AccessSpecifier::AS_public);
42 IO.enumCase(Value,
"Protected", clang::AccessSpecifier::AS_protected);
43 IO.enumCase(Value,
"Private", clang::AccessSpecifier::AS_private);
44 IO.enumCase(Value,
"None", clang::AccessSpecifier::AS_none);
48template <>
struct ScalarEnumerationTraits<
clang::TagTypeKind> {
50 IO.enumCase(Value,
"Struct", clang::TagTypeKind::Struct);
51 IO.enumCase(Value,
"Interface", clang::TagTypeKind::Interface);
52 IO.enumCase(Value,
"Union", clang::TagTypeKind::Union);
53 IO.enumCase(Value,
"Class", clang::TagTypeKind::Class);
54 IO.enumCase(Value,
"Enum", clang::TagTypeKind::Enum);
58template <>
struct ScalarEnumerationTraits<
InfoType> {
71 IO.enumCase(Value,
"ParagraphComment",
74 IO.enumCase(Value,
"InlineCommandComment",
76 IO.enumCase(Value,
"HTMLStartTagComment",
78 IO.enumCase(Value,
"HTMLEndTagComment",
80 IO.enumCase(Value,
"BlockCommandComment",
82 IO.enumCase(Value,
"ParamCommandComment",
84 IO.enumCase(Value,
"TParamCommandComment",
86 IO.enumCase(Value,
"VerbatimBlockComment",
88 IO.enumCase(Value,
"VerbatimBlockLineComment",
90 IO.enumCase(Value,
"VerbatimLineComment",
97template <
unsigned U>
struct ScalarTraits<SmallString<U>> {
99 static void output(
const SmallString<U> &S,
void *, llvm::raw_ostream &OS) {
100 for (
const auto &C : S)
104 static StringRef
input(StringRef Scalar,
void *, SmallString<U> &Value) {
105 Value.assign(Scalar.begin(), Scalar.end());
109 static QuotingType
mustQuote(StringRef) {
return QuotingType::Single; }
115 OS << toHex(toStringRef(S));
119 if (Scalar.size() != 40)
120 return "Error: Incorrect scalar size for USR.";
127 std::string HexString = fromHex(Value);
128 std::copy(HexString.begin(), HexString.end(), USR.begin());
132 static QuotingType
mustQuote(StringRef) {
return QuotingType::Single; }
143 IO.mapOptional(
"Name", I.
Name, SmallString<16>());
144 IO.mapOptional(
"DefaultValue", I.
DefaultValue, SmallString<16>());
148 IO.mapRequired(
"USR", I.
USR);
149 IO.mapOptional(
"Name", I.
Name, SmallString<16>());
150 IO.mapOptional(
"Path", I.
Path, SmallString<128>());
151 IO.mapOptional(
"Namespace", I.
Namespace, llvm::SmallVector<Reference, 4>());
157 IO.mapOptional(
"DefLocation", I.
DefLoc, std::optional<Location>());
158 IO.mapOptional(
"Location", I.
Loc, llvm::SmallVector<Location, 2>());
163 IO.mapOptional(
"TagType", I.
TagType);
164 IO.mapOptional(
"IsTypeDef", I.
IsTypeDef,
false);
165 IO.mapOptional(
"Members", I.
Members);
166 IO.mapOptional(
"Bases", I.
Bases);
167 IO.mapOptional(
"Parents", I.
Parents, llvm::SmallVector<Reference, 4>());
169 llvm::SmallVector<Reference, 4>());
174 IO.mapOptional(
"Template", I.
Template);
179 IO.mapOptional(
"Text", I.
Text, SmallString<64>());
180 IO.mapOptional(
"Name", I.
Name, SmallString<16>());
181 IO.mapOptional(
"Direction", I.
Direction, SmallString<8>());
182 IO.mapOptional(
"ParamName", I.
ParamName, SmallString<16>());
183 IO.mapOptional(
"CloseName", I.
CloseName, SmallString<16>());
184 IO.mapOptional(
"SelfClosing", I.
SelfClosing,
false);
185 IO.mapOptional(
"Explicit", I.
Explicit,
false);
186 IO.mapOptional(
"Args", I.
Args, llvm::SmallVector<SmallString<16>, 4>());
187 IO.mapOptional(
"AttrKeys", I.
AttrKeys,
188 llvm::SmallVector<SmallString<16>, 4>());
190 llvm::SmallVector<SmallString<16>, 4>());
191 IO.mapOptional(
"Children", I.
Children);
199 IO.mapOptional(
"Filename", Loc.
Filename, SmallString<32>());
206 IO.mapOptional(
"Name",
Ref.Name, SmallString<16>());
207 IO.mapOptional(
"QualName",
Ref.QualName, SmallString<16>());
209 IO.mapOptional(
"Path",
Ref.Path, SmallString<128>());
220 IO.mapOptional(
"Name", I.
Name, SmallString<16>());
221 IO.mapOptional(
"DefaultValue", I.
DefaultValue, SmallString<16>());
231 IO.mapOptional(
"Access", I.
Access, clang::AccessSpecifier::AS_none);
255 IO.mapOptional(
"IsVirtual", I.
IsVirtual,
false);
259 IO.mapOptional(
"Access", I.
Access, clang::AccessSpecifier::AS_none);
260 IO.mapOptional(
"IsParent", I.
IsParent,
false);
266 IO.mapOptional(
"Name", I.
Name);
267 IO.mapOptional(
"Value", I.
Value);
268 IO.mapOptional(
"Expr", I.
ValueExpr, SmallString<16>());
275 IO.mapOptional(
"Scoped", I.
Scoped,
false);
276 IO.mapOptional(
"BaseType", I.
BaseType);
277 IO.mapOptional(
"Members", I.
Members);
285 IO.mapOptional(
"IsUsing", I.
IsUsing,
false);
292 IO.mapOptional(
"IsMethod", I.
IsMethod,
false);
294 IO.mapOptional(
"Params", I.
Params);
299 IO.mapOptional(
"Access", I.
Access, clang::AccessSpecifier::AS_none);
300 IO.mapOptional(
"Template", I.
Template);
306 IO.mapOptional(
"Contents", I.
Contents);
313 IO.mapOptional(
"Params", I.
Params);
319 IO.mapOptional(
"Params", I.
Params);
321 std::optional<TemplateSpecializationInfo>());
359 for (
const auto &Group : Infos) {
365 llvm::SmallString<128> Path;
366 llvm::sys::path::native(RootDir, Path);
368 llvm::sys::path::append(Path,
"index.yaml");
370 llvm::sys::path::append(Path, Group.getKey() +
".yaml");
373 std::error_code FileErr;
374 llvm::raw_fd_ostream InfoOS(Path, FileErr, llvm::sys::fs::OF_Text);
376 return llvm::createStringError(FileErr,
"Error opening file '%s'",
385 return llvm::Error::success();
390 llvm::yaml::Output InfoYAML(OS);
393 InfoYAML << *static_cast<clang::doc::NamespaceInfo *>(I);
396 InfoYAML << *static_cast<clang::doc::RecordInfo *>(I);
399 InfoYAML << *static_cast<clang::doc::EnumInfo *>(I);
402 InfoYAML << *static_cast<clang::doc::FunctionInfo *>(I);
405 InfoYAML << *static_cast<clang::doc::TypedefInfo *>(I);
412 return llvm::createStringError(llvm::inconvertibleErrorCode(),
413 "unexpected InfoType");
415 return llvm::Error::success();
419 "Generator for YAML output.");
Generator for YAML documentation.
llvm::Error generateDocumentation(StringRef RootDir, llvm::StringMap< doc::OwnedPtr< doc::Info > > Infos, const ClangDocContext &CDCtx, std::string DirName) override
static const char * Format
llvm::Error generateDocForInfo(Info *I, llvm::raw_ostream &OS, const ClangDocContext &CDCtx) override
@ CK_InlineCommandComment
@ CK_VerbatimBlockLineComment
@ CK_VerbatimBlockComment
@ CK_TParamCommandComment
std::unique_ptr< T > OwnedPtr
T * getPtr(const OwnedPtr< T > &O)
static GeneratorRegistry::Add< YAMLGenerator > YAML(YAMLGenerator::Format, "Generator for YAML output.")
volatile int YAMLGeneratorAnchorSource
std::vector< T > OwningVec
std::array< uint8_t, 20 > SymbolID
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static void infoMapping(IO &IO, Info &I)
static void commentInfoMapping(IO &IO, CommentInfo &I)
static void fieldTypeInfoMapping(IO &IO, FieldTypeInfo &I)
static void symbolInfoMapping(IO &IO, SymbolInfo &I)
static void typeInfoMapping(IO &IO, TypeInfo &I)
static void recordInfoMapping(IO &IO, RecordInfo &I)
Some operations such as code completion produce a set of candidates.
Represents a symbol occurrence in the source file.
llvm::SmallVector< EnumValueInfo, 4 > Members
std::optional< TypeInfo > BaseType
SmallString< 16 > ValueExpr
SmallString< 16 > DefaultValue
llvm::SmallVector< FieldTypeInfo, 4 > Params
std::optional< TemplateInfo > Template
OwningVec< CommentInfo > Description
llvm::SmallString< 128 > Path
llvm::SmallVector< Reference, 4 > Namespace
SmallString< 32 > Filename
OwningVec< CommentInfo > Description
OwningVec< BaseRecordInfo > Bases
llvm::SmallVector< MemberTypeInfo, 4 > Members
std::optional< TemplateInfo > Template
llvm::SmallVector< Reference, 4 > VirtualParents
llvm::SmallVector< Reference, 4 > Parents
OwningVec< FunctionInfo > Functions
OwningVec< TypedefInfo > Typedefs
OwningVec< EnumInfo > Enums
OwningVec< Reference > Records
OwningVec< Reference > Namespaces
llvm::SmallVector< Location, 2 > Loc
std::optional< Location > DefLoc
OwningVec< TemplateParamInfo > Params
std::optional< TemplateSpecializationInfo > Specialization
SmallString< 16 > Contents
SymbolID SpecializationOf
OwningVec< TemplateParamInfo > Params
static void mapping(IO &IO, BaseRecordInfo &I)
static void mapping(IO &IO, EnumInfo &I)
static void mapping(IO &IO, EnumValueInfo &I)
static void mapping(IO &IO, FieldTypeInfo &I)
static void mapping(IO &IO, FunctionInfo &I)
static void mapping(IO &IO, Location &Loc)
static void mapping(IO &IO, MemberTypeInfo &I)
static void mapping(IO &IO, NamespaceInfo &I)
static void mapping(IO &IO, RecordInfo &I)
static void mapping(IO &IO, Reference &Ref)
static void mapping(IO &IO, TemplateInfo &I)
static void mapping(IO &IO, TemplateParamInfo &I)
static void mapping(IO &IO, TemplateSpecializationInfo &I)
static void mapping(IO &IO, TypeInfo &I)
static void mapping(IO &IO, TypedefInfo &I)
static void enumeration(IO &IO, InfoType &Value)
static void enumeration(IO &IO, clang::AccessSpecifier &Value)
static void enumeration(IO &IO, clang::TagTypeKind &Value)
static void output(const SmallString< U > &S, void *, llvm::raw_ostream &OS)
static QuotingType mustQuote(StringRef)
static StringRef input(StringRef Scalar, void *, SmallString< U > &Value)
static SymbolID stringToSymbol(llvm::StringRef Value)
static StringRef input(StringRef Scalar, void *, SymbolID &Value)
static void output(const SymbolID &S, void *, llvm::raw_ostream &OS)
static QuotingType mustQuote(StringRef)