view trunk/src/docgen/graphutils/modulepathwriter.d @ 729:ec8dd7b8bf0c

Updated graph type.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Sun, 03 Feb 2008 19:43:53 +0200
parents db7e27b5c180
children
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.Print: Print;
import tango.text.convert.Layout : Layout;

class ModulePathWriter : AbstractGraphWriter {
  public:

  this(GraphWriterFactory factory, PageWriter writer) {
    super(factory, writer);
  }

  void generateDepGraph(DepGraph depGraph, OutputStream imageFile) {
    char[][] contents;

    auto edges = depGraph.edges;
    auto vertices = depGraph.vertices;

    void doList(DepGraph.Vertex[] v, uint level) {
      if (!level) return;

      contents ~= "(";

      foreach (vertex; v) {
        contents ~= vertex.location;
        if (vertex.outgoing.length)
          doList(vertex.outgoing, level-1);
      }

      contents ~= ")";
    }

    doList(vertices, factory.options.graph.depth);

    writer.addList(contents, false);
  }
}