changeset 468:7f7b2232a9eb

Fixes for the html generation.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Wed, 31 Oct 2007 20:15:16 +0200
parents 32f4c3cb6a41
children e562d455cbbe
files trunk/src/docgen/document/htmlgenerator.d trunk/src/docgen/document/latexgenerator.d trunk/src/docgen/page/htmlwriter.d trunk/src/docgen/page/writer.d trunk/src/docgen/templates/default/html/classes.tpl trunk/src/docgen/templates/default/html/dependencies.tpl trunk/src/docgen/templates/default/html/firstpage.tpl trunk/src/docgen/templates/default/html/listing.tpl trunk/src/docgen/templates/default/html/listings.tpl trunk/src/docgen/templates/default/html/makefile.tpl trunk/src/docgen/templates/default/html/modules.tpl trunk/src/docgen/templates/default/html/pagetemplate.tpl trunk/src/docgen/templates/default/html/pagetemplate2.tpl trunk/src/docgen/templates/default/html/stylesheet.tpl trunk/src/docgen/templates/default/latex/makefile.tpl trunk/src/docgen/tests/doctemplate.d
diffstat 16 files changed, 122 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/docgen/document/htmlgenerator.d	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/document/htmlgenerator.d	Wed Oct 31 20:15:16 2007 +0200
@@ -48,7 +48,7 @@
     generateClasses();
     generateModules();
     generateDependencies();
-    generateMakeFile("", imageFormatExts[options.graph.imageFormat]);
+    generateMakeFile(imageFormatExts[options.graph.imageFormat]);
   }
 
   protected:
@@ -58,10 +58,11 @@
    */
   void generateDoc() {
     writeSimpleFile(docFileNames[0], { docWriter.generateFirstPage(); });
-    writeSimpleFile(docFileNames[1], { docWriter.generateTOC(modules); });
-    writeSimpleFile(docFileNames[2], { docWriter.generateClassSection(); });
-    writeSimpleFile(docFileNames[3], { docWriter.generateModuleSection(); });
-    writeSimpleFile(docFileNames[4], { docWriter.generateListingSection(); });
+    /*
+    writeSimpleFile(docFileNames[1], {
+      docWriter.generateTOC(modules);
+      docWriter.generateCustomPage("pagetemplate2", docgen_version);
+    });*/
   }
 
   /**
@@ -75,22 +76,31 @@
    * Generates documentation for classes.
    */
   void generateClasses() {
-    //auto docFile = outputFile(classesFile);
-    //docFile.close();
+    writeSimpleFile(docFileNames[2], {
+      docWriter.generateClassSection();
+      docWriter.generateCustomPage("pagetemplate2", docgen_version);
+    });
   }
 
   /**
    * Generates documentation for modules.
    */
   void generateModules() {
-    //auto docFile = outputFile(modulesFile);
-    //docFile.close();
+    writeSimpleFile(docFileNames[3], {
+      docWriter.generateModuleSection(modules);
+      docWriter.generateCustomPage("pagetemplate2", docgen_version);
+    });
   }
 
   /**
    * Generates source file listings.
    */
   void generateListings() {
+    writeSimpleFile(docFileNames[4], {
+      docWriter.generateListingSection(modules);
+      docWriter.generateCustomPage("pagetemplate2", docgen_version);
+    });
+
     auto writer = listingFactory.createListingWriter(docWriter, docFormat);
 
     foreach(mod; modules) {
@@ -109,12 +119,16 @@
    */
   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();
+
+      docWriter.generateCustomPage("pagetemplate2", docgen_version);
     });
   }
 }
--- a/trunk/src/docgen/document/latexgenerator.d	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/document/latexgenerator.d	Wed Oct 31 20:15:16 2007 +0200
@@ -61,8 +61,8 @@
     docWriter.generateFirstPage();
     docWriter.generateTOC(modules);
     docWriter.generateClassSection();
-    docWriter.generateModuleSection();
-    docWriter.generateListingSection();
+    docWriter.generateModuleSection(modules);
+    docWriter.generateListingSection(modules);
     docWriter.generateDepGraphSection();
     docWriter.generateIndexSection();
     docWriter.generateLastPage();
