view trunk/src/docgen/templates/plaintextwriter.d @ 448:c82b36b9cadf

Simpler writer hierarchy.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Wed, 17 Oct 2007 19:23:56 +0300
parents 49f3afd6a0e8
children
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;

//TODO: this is mostly broken now

/**
 * Writes a plain text document skeleton.
 */
class PlainTextWriter : AbstractWriter!(TemplateWriterFactory, 1), TemplateWriter {
  this(TemplateWriterFactory factory, OutputStream[] outputs) {
    super(factory, 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.templates.title ~ " Reference Manual") ~ \n ~
      factory.options.templates.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
    );
  }
}