annotate trunk/src/docgen/docgen.d @ 459:1b5f1ce09f38

Fix to the image cache, cleaned stuff.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Tue, 30 Oct 2007 16:58:17 +0200
parents 33a4cb255fcc
children b7503e02fbe7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
13ecfb4278a4 Initial docgen test stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 395
diff changeset
5 module docgen.docgen;
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
6
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
7 import docgen.document.generator;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
8
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
9 import docgen.sourcelisting.writers;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
10 import docgen.page.writers;
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
11 import docgen.graphutils.writers;
446
49f3afd6a0e8 Refactored writers.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 444
diff changeset
12 import docgen.misc.misc;
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
13 import docgen.misc.parser;
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
14 import docgen.config.configurator;
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
15 import tango.core.Array;
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
16 import tango.io.stream.FileStream;
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
17 import tango.text.Ascii;
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
18 import tango.text.Util : replace;
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
19 import tango.io.FilePath;
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
20
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
21 import tango.io.Stdout;
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
22
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
23
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
24 class HTMLDocGenerator : DefaultDocGenerator!("html") {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
25 this(DocGeneratorOptions options, ParserDg parser) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
26 super(options, parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
27 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
28 public void generate() { /* TODO */ }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
29 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
30 class XMLDocGenerator : DefaultDocGenerator!("xml") {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
31 this(DocGeneratorOptions options, ParserDg parser) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
32 super(options, parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
33 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
34 public void generate() { /* TODO */ }
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 class PlainTextDocGenerator : DefaultDocGenerator!("txt") {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
37 this(DocGeneratorOptions options, ParserDg parser) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
38 super(options, parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
39 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
40 public void generate() { /* TODO */ }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
41 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
42
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
43 /**
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
44 * Main routine for LaTeX doc generation.
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
45 */
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
46 class LaTeXDocGenerator : DefaultCachingDocGenerator!("latex") {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
47 this(DocGeneratorOptions options, ParserDg parser, GraphCache graphcache) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
48 super(options, parser, graphcache);
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
49 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
50
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
51 /**
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
52 * Generates document skeleton.
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
53 */
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
54 void generateDoc(char[] docFileName) {
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
55 auto docFile = new FileOutput(outPath(docFileName));
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
56 docWriter = pageFactory.createPageWriter( [ docFile ], DocFormat.LaTeX );
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
57
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
58 docWriter.generateFirstPage();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
59 docWriter.generateTOC(modules);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
60 docWriter.generateModuleSection();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
61 docWriter.generateListingSection();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
62 docWriter.generateDepGraphSection();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
63 docWriter.generateIndexSection();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
64 docWriter.generateLastPage();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
65
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
66 docFile.close();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
67 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
68
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
69 /**
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
70 * Generates D language definition file.
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
71 */
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
72 void generateLangDef() {
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
73 auto docFile = new FileOutput(outPath("lstlang0.sty"));
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
74 docWriter.setOutput([docFile]);
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
75
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
76 docWriter.generateLangDef();
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
77
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
78 docFile.close();
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
79 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
80
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
81 /**
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
82 * Generates "makefile" for processing the .dot and .tex files.
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
83 */
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
84 void generateMakeFile() {
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
85 auto docFile = new FileOutput(outPath("make.sh"));
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
86 docWriter.setOutput([docFile]);
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
87
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
88 docWriter.generateMakeFile();
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
89
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
90 docFile.close();
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
91 }
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
92
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
93 /**
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
94 * Generates documentation for modules.
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
95 */
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
96 void generateModules(char[] modulesFile) {
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
97 auto docFile = new FileOutput(outPath(modulesFile));
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
98 docFile.close();
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
99 }
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
100
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
101 /**
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
102 * Generates source file listings.
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
103 */
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
104 void generateListings(char[] listingsFile) {
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
105 auto dlwf = new DefaultListingWriterFactory(this);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
106 auto docFile = new FileOutput(outPath(listingsFile));
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
107 docWriter.setOutput([docFile]);
454
dbdc9fa5d479 depgraph fixes, better design for multiple doctargets.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 453
diff changeset
108 auto writer = dlwf.createListingWriter(docWriter, DocFormat.LaTeX);
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
109
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
110
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
111 foreach(mod; modules) {
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
112 auto dstFname = replace(mod.moduleFQN.dup, '.', '_') ~ ".d";
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
113
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
114 auto srcFile = new FileInput(mod.filePath);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
115 auto dstFile = new FileOutput(outPath(dstFname));
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
116
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
117 writer.generateListing(srcFile, dstFile, mod.moduleFQN);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
118
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
119 srcFile.close();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
120 dstFile.close();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
121 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
122
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
123 docFile.close();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
124 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
125
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
126 /**
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
127 * Generates dependency graphs.
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
128 */
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
129 void generateDependencies(char[] depGraphTexFile, char[] depGraphFile) {
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
130 auto docFile = new FileOutput(outPath(depGraphTexFile));
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
131 docWriter.setOutput([docFile]);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
132
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
133 createDepGraph(depGraphFile);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
134
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
135 docFile.close();
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
136 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
137
446
49f3afd6a0e8 Refactored writers.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 444
diff changeset
138 public void generate() {
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
139 auto docFileName = "document.tex";
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
140 auto depGraphTexFile = "dependencies.tex";
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
141 auto depGraphFile = "depgraph.dot";
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
142 auto listingFile = "files.tex";
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
143 auto modulesFile = "modules.tex";
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
144
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
145 parseSources();
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
146
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
147 generateDoc(docFileName);
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
148
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
149 if (options.listing.enableListings)
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
150 generateListings(listingFile);
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
151
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
152 generateModules(modulesFile);
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
153
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
154 generateDependencies(depGraphTexFile, depGraphFile);
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
155
453
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
156 generateLangDef();
4e5b35df3060 Parsing bugfixes, cleaned up imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 452
diff changeset
157 generateMakeFile();
395
ac9cd48151b6 Added couple of docgen modules.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
158 }
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
159 }
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
160
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
161 void usage() {
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
162 Stdout(
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
163 "Usage: docgen rootpath importpath_1 ... importpath_n outputdir"
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
164 ).newline;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
165 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
166
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
167 void main(char[][] args) {
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
168 Stdout(docgen_version).newline.newline;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
169
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
170 if (args.length<3) {
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
171 usage();
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
172 return;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
173 }
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
174
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
175 Configurator config = new DefaultConfigurator();
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
176
455
f92505ad18ab Simple configuration reader, small modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 454
diff changeset
177 auto options = config.getConfiguration();
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
178 options.parser.rootPaths = [ args[1] ];
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
179 options.parser.importPaths = args[2..$-1];
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
180 options.outputDir = args[$-1];
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
181
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
182 Module[] cachedModules;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
183 Edge[] cachedEdges;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
184 Vertex[char[]] cachedVertices;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
185
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
186 void parser(ref Module[] modules, ref Edge[] edges, ref Vertex[char[]] vertices) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
187 if (cachedModules != null) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
188 modules = cachedModules;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
189 edges = cachedEdges;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
190 vertices = cachedVertices;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
191 return;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
192 }
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
193
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
194 int id = 1;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
195
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
196 Parser.loadModules(
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
197 options.parser.rootPaths,
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
198 options.parser.importPaths,
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
199 options.parser.strRegexps,
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
200 options.graph.includeUnlocatableModules,
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
201 options.graph.depth,
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
202 (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
203 if (m is null) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
204 if (fqn in vertices) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
205 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
206 return;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
207
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
208 }
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
209 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
210 vertex.type = VertexType.UnlocatableModule;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
211 vertices[fqn] = vertex;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
212 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
213
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
214 } else {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
215 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
216 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
217 }
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
218 },
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
219 (Module imported, Module importer) {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
220 debug Stdout.format("Connecting {} - {}.\n", imported.moduleFQN, importer.moduleFQN);
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
221 edges ~= vertices[imported.moduleFQN].addChild(vertices[importer.moduleFQN]);
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
222 },
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
223 modules
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
224 );
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
225
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
226 modules.sort(
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
227 (Module a, Module b){ return icompare(a.moduleFQN, b.moduleFQN); }
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
228 );
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
229
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
230 cachedVertices = vertices;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
231 cachedModules = modules;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
232 cachedEdges = edges;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
233 }
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
234
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
235 GraphCache graphcache = new DefaultGraphCache();
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
236
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
237 foreach(format; options.outputFormats) {
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
238 DocGenerator generator;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
239
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
240 switch(format) {
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
241 case DocFormat.LaTeX:
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
242 generator = new LaTeXDocGenerator(*options, &parser, graphcache);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
243 Stdout("Generating LaTeX docs..");
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
244 break;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
245 case DocFormat.HTML:
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
246 generator = new HTMLDocGenerator(*options, &parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
247 Stdout("Generating HTML docs..");
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
248 break;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
249 case DocFormat.XML:
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
250 generator = new XMLDocGenerator(*options, &parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
251 Stdout("Generating XML docs..");
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
252 break;
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
253 case DocFormat.PlainText:
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
254 generator = new PlainTextDocGenerator(*options, &parser);
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
255 Stdout("Generating plain text docs..");
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
256 break;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
257 default: throw new Exception("Format not supported");
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
258 }
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
259
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
260 generator.generate();
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 456
diff changeset
261 Stdout("done.").newline;
456
de2675bc9afa Dependency lists, minor cleanup.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 455
diff changeset
262 }
452
f658ec4a15dd Simple docgen ui util, some fixes.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 446
diff changeset
263 }