view trunk/src/docgen/page/plaintextwriter.d @ 457:33a4cb255fcc

Cached images, small fixes, reorganizing.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Tue, 30 Oct 2007 15:41:30 +0200
parents
children db7e27b5c180
line wrap: on
line source

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

import docgen.page.writer;
import docgen.misc.textutils;
import tango.io.FileConduit : FileConduit;

//TODO: this is mostly broken now

/**
 * Writes a plain text document skeleton.
 */
class PlainTextWriter : AbstractPageWriter!(1, "plaintext") {
  this(PageWriterFactory factory, OutputStream[] outputs) {
    super(factory, outputs);
  }

  void generateTOC(Module[] modules) {
    // TODO
    print.format(templates["toc"]);
  }

  void generateModuleSection() {
    // TODO
    print.format(templates["modules"]);
  }

  void generateListingSection() {
    // TODO
    print.format(templates["listings"]);
  }

  void generateDepGraphSection() {
    // TODO
    print.format(templates["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
    );
  }

  void addList(char[][] contents, bool ordered) {
    uint[] counters;
    foreach(item; contents) {
      switch(item) {
        case "(": counters ~= 1; continue;
        case ")": counters.length = counters.length - 1; continue;
        default:
        if (counters.length>0)
          for (int i=0; i <= counters.length; i++)
            print(" ");
        if (ordered)
          print(++counters[$-1])(". ")(item)(\n);
        else
          print("* ")(item)(\n);
      }
    }
  }
}