--- a/trunk/src/docgen/page/htmlwriter.d	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/page/htmlwriter.d	Wed Oct 31 20:15:16 2007 +0200
@@ -16,44 +16,44 @@
  * Writes a HTML document skeleton.
  */
 class HTMLWriter : AbstractPageWriter!("html") {
+  private:
+
   char[] styleSheetFile;
+
+  public:
   
   this(PageWriterFactory factory, OutputStream[] outputs) {
     super(factory);
   }
 
-  void generateTOC(Module[] modules) {
+  override void generateClassSection() {
     // TODO
-    print.format(getTemplate("toc"));
-  }
-
-  void generateModuleSection() {
-    // TODO
-    print.format(getTemplate("modules"));
+    print.format(getTemplate("classes"), factory.options.templates.title);
   }
 
-  void generateListingSection() {
+  override void generateModuleSection(Module[] modules) {
     // TODO
-    print.format(getTemplate("listings"));
+    print.format(getTemplate("modules"), factory.options.templates.title);
   }
 
-  void generateDepGraphSection() {
+  override void generateListingSection(Module[] modules) {
     // TODO
-    print.format(getTemplate("dependencies"));
+    print.format(getTemplate("listings"), factory.options.templates.title);
   }
 
-  void generateIndexSection() { }
-
-  void generateLastPage() { }
+  override void generateDepGraphSection() {
+    print.format(getTemplate("dependencies"), factory.options.templates.title);
+  }
 
   void generateFirstPage() {
     print.format(
       getTemplate("firstpage"),
       factory.options.templates.title,
       factory.options.templates.versionString,
-      docgen_version,
       factory.options.templates.copyright
     );
+
+    footer();
   }
   
   /**
@@ -76,16 +76,22 @@
     auto content = super.getTemplate(name);
 
     foreach(pageName; [
-      "firstpage"[], "toc"[], "classes"[], "modules"[], "files"[],
-      "dependencies"[], "index"[], "lastpage"[] ]) {
+      "firstpage"[], "toc"[], "classes"[], "modules"[], "listings"[],
+      "dependencies"[], "lastpage"[] ]) {
       if (name == pageName) {
         auto sprint = new Sprint!(char)(5120);
-        return sprint.format(
-          super.getTemplate("pagetemplate"),
-          styleSheetFile,
-          name, // FIXME
-          content,
-          docgen_version);
+        char[] title = factory.options.templates.title ~ " ";
+        switch(name) {
+          case "firstpage": title ~= "Documentation"; break;
+          case "toc": title ~= "TOC"; break;
+          case "classes": title ~= "Class index"; break;
+          case "modules": title ~= "Module index"; break;
+          case "listings": title ~= "File index"; break;
+          case "dependencies": title ~="Dependencies"; break;
+        }
+        return
+          sprint.format(super.getTemplate("pagetemplate"), styleSheetFile, title) ~
+          content;
       }
     }
 
@@ -101,4 +107,13 @@
       }
     }
   }
+
+  protected:
+
+  /**
+   * Writes the page footer.
+   */
+  void footer() {
+    print.format(getTemplate("pagetemplate2"), docgen_version);
+  }
 }
--- a/trunk/src/docgen/page/writer.d	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/page/writer.d	Wed Oct 31 20:15:16 2007 +0200
@@ -49,12 +49,12 @@
   /**
    * Generates module documentation section.
    */
-  void generateModuleSection();
+  void generateModuleSection(Module[] modules);
 
   /**
    * Generates source code listing section.
    */
-  void generateListingSection();
+  void generateListingSection(Module[] modules);
 
   /**
    * Generates dependency graph section.
@@ -130,11 +130,11 @@
       print.format(getTemplate("classes"));
     }
 
-    void generateModuleSection() {
+    void generateModuleSection(Module[] modules) {
       print.format(getTemplate("modules"));
     }
 
-    void generateListingSection() {
+    void generateListingSection(Module[] modules) {
       print.format(getTemplate("listings"));
     }
 
@@ -151,7 +151,13 @@
     }
 
     void generateCustomPage(char[] name, char[][] args ...) {
-      print.format(getTemplate(name), args);
+      switch(args.length) {
+        case 0: print.format(getTemplate(name)); break;
+        case 1: print.format(getTemplate(name), args[0]); break;
+        case 2: print.format(getTemplate(name), args[0], args[1]); break;
+        case 3: print.format(getTemplate(name), args[0], args[1], args[2]); break;
+        default: throw new Exception("Too many arguments");
+      }
     }
 
     //---
--- a/trunk/src/docgen/templates/default/html/classes.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/classes.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,2 +1,1 @@
-<h2>Module {}</h2>
-<pre style="dcode">{}</pre>
+<h1>{0} Class List</h1>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/docgen/templates/default/html/dependencies.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -0,0 +1,1 @@
+<h1>{} Dependencies</h1>
--- a/trunk/src/docgen/templates/default/html/firstpage.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/firstpage.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,4 +1,3 @@
-<h1>{0} Reference Manual</h1>
-<h2>{1}</h2>
-<h2>Generated by {2}</h2>
-<h3>{3}</h3>
+<h1>{0} Documentation</h1>
+<h2 id="version">{1}</h2>
+<h2>© {2}</h2>
--- a/trunk/src/docgen/templates/default/html/listing.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/listing.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,2 +1,1 @@
-<h2>Module {}</h2>
-<pre style="dcode">{}</pre>
\ No newline at end of file
+<pre style="dcode">{}</pre>
--- a/trunk/src/docgen/templates/default/html/listings.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/listings.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,2 +1,1 @@
-<h2>Module {}</h2>
-<pre style="dcode">{}</pre>
+<h1>{0} File List</h1>
--- a/trunk/src/docgen/templates/default/html/makefile.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/makefile.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 for i in *.dot; do
-  F=`echo $i|sed 's/dot/png/'`
-  dot $i -Tpng -o$F
+  F=`echo $i|sed 's/dot/{0}/'`
+  dot $i -T{0} -o$F
 done
 
--- a/trunk/src/docgen/templates/default/html/modules.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/modules.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,2 +1,1 @@
-<h2>Module {}</h2>
-<pre style="dcode">{}</pre>
+<h1>{0} Module List</h1>
--- a/trunk/src/docgen/templates/default/html/pagetemplate.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/pagetemplate.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -16,9 +16,3 @@
     <li><a href="depgraph.html"><span>Dependencies</span></a></li>
   </ul>
 </div>
-<h1>{1}</h1>
-{2}
-<hr />
-<p>Generated by {3}</p>
-</body>
-</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/docgen/templates/default/html/pagetemplate2.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -0,0 +1,4 @@
+<hr />
+<p id="generator">Generated by {0}</p>
+</body>
+</html>
--- a/trunk/src/docgen/templates/default/html/stylesheet.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/html/stylesheet.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -3,3 +3,31 @@
 body {{
 background: #fff;
 }
+
+h1, h2 {{
+text-align: center;
+}
+
+h1 {{
+font-size: 1.5em;
+}
+
+h2#version {{
+font-size: 0.8em;
+}
+
+h2 {{
+font-size: 1.1em;
+}
+
+hr {{
+height: 0;
+border: 0;
+border-bottom: 1px solid black;
+}
+
+#generator {{
+text-align: right;
+font-size: small;
+font-style: italic;
+}
--- a/trunk/src/docgen/templates/default/latex/makefile.tpl	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/templates/default/latex/makefile.tpl	Wed Oct 31 20:15:16 2007 +0200
@@ -1,10 +1,10 @@
 #!/bin/sh
 
 for i in *.dot; do
-  F=`echo $i|sed 's/dot/{2}/'`
-  dot $i -T{2} -o$F
+  F=`echo $i|sed 's/dot/{1}/'`
+  dot $i -T{1} -o$F
 done
 
-pdflatex {1}
+pdflatex {0}
 makeindex document
-pdflatex {1}
+pdflatex {0}
--- a/trunk/src/docgen/tests/doctemplate.d	Wed Oct 31 16:03:11 2007 +0200
+++ b/trunk/src/docgen/tests/doctemplate.d	Wed Oct 31 20:15:16 2007 +0200
@@ -20,8 +20,8 @@
   
   writer.generateFirstPage();
   writer.generateTOC(null);
-  writer.generateModuleSection();
-  writer.generateListingSection();
+  writer.generateModuleSection(null);
+  writer.generateListingSection(null);
   writer.generateDepGraphSection();
   writer.generateIndexSection();
   writer.generateLastPage();