view trunk/src/docgen/graphutils/modulepathwriter.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 3f44c38bf870
line wrap: on
line source

/**
 * Author: Aziz Köksal & Jari-Matti Mäkelä
 * License: GPL3
 */
module docgen.graphutils.modulepathwriter;
import docgen.graphutils.writer;

import tango.io.FileConduit : FileConduit;
import tango.io.Print: Print;
import tango.text.convert.Layout : Layout;

/**
 * TODO: add support for html/xml/latex?
 */
class ModulePathWriter : AbstractWriter!(GraphWriterFactory, 1), GraphWriter {
  this(GraphWriterFactory factory, OutputStream[] outputs) {
    super(factory, outputs);
  }

  void generateGraph(Vertex[] vertices, Edge[] edges) {
    auto output = new Print!(char)(new Layout!(char), outputs[0]);

    void doPaths(Vertex[] v, uint level, char[] indent = "") {
      if (!level) return;

      foreach (vertex; v) {
        output(indent)(vertex.location).newline;
        if (vertex.outgoing.length)
          doPaths(vertex.outgoing, level-1, indent ~ "  ");
      }
    }

    doPaths(vertices, factory.options.graph.depth);
  }
}