# HG changeset patch # User Jari-Matti M?kel? # Date 1193864636 -7200 # Node ID e48a011e687a7d045d7e77786189f7c8ba1daf13 # Parent e562d455cbbe283c05316b0f09822a94bac81347 Initial plain text output support. diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/config/default.cfg --- a/trunk/src/docgen/config/default.cfg Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/config/default.cfg Wed Oct 31 23:03:56 2007 +0200 @@ -34,6 +34,6 @@ (commentFormat Doxygen) (depth -1) ) - (outputFormats LaTeX HTML) + (outputFormats LaTeX HTML PlainText) (outputDir tmp/) ) diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/docgen.d --- a/trunk/src/docgen/docgen.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/docgen.d Wed Oct 31 23:03:56 2007 +0200 @@ -99,20 +99,20 @@ switch(format) { case DocFormat.LaTeX: + Stdout("Generating LaTeX docs.."); generator = new LaTeXDocGenerator(*options, &parser, graphcache); - Stdout("Generating LaTeX docs.."); break; case DocFormat.HTML: + Stdout("Generating HTML docs.."); generator = new HTMLDocGenerator(*options, &parser, graphcache); - Stdout("Generating HTML docs.."); break; case DocFormat.XML: + Stdout("Generating XML docs.."); generator = new XMLDocGenerator(*options, &parser); - Stdout("Generating XML docs.."); break; case DocFormat.PlainText: - generator = new PlainTextDocGenerator(*options, &parser); Stdout("Generating plain text docs.."); + generator = new PlainTextDocGenerator(*options, &parser, graphcache); break; default: throw new Exception("Format not supported"); } diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/document/generator.d --- a/trunk/src/docgen/document/generator.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/document/generator.d Wed Oct 31 23:03:56 2007 +0200 @@ -14,7 +14,6 @@ import tango.io.FilePath; import tango.io.FileScan; debug import tango.io.Stdout; -import tango.io.Stdout; alias void delegate(ref Module[], ref Edge[], ref Vertex[char[]]) ParserDg; @@ -85,8 +84,7 @@ (new FilePath(outPath(filePath.file))).copy(filePath.toUtf8()); } - Stdout(); - Stdout(scan.files.length)(" static files copied.\n"); + debug Stdout(scan.files.length)(" static files copied.\n"); } FileOutput outputFile(char[] fname) { diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/document/plaintextgenerator.d --- a/trunk/src/docgen/document/plaintextgenerator.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/document/plaintextgenerator.d Wed Oct 31 23:03:56 2007 +0200 @@ -7,17 +7,113 @@ import docgen.document.generator; import docgen.misc.misc; import tango.io.stream.FileStream; +import tango.io.FilePath; import tango.text.Util : replace; -class PlainTextDocGenerator : DefaultDocGenerator { +class PlainTextDocGenerator : DefaultCachingDocGenerator { + private: + + auto docFileNames = [ + "index.txt"[], "toc.txt"[], "classes.txt"[], + "modules.txt"[], "files.txt"[] + ]; + + auto depGraphFile = "depgraph.dot"; + auto depGraphDocFile = "depgraph.txt"; + public: - this(DocGeneratorOptions options, ParserDg parser) { + this(DocGeneratorOptions options, ParserDg parser, GraphCache graphcache) { genDir = "txt"; docFormat = DocFormat.PlainText; - super(options, parser); + super(options, parser, graphcache); + } + + /** + * Generates the documentation. + */ + void generate() { + parseSources(); + + docWriter = pageFactory.createPageWriter( null, docFormat ); + + generateDoc(); + + if (options.listing.enableListings) + generateListings(); + + generateClasses(); + generateModules(); + generateDependencies(); + generateMakeFile(imageFormatExts[options.graph.imageFormat]); + } + + protected: + + /** + * Generates document skeleton. + */ + void generateDoc() { + writeSimpleFile(docFileNames[0], { docWriter.generateFirstPage(); }); + + writeSimpleFile(docFileNames[1], { + docWriter.generateTOC(modules); + }); + } + + /** + * Generates documentation for classes. + */ + void generateClasses() { + writeSimpleFile(docFileNames[2], { + docWriter.generateClassSection(); + }); } - void generate() { /* TODO */ } + /** + * Generates documentation for modules. + */ + void generateModules() { + writeSimpleFile(docFileNames[3], { + docWriter.generateModuleSection(modules); + }); + } + + /** + * Generates source file listings. + */ + void generateListings() { + writeSimpleFile(docFileNames[4], { + docWriter.generateListingSection(modules); + + char[][] contents; + + foreach(mod; modules) { + auto FQN = mod.moduleFQN; + contents ~= FQN ~ " (see " ~ FQN ~ ".d)"; + } + + docWriter.addList(contents, false); + }); + + foreach(mod; modules) + (new FilePath(outPath(mod.moduleFQN ~ ".d"))).copy(mod.filePath); + } + + /** + * Generates dependency graphs. + */ + void generateDependencies() { + writeSimpleFile(depGraphDocFile, { + docWriter.generateDepGraphSection(); + + auto imgFile = outputFile(depGraphFile); + + auto writer = graphFactory.createGraphWriter( docWriter, GraphFormat.Dot ); + writer.generateDepGraph(vertices.values, edges, imgFile); + + imgFile.close(); + }); + } } diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/misc/textutils.d --- a/trunk/src/docgen/misc/textutils.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/misc/textutils.d Wed Oct 31 23:03:56 2007 +0200 @@ -24,7 +24,7 @@ char[] plainTextHeading(char[] s) { char[] line; line.length = 80; - line[] = "="; + line[] = '='; return s ~ \n ~ line[0..s.length].dup ~ \n ~ \n; } @@ -32,7 +32,7 @@ char[] plainTextHorizLine(int l = 80) { char[] line; line.length = 80; - line[] = "-"; + line[] = '-'; return line[0..l].dup ~ \n; } diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/page/htmlwriter.d --- a/trunk/src/docgen/page/htmlwriter.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/page/htmlwriter.d Wed Oct 31 23:03:56 2007 +0200 @@ -25,17 +25,14 @@ } override void generateClassSection() { - // TODO print.format(getTemplate("classes"), factory.options.templates.title); } override void generateModuleSection(Module[] modules) { - // TODO print.format(getTemplate("modules"), factory.options.templates.title); } override void generateListingSection(Module[] modules) { - // TODO print.format(getTemplate("listings"), factory.options.templates.title); } @@ -57,7 +54,7 @@ /** * A hack for figuring out the stylesheet file name. */ - void generateCustomPage(char[] name, char[][] args ...) { + override void generateCustomPage(char[] name, char[][] args ...) { super.generateCustomPage(name, args); if (name == "stylesheet") { diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/page/plaintextwriter.d --- a/trunk/src/docgen/page/plaintextwriter.d Wed Oct 31 21:42:33 2007 +0200 +++ b/trunk/src/docgen/page/plaintextwriter.d Wed Oct 31 23:03:56 2007 +0200 @@ -8,51 +8,36 @@ import docgen.misc.textutils; import tango.io.FileConduit : FileConduit; -//TODO: this is mostly broken now - /** * Writes a plain text document skeleton. */ class PlainTextWriter : AbstractPageWriter!("plaintext") { this(PageWriterFactory factory, OutputStream[] outputs) { - super(factory, outputs); + super(factory); } - void generateTOC(Module[] modules) { - // TODO + override void generateTOC(Module[] modules) { print.format(getTemplate("toc")); } - void generateModuleSection() { - // TODO + override void generateModuleSection(Module[] modules) { print.format(getTemplate("modules")); } - void generateListingSection() { - // TODO + override void generateListingSection(Module[] modules) { print.format(getTemplate("listings")); } void generateDepGraphSection() { - // TODO print.format(getTemplate("dependencies")); } - void generateIndexSection() { } - - void generateLastPage() { } - void generateFirstPage() { - print( - plainTextHeading(factory.options.templates.title ~ " Reference Manual") ~ - factory.options.templates.versionString ~ \n ~ - "Generated by " ~ docgen_version ~ \n ~ - timeNow() ~ \n \n \n ~ - plainTextHorizLine() ~ \n \n ~ - plainTextHeading("Table of Contents") ~ \n ~ - plainTextHeading("Module documentation") ~ \n ~ - plainTextHeading("File listings") ~ \n ~ - plainTextHeading("Dependency diagram") ~ \n + print.format(getTemplate("firstpage"), + plainTextHeading(factory.options.templates.title ~ " Reference Manual"), + factory.options.templates.versionString, + docgen_version, + timeNow() ); } diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/classes.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/classes.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,3 @@ +Class List +---------- + diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/dependencies.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/dependencies.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,3 @@ +Module Dependencies +------------------- + diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/firstpage.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/firstpage.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,7 @@ +{0} + +Version {1} + +Generated by {2} + +{3} diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/listings.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/listings.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,3 @@ +File listings +------------- + diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/makefile.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/makefile.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,7 @@ +#!/bin/sh + +for i in *.dot; do + F=`echo $i|sed 's/dot/{0}/'` + dot $i -T{0} -o$F +done + diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/modules.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/modules.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,3 @@ +Module List +----------- + diff -r e562d455cbbe -r e48a011e687a trunk/src/docgen/templates/default/plaintext/toc.tpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/templates/default/plaintext/toc.tpl Wed Oct 31 23:03:56 2007 +0200 @@ -0,0 +1,10 @@ +Table of Contents +----------------- + +1. Class documentation + +2. Module documentation + +3. File listings + +4. Dependency diagram