Mercurial > projects > dil
diff trunk/src/docgen/docgen.d @ 456:de2675bc9afa
Dependency lists, minor cleanup.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Tue, 30 Oct 2007 02:35:56 +0200 |
parents | f92505ad18ab |
children | 33a4cb255fcc |
line wrap: on
line diff
--- a/trunk/src/docgen/docgen.d Mon Oct 29 21:27:02 2007 +0200 +++ b/trunk/src/docgen/docgen.d Tue Oct 30 02:35:56 2007 +0200 @@ -15,7 +15,8 @@ import tango.text.Ascii; import tango.text.Util : replace; import tango.io.FilePath; -debug import tango.io.Stdout; + +import tango.io.Stdout; template DefaultDocGenerator(char[] genDir) { abstract class DefaultDocGenerator : DocGenerator { @@ -37,7 +38,7 @@ // TODO: constructor for situations where parsing has happened elsewhere - char[] outPath(char[] file) { + protected char[] outPath(char[] file) { return options.outputDir ~ "/" ~ genDir ~ "/" ~ file; } @@ -91,6 +92,25 @@ } } +class HTMLDocGenerator : DefaultDocGenerator!("html") { + this(DocGeneratorOptions options) { + super(options); + } + public void generate() { /* TODO */ } +} +class XMLDocGenerator : DefaultDocGenerator!("xml") { + this(DocGeneratorOptions options) { + super(options); + } + public void generate() { /* TODO */ } +} +class PlainTextDocGenerator : DefaultDocGenerator!("txt") { + this(DocGeneratorOptions options) { + super(options); + } + public void generate() { /* TODO */ } +} + /** * Main routine for LaTeX doc generation. */ @@ -214,15 +234,53 @@ } } +void usage() { + Stdout( + "Usage: docgen rootpath importpath_1 ... importpath_n outputdir" + ).newline; +} + void main(char[][] args) { + Stdout(docgen_version).newline.newline; + + if (args.length<3) { + usage(); + return; + } + Configurator config = new DefaultConfigurator(); auto options = config.getConfiguration(); options.parser.rootPaths = [ args[1] ]; - options.parser.importPaths = [ args[2] ]; - options.outputDir = args[3]; + options.parser.importPaths = args[2..$-1]; + options.outputDir = args[$-1]; - auto generator = new LaTeXDocGenerator(*options); - - generator.generate(); + foreach(format; options.outputFormats) { + switch(format) { + case DocFormat.LaTeX: + auto generator = new LaTeXDocGenerator(*options); + Stdout("Generating LaTeX docs.."); + generator.generate(); + Stdout("done.").newline; + break; + case DocFormat.HTML: + auto generator = new HTMLDocGenerator(*options); + Stdout("Generating HTML docs.."); + generator.generate(); + Stdout("done.").newline; + break; + case DocFormat.XML: + auto generator = new XMLDocGenerator(*options); + Stdout("Generating XML docs.."); + generator.generate(); + Stdout("done.").newline; + break; + case DocFormat.PlainText: + auto generator = new PlainTextDocGenerator(*options); + Stdout("Generating plain text docs.."); + generator.generate(); + Stdout("done.").newline; + break; + } + } }