clang-tools 20.0.0git
Public Member Functions | List of all members
clang::clangd::markup::Document Class Reference

A format-agnostic representation for structured text. More...

#include <Markup.h>

Public Member Functions

 Document ()=default
 
 Document (const Document &Other)
 
Documentoperator= (const Document &)
 
 Document (Document &&)=default
 
Documentoperator= (Document &&)=default
 
void append (Document Other)
 
ParagraphaddParagraph ()
 Adds a semantical block that will be separate from others.
 
void addRuler ()
 Inserts a horizontal separator to the document.
 
void addCodeBlock (std::string Code, std::string Language="cpp")
 Adds a block of code.
 
ParagraphaddHeading (size_t Level)
 Heading is a special type of paragraph that will be prepended with Level many '#'s in markdown.
 
BulletListaddBulletList ()
 
std::string asMarkdown () const
 Doesn't contain any trailing newlines.
 
std::string asPlainText () const
 Doesn't contain any trailing newlines.
 

Detailed Description

A format-agnostic representation for structured text.

Allows rendering into markdown and plaintext.

Definition at line 97 of file Markup.h.

Constructor & Destructor Documentation

◆ Document() [1/3]

clang::clangd::markup::Document::Document ( )
default

◆ Document() [2/3]

clang::clangd::markup::Document::Document ( const Document Other)
inline

Definition at line 100 of file Markup.h.

◆ Document() [3/3]

clang::clangd::markup::Document::Document ( Document &&  )
default

Member Function Documentation

◆ addBulletList()

BulletList & clang::clangd::markup::Document::addBulletList ( )

Definition at line 493 of file Markup.cpp.

References Children.

◆ addCodeBlock()

void clang::clangd::markup::Document::addCodeBlock ( std::string  Code,
std::string  Language = "cpp" 
)

Adds a block of code.

This translates to a ``` block in markdown. In plain text representation, the code block will be surrounded by newlines.

Definition at line 480 of file Markup.cpp.

References Children.

◆ addHeading()

Paragraph & clang::clangd::markup::Document::addHeading ( size_t  Level)

Heading is a special type of paragraph that will be prepended with Level many '#'s in markdown.

Definition at line 498 of file Markup.cpp.

References Children.

◆ addParagraph()

Paragraph & clang::clangd::markup::Document::addParagraph ( )

Adds a semantical block that will be separate from others.

Definition at line 473 of file Markup.cpp.

References Children.

Referenced by clang::clangd::CodeCompletion::render().

◆ addRuler()

void clang::clangd::markup::Document::addRuler ( )

Inserts a horizontal separator to the document.

Definition at line 478 of file Markup.cpp.

References Children.

◆ append()

void clang::clangd::markup::Document::append ( Document  Other)

Definition at line 468 of file Markup.cpp.

References Children.

Referenced by operator=(), and clang::clangd::CodeCompletion::render().

◆ asMarkdown()

std::string clang::clangd::markup::Document::asMarkdown ( ) const

Doesn't contain any trailing newlines.

We try to make the markdown human-readable, e.g. avoid extra escaping. At least one client (coc.nvim) displays the markdown verbatim!

Definition at line 485 of file Markup.cpp.

References Children, and clang::clangd::markup::Block::renderMarkdown().

◆ asPlainText()

std::string clang::clangd::markup::Document::asPlainText ( ) const

Doesn't contain any trailing newlines.

Definition at line 489 of file Markup.cpp.

References Children, and clang::clangd::markup::Block::renderPlainText().

◆ operator=() [1/2]

Document & clang::clangd::markup::Document::operator= ( const Document Other)

Definition at line 461 of file Markup.cpp.

References C, and Children.

◆ operator=() [2/2]

Document & clang::clangd::markup::Document::operator= ( Document &&  )
default

References append().


The documentation for this class was generated from the following files: