Mercurial > projects > dil
comparison trunk/src/docgen/docgen.d @ 729:ec8dd7b8bf0c
Updated graph type.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Sun, 03 Feb 2008 19:43:53 +0200 |
parents | e48a011e687a |
children | 30e6f1b302a1 |
comparison
equal
deleted
inserted
replaced
728:41cad5ca4863 | 729:ec8dd7b8bf0c |
---|---|
34 auto options = config.getConfiguration(); | 34 auto options = config.getConfiguration(); |
35 options.parser.rootPaths = [ args[1] ]; | 35 options.parser.rootPaths = [ args[1] ]; |
36 options.parser.importPaths = args[2..$-1]; | 36 options.parser.importPaths = args[2..$-1]; |
37 options.outputDir = args[$-1]; | 37 options.outputDir = args[$-1]; |
38 | 38 |
39 alias DepGraph.Vertex Vertex; | |
40 alias DepGraph.Edge Edge; | |
41 | |
39 Module[] cachedModules; | 42 Module[] cachedModules; |
40 Edge[] cachedEdges; | 43 DepGraph cachedGraph; |
41 Vertex[char[]] cachedVertices; | |
42 | 44 |
43 void parser(ref Module[] modules, ref Edge[] edges, ref Vertex[char[]] vertices) { | 45 void parser(ref Module[] modules, ref DepGraph depGraph) { |
44 if (cachedModules != null) { | 46 Edge[] edges; |
47 Vertex[char[]] vertices; | |
48 | |
49 if (cachedGraph != null) { | |
45 modules = cachedModules; | 50 modules = cachedModules; |
46 edges = cachedEdges; | 51 depGraph = cachedGraph; |
47 vertices = cachedVertices; | |
48 return; | 52 return; |
49 } | 53 } |
50 | 54 |
51 int id = 1; | 55 int id = 1; |
52 | 56 |
59 (char[] fqn, char[] path, Module m) { | 63 (char[] fqn, char[] path, Module m) { |
60 if (m is null) { | 64 if (m is null) { |
61 if (fqn in vertices) { | 65 if (fqn in vertices) { |
62 debug Stdout.format("{} already set.\n", fqn); | 66 debug Stdout.format("{} already set.\n", fqn); |
63 return; | 67 return; |
64 | |
65 } | 68 } |
66 auto vertex = new Vertex(fqn, path, id++); | 69 auto vertex = new Vertex(fqn, path, id++); |
67 vertex.type = VertexType.UnlocatableModule; | |
68 vertices[fqn] = vertex; | 70 vertices[fqn] = vertex; |
69 debug Stdout.format("Setting {} = {}.\n", fqn, path); | 71 debug Stdout.format("Setting {} = {}.\n", fqn, path); |
70 | |
71 } else { | 72 } else { |
72 vertices[m.moduleFQN] = new Vertex(m.moduleFQN, m.filePath, id++); | 73 vertices[m.moduleFQN] = new Vertex(m.moduleFQN, m.filePath, id++); |
73 debug Stdout.format("Setting {} = {}.\n", m.moduleFQN, m.filePath); | 74 debug Stdout.format("Setting {} = {}.\n", m.moduleFQN, m.filePath); |
74 } | 75 } |
75 }, | 76 }, |
76 (Module imported, Module importer, bool isPublic) { | 77 (Module imported, Module importer, bool isPublic) { |
77 debug Stdout.format("Connecting {} - {}.\n", imported.moduleFQN, importer.moduleFQN); | 78 debug Stdout.format("Connecting {} - {}.\n", imported.moduleFQN, importer.moduleFQN); |
78 auto edge = vertices[imported.moduleFQN].addChild(vertices[importer.moduleFQN]); | 79 auto edge = vertices[imported.moduleFQN].addChild(vertices[importer.moduleFQN]); |
79 edge.type = isPublic ? EdgeType.PublicDependency : EdgeType.Dependency; | 80 edge.isPublic = isPublic; |
80 edge.type = id % 2 ? EdgeType.PublicDependency : EdgeType.Dependency; // FIXME: temporary feature for demonstrating public imports | |
81 edges ~= edge; | 81 edges ~= edge; |
82 }, | 82 }, |
83 modules | 83 modules |
84 ); | 84 ); |
85 | 85 |
86 modules.sort( | 86 modules.sort( |
87 (Module a, Module b){ return icompare(a.moduleFQN, b.moduleFQN); } | 87 (Module a, Module b){ return icompare(a.moduleFQN, b.moduleFQN); } |
88 ); | 88 ); |
89 | 89 |
90 cachedVertices = vertices; | 90 depGraph.edges = edges; |
91 depGraph.vertices = vertices.values; | |
92 | |
93 cachedGraph = depGraph; | |
91 cachedModules = modules; | 94 cachedModules = modules; |
92 cachedEdges = edges; | |
93 } | 95 } |
94 | 96 |
95 GraphCache graphcache = new DefaultGraphCache(); | 97 GraphCache graphcache = new DefaultGraphCache(); |
96 | 98 |
97 foreach(format; options.outputFormats) { | 99 foreach(format; options.outputFormats) { |