clang-tools 23.0.0git
JSONGenerator.cpp File Reference

This file contains the implementation of the JSONGenerator, which serializes the clang-doc internal representation (Info structures) into JSON format. More...

#include "Generators.h"
#include "clang/Basic/Specifiers.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/JSON.h"

Go to the source code of this file.

Namespaces

namespace  clang
 ===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
namespace  clang::doc

Functions

template<typename Container, typename SerializationFunc>
static void serializeArray (const Container &Records, Object &Obj, const StringRef Key, SerializationFunc SerializeInfo, const StringRef EndKey="End", function_ref< void(Object &)> UpdateJson=[](Object &Obj) {})
static constexpr unsigned getMaxParamWrapLimit ()
static void insertNonEmpty (StringRef Key, StringRef Value, Object &Obj)
static std::string infoTypeToString (InfoType IT)
static void insertComment (Object &Description, json::Value &Comment, StringRef Key)
 Insert comments into a key in the Description object.
static json::Value extractTextComments (Object *ParagraphComment)
 Takes the nested "Children" array from a comment Object.
static json::Value extractVerbatimComments (json::Array VerbatimLines)
static Object serializeComment (const CommentInfo &I, Object &Description)
static void serializeDescription (const DocList< CommentInfo > &Description, json::Object &Obj, StringRef Key="")
static void serializeTemplateSpecialization (TemplateInfo Template, Object &TemplateObj)
static void insertArray (Object &Obj, json::Value &Array, StringRef Key)
static std::vector< IndexpreprocessCDCtxIndex (Index CDCtxIndex)
static GeneratorRegistry::Add< JSONGenerator > JSON (JSONGenerator::Format, "Generator for JSON output.")

Variables

static auto SerializeTemplateParam

Detailed Description

This file contains the implementation of the JSONGenerator, which serializes the clang-doc internal representation (Info structures) into JSON format.

It handles the mapping of C++ constructs like namespaces, records, functions, and enums to their JSON equivalents, enabling downstream tools to consume the structured documentation data.

Definition in file JSONGenerator.cpp.

Function Documentation

◆ extractTextComments()

json::Value extractTextComments ( Object * ParagraphComment)
static

Takes the nested "Children" array from a comment Object.

Returns
a json::Array of comments, possible json::Value::Kind::Null

Definition at line 187 of file JSONGenerator.cpp.

Referenced by serializeComment(), and serializeDescription().

◆ extractVerbatimComments()

json::Value extractVerbatimComments ( json::Array VerbatimLines)
static

Definition at line 208 of file JSONGenerator.cpp.

Referenced by serializeComment().

◆ getMaxParamWrapLimit()

constexpr unsigned getMaxParamWrapLimit ( )
staticconstexpr

Definition at line 34 of file JSONGenerator.cpp.

Referenced by serializeTemplateSpecialization().

◆ infoTypeToString()

◆ insertArray()

void insertArray ( Object & Obj,
json::Value & Array,
StringRef Key )
static

Definition at line 720 of file JSONGenerator.cpp.

◆ insertComment()

void insertComment ( Object & Description,
json::Value & Comment,
StringRef Key )
static

Insert comments into a key in the Description object.

Parameters
CommentEither an Object or Array, depending on the comment type
KeyThe type (Brief, Code, etc.) of comment to be inserted

Definition at line 158 of file JSONGenerator.cpp.

Referenced by serializeComment(), and serializeDescription().

◆ insertNonEmpty()

void insertNonEmpty ( StringRef Key,
StringRef Value,
Object & Obj )
static

Definition at line 104 of file JSONGenerator.cpp.

◆ JSON()

GeneratorRegistry::Add< JSONGenerator > JSON ( JSONGenerator::Format ,
"Generator for JSON output."  )
static

◆ preprocessCDCtxIndex()

std::vector< Index > preprocessCDCtxIndex ( Index CDCtxIndex)
static

◆ serializeArray()

template<typename Container, typename SerializationFunc>
void serializeArray ( const Container & Records,
Object & Obj,
const StringRef Key,
SerializationFunc SerializeInfo,
const StringRef EndKey = "End",
function_ref< void(Object &)> UpdateJson = [](Object &Obj) {} )
static

Definition at line 557 of file JSONGenerator.cpp.

Referenced by serializeTemplateSpecialization().

◆ serializeComment()

◆ serializeDescription()

void serializeDescription ( const DocList< CommentInfo > & Description,
json::Object & Obj,
StringRef Key = "" )
static

Definition at line 406 of file JSONGenerator.cpp.

References extractTextComments(), insertComment(), and serializeComment().

◆ serializeTemplateSpecialization()

void serializeTemplateSpecialization ( TemplateInfo Template,
Object & TemplateObj )
static

Variable Documentation

◆ SerializeTemplateParam

auto SerializeTemplateParam
static
Initial value:
= [](const TemplateParamInfo &Param,
Object &JsonObj) {
JsonObj["Param"] = Param.Contents;
}

Definition at line 464 of file JSONGenerator.cpp.

Referenced by serializeTemplateSpecialization().