class SymbolGraphSerializer

Declaration

class SymbolGraphSerializer : public APISerializer { /* full declaration omitted */ };

Description

The serializer that organizes API information in the Symbol Graph format. The Symbol Graph format (https://github.com/apple/swift-docc-symbolkit) models an API set as a directed graph, where nodes are symbol declarations, and edges are relationships between the connected symbols.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:37

Inherits from: APISerializer

Member Variables

private llvm::json::Array Symbols
A JSON array of formatted symbols in \c APISet.
private llvm::json::Array Relationships
A JSON array of formatted symbol relationships in \c APISet.
private clang::extractapi::SymbolGraphSerializer:: PathComponentStack PathComponents
Note: this is used to serialize the ``pathComponents`` field of symbols in the Symbol Graph.
private static const llvm::VersionTuple FormatVersion
The Symbol Graph format version used by this serializer.

Inherited from APISerializer:

protected API
protected ProductName
protected Options

Method Overview

Inherited from APISerializer:

Methods

SymbolGraphSerializer(
    const clang::extractapi::APISet& API,
    llvm::StringRef ProductName,
    clang::extractapi::APISerializerOption
        Options = {})

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:170

Parameters

const clang::extractapi::APISet& API
llvm::StringRef ProductName
clang::extractapi::APISerializerOption Options = {}

virtual void anchor()

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:38

static llvm::StringRef getRelationshipString(
    clang::extractapi::SymbolGraphSerializer::
        RelationshipKind Kind)

Description

Get the string representation of the relationship kind.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:95

Parameters

clang::extractapi::SymbolGraphSerializer:: RelationshipKind Kind

clang::extractapi::SymbolGraphSerializer::
    PathComponentGuard
    makePathComponentGuard(
        llvm::StringRef Component)

Description

Push a component to the current path components stack.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:167

Parameters

llvm::StringRef Component
The component to push onto the path components stack.

Returns

A PathComponentGuard responsible for removing the latest component from the stack on scope exit.

llvm::json::Object serialize()

Description

Serialize the APIs in \c APISet in the Symbol Graph format.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:73

Returns

a JSON object that contains the root of the formatted Symbol Graph.

void serialize(llvm::raw_ostream& os)

Description

Implement the APISerializer::serialize interface. Wrap serialize(void) and write out the serialized JSON object to \p os.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:77

Parameters

llvm::raw_ostream& os

template <typename RecordTy>
Optional<llvm::json::Object> serializeAPIRecord(
    const RecordTy& Record) const

Description

Format the common API information for \p Record. This handles the shared information of all kinds of API records, for example identifier and source location. The resulting object is then augmented with kind-specific symbol information by the caller. This method also checks if the given \p Record should be skipped during serialization.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:126

Templates

RecordTy

Parameters

const RecordTy& Record

Returns

\c None if this \p Record should be skipped, or a JSON object containing common symbol information of \p Record.

void serializeEnumRecord(
    const clang::extractapi::EnumRecord& Record)

Description

Serialize an enum record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:148

Parameters

const clang::extractapi::EnumRecord& Record

void serializeGlobalFunctionRecord(
    const clang::extractapi::GlobalFunctionRecord&
        Record)

Description

Serialize a global function record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:142

Parameters

const clang::extractapi::GlobalFunctionRecord& Record

void serializeGlobalVariableRecord(
    const clang::extractapi::GlobalVariableRecord&
        Record)

Description

Serialize a global variable record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:145

Parameters

const clang::extractapi::GlobalVariableRecord& Record

void serializeMacroDefinitionRecord(
    const clang::extractapi::
        MacroDefinitionRecord& Record)

Description

Serialize a macro defintion record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:157

Parameters

const clang::extractapi::MacroDefinitionRecord& Record

template <typename MemberTy>
void serializeMembers(
    const clang::extractapi::APIRecord& Record,
    const SmallVector<std::unique_ptr<MemberTy>>&
        Members)

Description

Helper method to serialize second-level member records of \p Record and the member-of relationships.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:131

Templates

MemberTy

Parameters

const clang::extractapi::APIRecord& Record
const SmallVector<std::unique_ptr<MemberTy>>& Members

llvm::json::Object serializeMetadata() const

Description

Synthesize the metadata section of the Symbol Graph format. The metadata section describes information about the Symbol Graph itself, including the format version and the generator information.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:102

llvm::json::Object serializeModule() const

Description

Synthesize the module section of the Symbol Graph format. The module section contains information about the product that is defined by the given API set. Note that "module" here is not to be confused with the Clang/C++ module concept.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:110

void serializeObjCContainerRecord(
    const clang::extractapi::ObjCContainerRecord&
        Record)

Description

Serialize an Objective-C container record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:154

Parameters

const clang::extractapi::ObjCContainerRecord& Record

void serializeRelationship(
    clang::extractapi::SymbolGraphSerializer::
        RelationshipKind Kind,
    clang::extractapi::SymbolReference Source,
    clang::extractapi::SymbolReference Target)

Description

Serialize the \p Kind relationship between \p Source and \p Target. Record the relationship between the two symbols in SymbolGraphSerializer::Relationships.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:138

Parameters

clang::extractapi::SymbolGraphSerializer:: RelationshipKind Kind
clang::extractapi::SymbolReference Source
clang::extractapi::SymbolReference Target

void serializeStructRecord(
    const clang::extractapi::StructRecord& Record)

Description

Serialize a struct record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:151

Parameters

const clang::extractapi::StructRecord& Record

void serializeTypedefRecord(
    const clang::extractapi::TypedefRecord&
        Record)

Description

Serialize a typedef record.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:160

Parameters

const clang::extractapi::TypedefRecord& Record

bool shouldSkip(
    const clang::extractapi::APIRecord& Record)
    const

Description

Determine if the given \p Record should be skipped during serialization.

Declared at: clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h:113

Parameters

const clang::extractapi::APIRecord& Record