annotate trunk/src/docgen/document/generator.d @ 462:b7503e02fbe7

Docgen code for handling public imports.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Tue, 30 Oct 2007 20:52:29 +0200
parents 1b5f1ce09f38
children db7e27b5c180
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
1 /**
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
2 * Author: Jari-Matti Mäkelä
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
3 * License: GPL3
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
4 */
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
5 module docgen.document.generator;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
6
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
7 import docgen.sourcelisting.writers;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
8 import docgen.page.writers;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
9 import docgen.graphutils.writers;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
10 import docgen.misc.misc;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
11 import docgen.misc.parser;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
12 import docgen.config.configurator;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
13 import tango.io.stream.FileStream;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
14 import tango.io.FilePath;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
15 debug import tango.io.Stdout;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
16
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
17 alias void delegate(ref Module[], ref Edge[], ref Vertex[char[]]) ParserDg;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
18
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
19 template DefaultDocGenerator(char[] genDir) {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
20 abstract class DefaultDocGenerator : DocGenerator {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
21 DocGeneratorOptions m_options;
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
22 ParserDg m_parser;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
23 PageWriter docWriter;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
24
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
25 GraphWriterFactory graphFactory;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
26 PageWriterFactory pageFactory;
462
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
27 DefaultListingWriterFactory listingFactory;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
28
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
29 Module[] modules;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
30 Edge[] edges;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
31 Vertex[char[]] vertices;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
32
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
33 this(DocGeneratorOptions options, ParserDg parser) {
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
34 m_options = options;
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
35 m_parser = parser;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
36
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
37 createGraphWriterFactory();
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
38 createPageWriterFactory();
462
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
39 createListingWriterFactory();
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
40
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
41 // create output dir
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
42 (new FilePath(options.outputDir ~ "/" ~ genDir)).create();
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
43 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
44
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
45 protected void createGraphWriterFactory() {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
46 graphFactory = new DefaultGraphWriterFactory(this);
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
47 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
48
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
49 protected void createPageWriterFactory() {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
50 pageFactory = new DefaultPageWriterFactory(this);
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
51 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
52
462
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
53 protected void createListingWriterFactory() {
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
54 listingFactory = new DefaultListingWriterFactory(this);
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
55 }
b7503e02fbe7 Docgen code for handling public imports.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 459
diff changeset
56
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
57 protected char[] outPath(char[] file) {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
58 return options.outputDir ~ "/" ~ genDir ~ "/" ~ file;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
59 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
60
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
61 protected void parseSources() {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
62 m_parser(modules, edges, vertices);
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
63 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
64
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
65 void createDepGraph(char[] depGraphFile) {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
66 auto imgFile = new FileOutput(outPath(depGraphFile));
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
67
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
68 auto writer = graphFactory.createGraphWriter( docWriter, GraphFormat.Dot );
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
69
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
70 writer.generateDepGraph(vertices.values, edges, imgFile);
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
71
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
72 imgFile.close();
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
73 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
74
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
75 public DocGeneratorOptions *options() {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
76 return &m_options;
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
77 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
78 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
79 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
80
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
81 template DefaultCachingDocGenerator(char[] genDir) {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
82 abstract class DefaultCachingDocGenerator : DefaultDocGenerator!(genDir), CachingDocGenerator {
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
83 GraphCache m_graphCache;
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
84
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
85 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
86 super(options, parser);
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
87 m_graphCache = graphCache;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
88 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
89
459
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
90 GraphCache graphCache() {
1b5f1ce09f38 Fix to the image cache, cleaned stuff.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 457
diff changeset
91 return m_graphCache;
457
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
92 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
93
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
94 protected void createGraphWriterFactory() {
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
95 graphFactory = new DefaultCachingGraphWriterFactory(this);
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
96 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
97 }
33a4cb255fcc Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
98 }