Mercurial > projects > dil
annotate trunk/src/docgen/docgen.d @ 735:30e6f1b302a1
Forgot this, fixes segfault.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Sun, 03 Feb 2008 22:15:51 +0200 |
parents | ec8dd7b8bf0c |
children | 2eee29aaa357 |
rev | line source |
---|---|
395
ac9cd48151b6
Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
1 /** |
ac9cd48151b6
Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
2 * Author: Jari-Matti Mäkelä |
ac9cd48151b6
Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
3 * License: GPL3 |
ac9cd48151b6
Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
4 */ |
441 | 5 module docgen.docgen; |
395
ac9cd48151b6
Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
6 |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
7 import docgen.graphutils.writers; |
455
f92505ad18ab
Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
454
diff
changeset
|
8 import docgen.config.configurator; |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
9 import docgen.document.latexgenerator; |
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
10 import docgen.document.htmlgenerator; |
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
11 import docgen.document.xmlgenerator; |
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
12 import docgen.document.plaintextgenerator; |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
13 |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
14 import tango.core.Array; |
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
15 import tango.text.Ascii; |
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
16 import tango.io.Stdout; |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
17 |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
18 void usage() { |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
19 Stdout( |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
20 "Usage: docgen rootpath importpath_1 ... importpath_n outputdir" |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
21 ).newline; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
22 } |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
23 |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
24 void main(char[][] args) { |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
25 Stdout(docgen_version).newline.newline; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
26 |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
27 if (args.length<3) { |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
28 usage(); |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
29 return; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
30 } |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
31 |
455
f92505ad18ab
Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
454
diff
changeset
|
32 Configurator config = new DefaultConfigurator(); |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
33 |
455
f92505ad18ab
Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
454
diff
changeset
|
34 auto options = config.getConfiguration(); |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
35 options.parser.rootPaths = [ args[1] ]; |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
36 options.parser.importPaths = args[2..$-1]; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
37 options.outputDir = args[$-1]; |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
38 |
729 | 39 alias DepGraph.Vertex Vertex; |
40 alias DepGraph.Edge Edge; | |
41 | |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
42 Module[] cachedModules; |
729 | 43 DepGraph cachedGraph; |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
44 |
729 | 45 void parser(ref Module[] modules, ref DepGraph depGraph) { |
46 Edge[] edges; | |
47 Vertex[char[]] vertices; | |
48 | |
735
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
49 if (cachedGraph !is null) { |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
50 modules = cachedModules; |
729 | 51 depGraph = cachedGraph; |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
52 return; |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
53 } |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
54 |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
55 int id = 1; |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
56 |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
57 Parser.loadModules( |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
58 options.parser.rootPaths, |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
59 options.parser.importPaths, |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
60 options.parser.strRegexps, |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
61 options.graph.includeUnlocatableModules, |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
62 options.parser.depth, |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
63 (char[] fqn, char[] path, Module m) { |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
64 if (m is null) { |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
65 if (fqn in vertices) { |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
66 debug Stdout.format("{} already set.\n", fqn); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
67 return; |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
68 } |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
69 auto vertex = new Vertex(fqn, path, id++); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
70 vertices[fqn] = vertex; |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
71 debug Stdout.format("Setting {} = {}.\n", fqn, path); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
72 } else { |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
73 vertices[m.moduleFQN] = new Vertex(m.moduleFQN, m.filePath, id++); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
74 debug Stdout.format("Setting {} = {}.\n", m.moduleFQN, m.filePath); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
75 } |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
76 }, |
735
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
77 (Module imported, Module importer, bool isPublic, bool isStatic) { |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
78 debug Stdout.format("Connecting {} - {}.\n", imported.moduleFQN, importer.moduleFQN); |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
79 auto edge = vertices[imported.moduleFQN].addChild(vertices[importer.moduleFQN]); |
729 | 80 edge.isPublic = isPublic; |
735
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
81 edge.isStatic = isStatic; |
462
b7503e02fbe7
Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
459
diff
changeset
|
82 edges ~= edge; |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
83 }, |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
84 modules |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
85 ); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
86 |
735
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
87 // modules.sort( |
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
88 // (Module a, Module b){ return icompare(a.moduleFQN, b.moduleFQN); } |
30e6f1b302a1
Forgot this, fixes segfault.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
729
diff
changeset
|
89 // ); |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
90 |
729 | 91 depGraph.edges = edges; |
92 depGraph.vertices = vertices.values; | |
93 | |
94 cachedGraph = depGraph; | |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
95 cachedModules = modules; |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
96 } |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
97 |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
98 GraphCache graphcache = new DefaultGraphCache(); |
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
99 |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
100 foreach(format; options.outputFormats) { |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
101 DocGenerator generator; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
102 |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
103 switch(format) { |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
104 case DocFormat.LaTeX: |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
105 Stdout("Generating LaTeX docs.."); |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
106 generator = new LaTeXDocGenerator(*options, &parser, graphcache); |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
107 break; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
108 case DocFormat.HTML: |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
109 Stdout("Generating HTML docs.."); |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
462
diff
changeset
|
110 generator = new HTMLDocGenerator(*options, &parser, graphcache); |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
111 break; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
112 case DocFormat.XML: |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
113 Stdout("Generating XML docs.."); |
459
1b5f1ce09f38
Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
114 generator = new XMLDocGenerator(*options, &parser); |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
115 break; |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
116 case DocFormat.PlainText: |
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
117 Stdout("Generating plain text docs.."); |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
118 generator = new PlainTextDocGenerator(*options, &parser, graphcache); |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
119 break; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
120 default: throw new Exception("Format not supported"); |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
121 } |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
122 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
123 generator.generate(); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
456
diff
changeset
|
124 Stdout("done.").newline; |
456
de2675bc9afa
Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
455
diff
changeset
|
125 } |
452
f658ec4a15dd
Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
446
diff
changeset
|
126 } |