1 /// Authors: Aziz Köksal, Jari-Matti Mäkelä 2 /// License: GPL3 3 /// $(Maturity average) 4 module dil.doc.DDocXML; 5 6 import dil.doc.DDocEmitter, 7 dil.doc.Macro; 8 import dil.ast.Declarations; 9 import dil.semantic.Module; 10 import dil.Highlighter, 11 dil.Diagnostics; 12 import common; 13 14 /// Traverses the syntax tree and writes DDoc macros to a string buffer. 15 class DDocXMLEmitter : DDocEmitter 16 { 17 /// Constructs a DDocXMLEmitter object. 18 this(Module modul, MacroTable mtable, 19 bool includeUndocumented, bool includePrivate, 20 Diagnostics reportDiag, Highlighter tokenHL) 21 { 22 super(modul, mtable, includeUndocumented, includePrivate, 23 reportDiag, tokenHL); 24 } 25 26 override: 27 //alias visit = super.visit; 28 29 void visit(FunctionDecl d) 30 { 31 if (!ddoc(d)) 32 return; 33 DECL({ 34 write("function, ", "\1TYPE \1RETURNS"); 35 if (d.returnType) write(d.returnType); 36 else write("auto"); 37 write("\2"); 38 writeTemplateParams(); 39 writeParams(d.params); 40 write("\2"); 41 SYMBOL(d.name.text, K.Function, d); 42 }, d); 43 DESC(); 44 } 45 46 void visit(VariablesDecl d) 47 { 48 if (!ddoc(d)) 49 return; 50 foreach (name; d.names) 51 DECL({ 52 write("variable, ", "\1TYPE "); 53 if (d.type) write(d.type); 54 else write("auto"); 55 write("\2 "); 56 SYMBOL(name.text, K.Variable, d); 57 }, d); 58 DESC(); 59 } 60 }