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