view trunk/src/docgen/templates/plaintextwriter.d @ 444:0bda71dc9c4f

More document template and source listing code.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Wed, 17 Oct 2007 03:12:46 +0300
parents
children 49f3afd6a0e8
line wrap: on
line source

/**
 * Author: Jari-Matti Mäkelä
 * License: GPL3
 */
module docgen.templates.plaintextwriter;

import docgen.templates.writer;
import tango.io.FileConduit : FileConduit;
import tango.io.Print: Print;
import tango.text.convert.Layout : Layout;


/**
 * Writes a plain text document skeleton.
 */
class PlainTextWriter : AbstractTemplateWriter {
  this(TemplateWriterFactory factory, OutputStream[] outputs) {
    super(factory, outputs);
    assert(outputs.length == 1, "Wrong number of outputs");
  }

  void generateTemplate() {
    auto output = new Print!(char)(new Layout!(char), outputs[0]);
    
    char[] line, line2;
    line.length = line2.length = 80;
    line[] = "=";
    line2[] = "-";
    
    char[] h(char[] s) {
      return s ~ \n ~ line[0..s.length] ~ \n;
    }
    
    output(
      h(factory.options.title ~ " Reference Manual") ~ \n ~
      factory.options.versionString ~ \n ~
      "Generated by " ~ docgen_version ~ \n ~
      timeNow() ~ \n \n \n ~
      line2 ~ \n \n \n ~
      h("Table of Contents") ~ \n \n ~
      h("Module documentation") ~ \n \n ~
      h("File listings") ~ \n \n ~
      h("Dependency diagram") ~ \n \n
    );
  }
}