Mercurial > projects > dil
changeset 473:381044a3feac
Misc fixes & updates.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Thu, 08 Nov 2007 17:44:25 +0200 |
parents | e48a011e687a |
children | e91b224c223b |
files | trunk/src/docgen/config/configurator.d trunk/src/docgen/config/default.cfg trunk/src/docgen/config/reader.d trunk/src/docgen/document/generator.d trunk/src/docgen/document/htmlgenerator.d trunk/src/docgen/document/plaintextgenerator.d trunk/src/docgen/misc/misc.d trunk/src/docgen/misc/options.d trunk/src/docgen/misc/parser.d trunk/src/docgen/moduledoc/htmlwriter.d trunk/src/docgen/moduledoc/writer.d trunk/src/docgen/moduledoc/writers.d trunk/src/docgen/page/writer.d trunk/src/docgen/sourcelisting/plaintextwriter.d trunk/src/docgen/sourcelisting/writer.d trunk/src/docgen/sourcelisting/writers.d trunk/src/docgen/templates/default/html/graphics.tpl trunk/src/docgen/tests/common.d |
diffstat | 18 files changed, 253 insertions(+), 169 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/docgen/config/configurator.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/config/configurator.d Thu Nov 08 17:44:25 2007 +0200 @@ -5,7 +5,7 @@ module docgen.config.configurator; import docgen.config.reader; -import docgen.misc.misc; +import docgen.misc.options; import Integer = tango.text.convert.Integer; import tango.io.stream.FileStream;
--- a/trunk/src/docgen/config/default.cfg Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/config/default.cfg Thu Nov 08 17:44:25 2007 +0200 @@ -1,3 +1,13 @@ +# +# This file contains the default configuration. You don't need to +# worry about this, the system will load the settings automatically. +# +# If you need to customize settings, just take a copy of this or +# write one from scratch and pass the new file location as a +# command line parameter. +# + + (options (graph (imageFormat PNG)
--- a/trunk/src/docgen/config/reader.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/config/reader.d Thu Nov 08 17:44:25 2007 +0200 @@ -32,7 +32,7 @@ foreach(size_t i, c; input) { if (sidx > i) continue; switch(c) { // states space, token, textEnd - case '"': + case '"': // starts a ""-string switch(state) { case 0: char[] buf; @@ -61,11 +61,15 @@ case 1: continue; case 2: err(i); } - case ' ': + case '#': // starts a comment + sidx = i; + while (input[++sidx] != '\n' && sidx<input.length) {} + continue; + case ' ': // whitespace case '\t': case '\n': - case '(': - case ')': + case '(': // begins a block + case ')': // ends a block switch(state) { case 1: end(i); case 0:
--- a/trunk/src/docgen/document/generator.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/document/generator.d Thu Nov 08 17:44:25 2007 +0200 @@ -4,11 +4,13 @@ */ module docgen.document.generator; -import docgen.sourcelisting.writers; -import docgen.page.writers; -import docgen.graphutils.writers; import docgen.misc.misc; import docgen.misc.parser; +public import docgen.misc.options; +import docgen.page.writers; +import docgen.moduledoc.writers; +import docgen.graphutils.writers; +import docgen.sourcelisting.writers; import docgen.config.configurator; import tango.io.stream.FileStream; import tango.io.FilePath; @@ -31,7 +33,8 @@ GraphWriterFactory graphFactory; PageWriterFactory pageFactory; - DefaultListingWriterFactory listingFactory; + ListingWriterFactory listingFactory; + ModuleDocWriterFactory moduleDocFactory; Module[] modules; Edge[] edges; @@ -46,6 +49,7 @@ createGraphWriterFactory(); createPageWriterFactory(); createListingWriterFactory(); + createModuleDocWriterFactory(); // create output dir (new FilePath(options.outputDir ~ "/" ~ genDir)).create(); @@ -72,6 +76,10 @@ listingFactory = new DefaultListingWriterFactory(this); } + void createModuleDocWriterFactory() { + moduleDocFactory = new DefaultModuleDocWriterFactory(this); + } + char[] outPath(char[] file) { return options.outputDir ~ "/" ~ genDir ~ "/" ~ file; }
--- a/trunk/src/docgen/document/htmlgenerator.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/document/htmlgenerator.d Thu Nov 08 17:44:25 2007 +0200 @@ -90,6 +90,9 @@ docWriter.generateModuleSection(modules); docWriter.generateCustomPage("pagetemplate2", docgen_version); }); + +// auto mdw = moduleDocFactory.createModuleDocWriter(docWriter, docFormat); + } /** @@ -101,12 +104,16 @@ char[][] contents; + contents ~= "("; + foreach(mod; modules) { auto FQN = mod.moduleFQN; auto dstFname = replace(mod.moduleFQN.dup, '.', '_') ~ ".html"; contents ~= `<a href="` ~ dstFname ~ `">` ~ FQN ~ "</a>"; } + contents ~= ")"; + docWriter.addList(contents, false); docWriter.generateCustomPage("pagetemplate2", docgen_version);
--- a/trunk/src/docgen/document/plaintextgenerator.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/document/plaintextgenerator.d Thu Nov 08 17:44:25 2007 +0200 @@ -91,14 +91,14 @@ foreach(mod; modules) { auto FQN = mod.moduleFQN; - contents ~= FQN ~ " (see " ~ FQN ~ ".d)"; + contents ~= FQN ~ " (see " ~ replace(FQN.dup, '.', '_') ~ ".d)"; } docWriter.addList(contents, false); }); foreach(mod; modules) - (new FilePath(outPath(mod.moduleFQN ~ ".d"))).copy(mod.filePath); + (new FilePath(outPath(replace(mod.moduleFQN.dup, '.', '_') ~ ".d"))).copy(mod.filePath); } /**
--- a/trunk/src/docgen/misc/misc.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/misc/misc.d Thu Nov 08 17:44:25 2007 +0200 @@ -3,128 +3,11 @@ * License: GPL3 */ module docgen.misc.misc; +import docgen.misc.options; import tango.io.model.IConduit : OutputStream; char[] docgen_version = "Dil document generator 0.1"; -/** Supported document output formats. */ -enum DocFormat { - LaTeX, - XML, - HTML, - PlainText -} - -/** - * Supported comment formats. - * - * http://www.stack.nl/~dimitri/doxygen/docblocks.html - * http://www.digitalmars.com/d/ddoc.html - */ -enum CommentFormat { - Ddoc, - Doxygen -} - -/** Supported image formats. */ -enum ImageFormat { - PNG, - SVG, - GIF, - PDF -} - -/** Image format extensions. */ -const imageFormatExts = [ "png", "svg", "gif", "pdf" ]; - -/** Supported graph writers. */ -enum GraphFormat { - Dot, - ModuleNames, - ModulePaths -} - -struct GraphOptions { - /// image format to use for graphs - ImageFormat imageFormat; - /// maximum depth of dependencies in graphs - uint depth; - /// color of normal modules - char[] nodeColor; - /// color of the modules in cyclic dep relation - char[] cyclicNodeColor; - /// unlocatable module color - char[] unlocatableNodeColor; - /// color of the dependencies - char[] depColor; - /// color of the dependencies in cyclic dep relation - char[] cyclicDepColor; - /// color of the public dependencies - char[] publicDepColor; - /// package color - char[] clusterColor; - /// include unlocatable modules to the dep graph - bool includeUnlocatableModules; - /// highlight imports in cyclic dep relation - bool highlightCyclicEdges; - /// highlight modules in cyclic dep relation - bool highlightCyclicVertices; - /// group modules by package names in dep graph - bool groupByPackageNames; - /// group modules hierarchically or by full package name - bool groupByFullPackageName; -} - -struct ListingOptions { - /// use literate programming symbols [LaTeX] - bool literateStyle; - /// enable source code listings - bool enableListings; -} - -struct TemplateOptions { - /// project title - char[] title; - /// project version - char[] versionString; - /// copyright notice - char[] copyright; - /// paper size [LaTeX] - char[] paperSize; - /// use short file names [HTML] - bool shortFileNames; - /// page template style to use, customizable via docgen/templates - char[] templateStyle; -} - -struct ParserOptions { - /// paths to search for imports - char[][] importPaths; - /// paths to "root files" - char[][] rootPaths; - /// regexps for excluding modules - char[][] strRegexps; - /// comment format [comment parser] - CommentFormat commentFormat; - /// maximum depth of dependencies - uint depth; -} - -struct DocGeneratorOptions { - /// location for the generated output - char[] outputDir; - - /// list of document formats to be generated - DocFormat[] outputFormats; - - GraphOptions graph; - ListingOptions listing; - TemplateOptions templates; - ParserOptions parser; -} - -// --- - interface DocGenerator { DocGeneratorOptions *options(); void generate();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/misc/options.d Thu Nov 08 17:44:25 2007 +0200 @@ -0,0 +1,122 @@ +/** + * Author: Jari-Matti Mäkelä + * License: GPL3 + */ +module docgen.misc.options; + +/** Supported document output formats. */ +enum DocFormat { + LaTeX, + XML, + HTML, + PlainText +} + +/** + * Supported comment formats. + * + * http://www.stack.nl/~dimitri/doxygen/docblocks.html + * http://www.digitalmars.com/d/ddoc.html + */ +enum CommentFormat { + Ddoc, + Doxygen +} + +/** Supported image formats. */ +enum ImageFormat { + PNG, + SVG, + GIF, + PDF +} + +/** Image format extensions. */ +const imageFormatExts = [ "png", "svg", "gif", "pdf" ]; + +/** Supported graph writers. */ +enum GraphFormat { + Dot, + ModuleNames, + ModulePaths +} + +struct GraphOptions { + /// image format to use for graphs + ImageFormat imageFormat; + /// maximum depth of dependencies in graphs + uint depth; + /// color of normal modules + char[] nodeColor; + /// color of the modules in cyclic dep relation + char[] cyclicNodeColor; + /// unlocatable module color + char[] unlocatableNodeColor; + /// color of the dependencies + char[] depColor; + /// color of the dependencies in cyclic dep relation + char[] cyclicDepColor; + /// color of the public dependencies + char[] publicDepColor; + /// package color + char[] clusterColor; + /// include unlocatable modules to the dep graph + bool includeUnlocatableModules; + /// highlight imports in cyclic dep relation + bool highlightCyclicEdges; + /// highlight modules in cyclic dep relation + bool highlightCyclicVertices; + /// group modules by package names in dep graph + bool groupByPackageNames; + /// group modules hierarchically or by full package name + bool groupByFullPackageName; +} + +struct ListingOptions { + /// use literate programming symbols [LaTeX] + bool literateStyle; + /// enable source code listings + bool enableListings; +} + +struct TemplateOptions { + /// project title + char[] title; + /// project version + char[] versionString; + /// copyright notice + char[] copyright; + /// paper size [LaTeX] + char[] paperSize; + /// use short file names [HTML] + bool shortFileNames; + /// page template style to use, customizable via docgen/templates + char[] templateStyle; +} + +struct ParserOptions { + /// paths to search for imports + char[][] importPaths; + /// paths to "root files" + char[][] rootPaths; + /// regexps for excluding modules + char[][] strRegexps; + /// comment format [comment parser] + CommentFormat commentFormat; + /// maximum depth of dependencies + uint depth; +} + +struct DocGeneratorOptions { + /// location for the generated output + char[] outputDir; + + /// list of document formats to be generated + DocFormat[] outputFormats; + + GraphOptions graph; + ListingOptions listing; + TemplateOptions templates; + ParserOptions parser; +} +
--- a/trunk/src/docgen/misc/parser.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/misc/parser.d Thu Nov 08 17:44:25 2007 +0200 @@ -142,7 +142,6 @@ auto imports = mod.imports; - // TODO: add public/private attribute to the dg parameters foreach (importList; imports) foreach(moduleFQN_; importList.getModuleFQNs(dirSep)) { auto loaded_mod = loadModule(moduleFQN_, depth == -1 ? depth : depth-1);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/moduledoc/htmlwriter.d Thu Nov 08 17:44:25 2007 +0200 @@ -0,0 +1,38 @@ +/** + * Author: Jari-Matti Mäkelä + * License: GPL3 + */ +module docgen.moduledoc.htmlwriter; + +import docgen.moduledoc.writer; +import docgen.misc.textutils; + + +/** + * TODO + */ +class HTMLWriter : AbstractWriter!(ModuleDocWriterFactory), ModuleDocWriter { + PageWriter writer; + + this(ModuleDocWriterFactory factory, PageWriter writer) { + super(factory); + this.writer = writer; + } + + void generateModuleDoc(Module mod, OutputStream output) { + + /* + auto inputStream = cast(FileInput)input; + auto content = new char[inputStream.length]; + auto bytesRead = inputStream.read (content); + + assert(bytesRead == inputStream.length, "Error reading source file"); + assert(output == null); + + writer.addListing( + moduleName, + xml_escape(content) + );*/ + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/moduledoc/writer.d Thu Nov 08 17:44:25 2007 +0200 @@ -0,0 +1,17 @@ +/** + * Author: Jari-Matti Mäkelä + * License: GPL3 + */ +module docgen.moduledoc.writer; + +import docgen.misc.misc; +public import docgen.page.writer; +import tango.io.model.IConduit : OutputStream, InputStream; + +interface ModuleDocWriter { + void generateModuleDoc(Module mod, OutputStream output); +} + +interface ModuleDocWriterFactory : WriterFactory { + ModuleDocWriter createModuleDocWriter(PageWriter writer, DocFormat outputFormat); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/moduledoc/writers.d Thu Nov 08 17:44:25 2007 +0200 @@ -0,0 +1,30 @@ +/** + * Author: Jari-Matti Mäkelä + * License: GPL3 + */ +module docgen.moduledoc.writers; + +public import docgen.moduledoc.writer; +//import docgen.moduledoc.latexwriter; +import docgen.moduledoc.htmlwriter; +//import docgen.moduledoc.xmlwriter; + +class DefaultModuleDocWriterFactory : AbstractWriterFactory, ModuleDocWriterFactory { + this(DocGenerator generator) { + super(generator); + } + + ModuleDocWriter createModuleDocWriter(PageWriter writer, DocFormat outputFormat) { + switch (outputFormat) {/* + case DocFormat.LaTeX: + return new LaTeXWriter(this, writer); + case DocFormat.XML: + return new XMLWriter(this, writer);*/ + case DocFormat.HTML: + return new HTMLWriter(this, writer); + default: + throw new Exception("Moduledoc writer type does not exist!"); + } + } +} +
--- a/trunk/src/docgen/page/writer.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/page/writer.d Thu Nov 08 17:44:25 2007 +0200 @@ -5,6 +5,7 @@ module docgen.page.writer; public import docgen.misc.misc; +public import docgen.misc.options; import tango.io.model.IConduit : OutputStream; import tango.util.time.Date; import tango.util.time.Clock; @@ -215,7 +216,7 @@ date.asDay(), date.asMonth(), date.day, - date.year); + date.year).dup; } } }
--- a/trunk/src/docgen/sourcelisting/plaintextwriter.d Wed Oct 31 23:03:56 2007 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/** - * Author: Jari-Matti Mäkelä - * License: GPL3 - */ -module docgen.sourcelisting.plaintextwriter; - -import docgen.sourcelisting.writer; -import docgen.misc.textutils; -//import dil.Parser; -import tango.io.FilePath; - -/** - * TODO - */ -class PlainTextWriter : AbstractWriter!(ListingWriterFactory), ListingWriter { - PageWriter writer; - - this(ListingWriterFactory factory, PageWriter writer) { - super(factory); - this.writer = writer; - } - - //void generateListing(Parser parser) { /* TODO */ } - - void generateListing(InputStream input, OutputStream output, char[] moduleName) { - output.copy(input); - - writer.addListing( - moduleName, - FilePath((cast(Object)output.conduit).toUtf8()).file - ); - } -}
--- a/trunk/src/docgen/sourcelisting/writer.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/sourcelisting/writer.d Thu Nov 08 17:44:25 2007 +0200 @@ -4,7 +4,7 @@ */ module docgen.sourcelisting.writer; -public import docgen.misc.misc; +import docgen.misc.misc; public import docgen.page.writer; //import dil.Parser; import tango.io.model.IConduit : OutputStream, InputStream;
--- a/trunk/src/docgen/sourcelisting/writers.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/sourcelisting/writers.d Thu Nov 08 17:44:25 2007 +0200 @@ -8,7 +8,6 @@ import docgen.sourcelisting.latexwriter; import docgen.sourcelisting.htmlwriter; import docgen.sourcelisting.xmlwriter; -import docgen.sourcelisting.plaintextwriter; class DefaultListingWriterFactory : AbstractWriterFactory, ListingWriterFactory { this(DocGenerator generator) { @@ -23,8 +22,6 @@ return new XMLWriter(this, writer); case DocFormat.HTML: return new HTMLWriter(this, writer); - case DocFormat.PlainText: - return new PlainTextWriter(this, writer); default: throw new Exception("Listing writer type does not exist!"); }
--- a/trunk/src/docgen/templates/default/html/graphics.tpl Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/templates/default/html/graphics.tpl Thu Nov 08 17:44:25 2007 +0200 @@ -1,1 +1,1 @@ -<img src="{}" /> \ No newline at end of file +<p><img src="{}" /></p>
--- a/trunk/src/docgen/tests/common.d Wed Oct 31 23:03:56 2007 +0200 +++ b/trunk/src/docgen/tests/common.d Thu Nov 08 17:44:25 2007 +0200 @@ -5,6 +5,7 @@ module docgen.tests.common; import docgen.misc.misc; +import docgen.misc.options; import docgen.config.configurator; class TestDocGenerator : DocGenerator {