Mercurial > projects > dil
diff trunk/src/docgen/document/generator.d @ 466:db7e27b5c180
Fixed parts of HTML output, some reorganizing.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Wed, 31 Oct 2007 15:17:20 +0200 |
parents | b7503e02fbe7 |
children | 32f4c3cb6a41 |
line wrap: on
line diff
--- a/trunk/src/docgen/document/generator.d Tue Oct 30 20:27:24 2007 +0100 +++ b/trunk/src/docgen/document/generator.d Wed Oct 31 15:17:20 2007 +0200 @@ -16,83 +16,108 @@ alias void delegate(ref Module[], ref Edge[], ref Vertex[char[]]) ParserDg; -template DefaultDocGenerator(char[] genDir) { - abstract class DefaultDocGenerator : DocGenerator { - DocGeneratorOptions m_options; - ParserDg m_parser; - PageWriter docWriter; +abstract class DefaultDocGenerator : DocGenerator { + protected: + + DocFormat docFormat; + auto makeFile = "make.sh"; + char[] genDir; + + DocGeneratorOptions m_options; + ParserDg m_parser; + PageWriter docWriter; - GraphWriterFactory graphFactory; - PageWriterFactory pageFactory; - DefaultListingWriterFactory listingFactory; - - Module[] modules; - Edge[] edges; - Vertex[char[]] vertices; + GraphWriterFactory graphFactory; + PageWriterFactory pageFactory; + DefaultListingWriterFactory listingFactory; + + Module[] modules; + Edge[] edges; + Vertex[char[]] vertices; + + public: + + this(DocGeneratorOptions options, ParserDg parser) { + m_options = options; + m_parser = parser; - this(DocGeneratorOptions options, ParserDg parser) { - m_options = options; - m_parser = parser; + createGraphWriterFactory(); + createPageWriterFactory(); + createListingWriterFactory(); - createGraphWriterFactory(); - createPageWriterFactory(); - createListingWriterFactory(); + // create output dir + (new FilePath(options.outputDir ~ "/" ~ genDir)).create(); + } + + DocGeneratorOptions *options() { + return &m_options; + } - // create output dir - (new FilePath(options.outputDir ~ "/" ~ genDir)).create(); - } + protected: + + void createGraphWriterFactory() { + graphFactory = new DefaultGraphWriterFactory(this); + } - protected void createGraphWriterFactory() { - graphFactory = new DefaultGraphWriterFactory(this); - } + void createPageWriterFactory() { + pageFactory = new DefaultPageWriterFactory(this); + } + + void createListingWriterFactory() { + listingFactory = new DefaultListingWriterFactory(this); + } - protected void createPageWriterFactory() { - pageFactory = new DefaultPageWriterFactory(this); - } + char[] outPath(char[] file) { + return options.outputDir ~ "/" ~ genDir ~ "/" ~ file; + } + + FileOutput outputFile(char[] fname) { + return new FileOutput(outPath(fname)); + } - protected void createListingWriterFactory() { - listingFactory = new DefaultListingWriterFactory(this); - } + void parseSources() { + m_parser(modules, edges, vertices); + } + + //--- - protected char[] outPath(char[] file) { - return options.outputDir ~ "/" ~ genDir ~ "/" ~ file; - } + void writeSimpleFile(char[] fname, void delegate() dg) { + auto docFile = outputFile(fname); + + docWriter.setOutput([docFile]); + dg(); + + docFile.close(); + } - protected void parseSources() { - m_parser(modules, edges, vertices); - } + /** + * Generates "makefile" for processing e.g. .dot files. + */ + void generateMakeFile(char[][] args ...) { + writeSimpleFile(makeFile, { docWriter.generateCustomPage("makefile", args); } ); + } + +} - void createDepGraph(char[] depGraphFile) { - auto imgFile = new FileOutput(outPath(depGraphFile)); - - auto writer = graphFactory.createGraphWriter( docWriter, GraphFormat.Dot ); +abstract class DefaultCachingDocGenerator : DefaultDocGenerator, CachingDocGenerator { + private: + + GraphCache m_graphCache; - writer.generateDepGraph(vertices.values, edges, imgFile); + public: - imgFile.close(); - } + this(DocGeneratorOptions options, ParserDg parser, GraphCache graphCache) { + super(options, parser); + m_graphCache = graphCache; + } + + GraphCache graphCache() { + return m_graphCache; + } - public DocGeneratorOptions *options() { - return &m_options; - } + protected: + + void createGraphWriterFactory() { + graphFactory = new DefaultCachingGraphWriterFactory(this); } } - -template DefaultCachingDocGenerator(char[] genDir) { - abstract class DefaultCachingDocGenerator : DefaultDocGenerator!(genDir), CachingDocGenerator { - GraphCache m_graphCache; - - this(DocGeneratorOptions options, ParserDg parser, GraphCache graphCache) { - super(options, parser); - m_graphCache = graphCache; - } - - GraphCache graphCache() { - return m_graphCache; - } - - protected void createGraphWriterFactory() { - graphFactory = new DefaultCachingGraphWriterFactory(this); - } - } -}