DDocEmitter

Traverses the syntax tree and writes DDoc macros to a string buffer.

abstract
class DDocEmitter : DefaultVisitor2 {}

Constructors

this
this(Module modul, MacroTable mtable, bool includeUndocumented, bool includePrivate, Diagnostics reportDiag, Highlighter tokenHL)

Constructs a DDocEmitter object.

Members

Classes

DDocScope
class DDocScope

Keeps track of previous comments in each scope.

Functions

DECL
void DECL(void delegate() dg, Declaration d, bool writeSemicolon = true)

Writes a declaration to the text buffer.

DESC
void DESC(void delegate() dg = null)

Wraps the DDOC_DECL_DD macro around the text written by dg(). Writes the comment before dg() is called.

MEMBERS
void MEMBERS(cstring kind, cstring name, D members)

Wraps the DDOC_kind_MEMBERS macro around the text written by visit(members).

SYMBOL
void SYMBOL(cstring name, K kind, Declaration d)

Writes a symbol to the text buffer. E.g: $(DIL_SYMBOL scan, Lexer.scan, func, 229, 646);

addSymbol
void addSymbol(cstring name, cstring fqn, K kind, Location begin, Location end)

Adds a symbol to the symbol tree.

ddoc
bool ddoc(Declaration node)

Sets some members and returns true if a comment was found.

emit
char[] emit()

Entry method.

getSymbolFQN
cstring getSymbolFQN(cstring name)

Returns a unique, identifying string for the current symbol.

locationOf
Location locationOf(Token* t, cstring filePath = null)

Returns the location of t.

pushFQN
void pushFQN(cstring name)

Appends to parentFQN.

reportDDocProblem
void reportDDocProblem(Location loc, DDocProblem.Kind kind, MID mid, ...)

Reports a problem.

reportEmptyComment
void reportEmptyComment()

Reports an empty comment.

reportParameters
void reportParameters(Parameters params)
void reportParameters(TemplateParameters params)

Reports a missing params section or undocumented parameters.

reportParameters
void reportParameters(Token* paramsBegin, Token*[] params)
reportUndocumented
void reportUndocumented()

Reports an undocumented symbol.

storeAttributes
void storeAttributes(Declaration d)

Stores the attributes of the current symbol.

write
void write(char c)

Writes a character to the buffer.

write
void write(cstring[] strings...)

Writes an array of strings to the text buffer.

write
void write(Node n)

Writes a Node tree to the buffer.

writeAliasOrTypedef
void writeAliasOrTypedef(T d)

Writes an alias or typedef declaration.

writeAttributes
void writeAttributes(Declaration d)

Writes the attributes of a declaration in brackets.

writeClassOrInterface
void writeClassOrInterface(T d)

Writes a class or interface declaration.

writeComment
void writeComment()

Writes the DDoc comment to the text buffer.

writeCommentText
void writeCommentText(cstring comment)

Scans the comment text and:

  • skips HTML tags
  • escapes '<', '>' and '&' with named HTML entities
  • inserts $(DDOC_BLANKLINE) in place of '\n\n'
  • highlights the tokens in code sections
writeHL
void writeHL(Token[] tokens)

Write highlighted tokens to the buffer.

writeInheritanceList
void writeInheritanceList(BaseClassType[] bases)

Writes bases to the text buffer.

writeParams
void writeParams(Parameters params)

Writes params to the text buffer.

writeStructOrUnion
void writeStructOrUnion(T d)

Writes a struct or union declaration.

writeTemplateParams
void writeTemplateParams()

Writes the current template parameters to the text buffer.

Static functions

getDDocText
cstring getDDocText(Module mod)

Returns the DDoc text of this module.

isDDocFile
bool isDDocFile(Module mod)

Returns true if the source text starts with "Ddoc\n" (ignores letter case.)

Static variables

emptyCmnt
DDocComment emptyCmnt;

An empty comment. Used for undocumented symbols.

specialSections
string[hash_t] specialSections;

List of predefined, special sections.

Structs

SymbolAttributes
struct SymbolAttributes

All attributes a symbol can have.

Variables

astPrinter
ASTPrinter astPrinter;

Used to print Types/Expressions/etc.

cmnt
DDocComment cmnt;

Current comment.

cmntIsDitto
bool cmntIsDitto;

True if current comment is "ditto".

codeExamplesCounter
uint codeExamplesCounter;

Counts code examples in comments. This is used to make the code lines targetable in HTML.

currentAttributes
SymbolAttributes currentAttributes;

The attributes of the current symbol.

currentDecl
Node currentDecl;

The current declaration.

currentSymbolParams
cstring currentSymbolParams;

Saves the attributes of the current symbol.

currentTParams
TemplateParameters currentTParams;

The template parameters of the current declaration.

fqnCount
uint[hash_t] fqnCount;

Counts symbols with the same FQN. This is useful for anchor names that require unique strings.

includePrivate
bool includePrivate;

Include symbols with private protection?

includeUndocumented
bool includeUndocumented;

Include undocumented symbols?

modul
Module modul;

The module.

mtable
MacroTable mtable;

The macro table.

parentFQN
cstring parentFQN;

Reflects the fully qualified name of the current symbol's parent.

prevCmnt
DDocComment prevCmnt;

Previous comment in scope.

prevDeclOffset
size_t prevDeclOffset;

Offset at which to insert a declaration with a "ditto" comment.

reportDiag
Diagnostics reportDiag;

Collects problem messages.

symbolTree
DocSymbol[hash_t] symbolTree;

The symbols that will appear in the result document.

text
CharArray text;

The buffer that is written to.

tokenHL
Highlighter tokenHL;

The token highlighter.

Meta