12#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MARKUP_H
13#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_MARKUP_H
15#include "llvm/Support/raw_ostream.h"
33 virtual std::unique_ptr<Block>
clone()
const = 0;
38 virtual bool isRuler()
const {
return false; }
50 std::unique_ptr<Block>
clone()
const override;
63 Paragraph &appendCode(llvm::StringRef Code,
bool Preserve =
false);
70 enum ChunkKind {
PlainText, InlineCode, Bold, Emphasized };
74 bool Preserve =
false;
79 bool SpaceBefore =
false;
80 bool SpaceAfter =
false;
82 std::vector<Chunk> Chunks;
89 unsigned EstimatedStringSize = 0;
91 Paragraph &appendChunk(llvm::StringRef Contents, ChunkKind K);
93 llvm::StringRef chooseMarker(llvm::ArrayRef<llvm::StringRef> Options,
94 llvm::StringRef
Text)
const;
95 bool punctuationIndicatesLineBreak(llvm::StringRef Line)
const;
96 bool isHardLineBreakIndicator(llvm::StringRef Rest)
const;
97 bool isHardLineBreakAfter(llvm::StringRef Line, llvm::StringRef Rest)
const;
102class BulletList :
public Block {
110 void renderEscapedMarkdown(llvm::raw_ostream &OS)
const override;
111 void renderMarkdown(llvm::raw_ostream &OS)
const override;
112 void renderPlainText(llvm::raw_ostream &OS)
const override;
113 std::unique_ptr<Block> clone()
const override;
115 class Document &addItem();
118 std::vector<class Document> Items;
125 Document() =
default;
126 Document(
const Document &Other) { *
this = Other; }
127 Document &operator=(
const Document &);
128 Document(Document &&) =
default;
129 Document &operator=(Document &&) =
default;
131 void append(Document Other);
158 std::vector<std::unique_ptr<Block>> Children;
Holds text and knows how to lay it out.
std::string asEscapedMarkdown() const
virtual bool isRuler() const
virtual std::unique_ptr< Block > clone() const =0
virtual void renderPlainText(llvm::raw_ostream &OS) const =0
virtual void renderMarkdown(llvm::raw_ostream &OS) const =0
virtual void renderEscapedMarkdown(llvm::raw_ostream &OS) const =0
std::string asMarkdown() const
std::string asPlainText() const
Represents parts of the markup that can contain strings, like inline code, code block or plain text.
void renderPlainText(llvm::raw_ostream &OS) const override
Paragraph & appendEmphasizedText(llvm::StringRef Text)
Append emphasized text, this translates to the * block in markdown.
std::string asMarkdown() const
Doesn't contain any trailing newlines.
Paragraph & appendText(llvm::StringRef Text)
Append plain text to the end of the string.
std::string asEscapedMarkdown() const
Doesn't contain any trailing newlines and escaped markdown syntax.
void addCodeBlock(std::string Code, std::string Language="cpp")
Append inline code, this translates to the ` block in markdown.
std::string asPlainText() const
Doesn't contain any trailing newlines.
void renderEscapedMarkdown(llvm::raw_ostream &OS) const override
Paragraph & addHeading(size_t Level)
Heading is a special type of paragraph that will be prepended with Level many '#'s in markdown.
std::unique_ptr< Block > clone() const override
void renderMarkdown(llvm::raw_ostream &OS) const override
Paragraph & appendBoldText(llvm::StringRef Text)
Append bold text, this translates to the ** block in markdown.
BulletList & addBulletList()
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//