comparison trunk/src/cmd/DDoc.d @ 744:7173ece1b696

Wrapped some macro functions inside struct MacroExpander. Warning messages from the macro expansion pass are collected now. Tidied up predefined.ddoc a bit, and added some macros. Added two messages to struct MSG. Added another opCatAssign to class InfoManager.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 09 Feb 2008 22:54:31 +0100
parents 764f660e3909
children 00f872d949ea
comparison
equal deleted inserted replaced
743:764f660e3909 744:7173ece1b696
59 pass1.start(); 59 pass1.start();
60 60
61 // Generate documentation. 61 // Generate documentation.
62 auto dest = new FilePath(destDir); 62 auto dest = new FilePath(destDir);
63 dest.append(mod.getFQN() ~ ".html"); 63 dest.append(mod.getFQN() ~ ".html");
64 InfoManager infoMan2; // Collects warnings from the macro expander.
64 if (verbose) 65 if (verbose)
66 {
65 Stdout.formatln("{} > {}", mod.filePath, dest); 67 Stdout.formatln("{} > {}", mod.filePath, dest);
66 writeDocFile(dest.toString(), mod, mtable, incUndoc); 68 infoMan2 = new InfoManager();
69 }
70 writeDocFile(dest.toString(), mod, mtable, incUndoc, infoMan2);
71 if (infoMan2)
72 infoMan ~= infoMan2.info;
67 } 73 }
68 } 74 }
69 75
70 void writeDocFile(string dest, Module mod, MacroTable mtable, bool incUndoc) 76 void writeDocFile(string dest, Module mod, MacroTable mtable, bool incUndoc,
77 InfoManager infoMan)
71 { 78 {
72 // Create a macro environment for this module. 79 // Create a macro environment for this module.
73 mtable = new MacroTable(mtable); 80 mtable = new MacroTable(mtable);
74 // Define runtime macros. 81 // Define runtime macros.
75 mtable.insert("TITLE", mod.getFQN()); 82 mtable.insert("TITLE", mod.getFQN());
85 auto doc = new DDocEmitter(mtable, incUndoc); 92 auto doc = new DDocEmitter(mtable, incUndoc);
86 doc.emit(mod); 93 doc.emit(mod);
87 // Set BODY macro to the text produced by the DDocEmitter. 94 // Set BODY macro to the text produced by the DDocEmitter.
88 mtable.insert("BODY", doc.text); 95 mtable.insert("BODY", doc.text);
89 // Do the macro expansion pass. 96 // Do the macro expansion pass.
90 auto fileText = expandMacros(mtable, "$(DDOC)"); 97 auto fileText = MacroExpander.expand(mtable, "$(DDOC)", mod.filePath, infoMan);
91 // Finally write the file out to the harddisk. 98 // Finally write the file out to the harddisk.
92 auto file = new File(dest); 99 auto file = new File(dest);
93 file.write(fileText); 100 file.write(fileText);
94 } 101 }
95 102