view trunk/src/docgen/document/plaintextwriter.d @ 456:de2675bc9afa

Dependency lists, minor cleanup.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Tue, 30 Oct 2007 02:35:56 +0200
parents f658ec4a15dd
children
line wrap: on
line source

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

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

//TODO: this is mostly broken now

/**
 * Writes a plain text document skeleton.
 */
class PlainTextWriter : AbstractDocumentWriter!(1, "plaintext") {
  this(DocumentWriterFactory 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);
      }
    }
  }
}