Mercurial > projects > dil
annotate trunk/src/docgen/document/latexgenerator.d @ 729:ec8dd7b8bf0c
Updated graph type.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Sun, 03 Feb 2008 19:43:53 +0200 |
parents | e562d455cbbe |
children |
rev | line source |
---|---|
463 | 1 /** |
2 * Author: Jari-Matti Mäkelä | |
3 * License: GPL3 | |
4 */ | |
5 module docgen.document.latexgenerator; | |
6 | |
7 import docgen.document.generator; | |
8 import docgen.misc.misc; | |
9 import tango.io.stream.FileStream; | |
10 import tango.text.Util : replace; | |
11 | |
12 /** | |
13 * Main routine for LaTeX doc generation. | |
14 */ | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
15 class LaTeXDocGenerator : DefaultCachingDocGenerator { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
16 private: |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
17 |
463 | 18 auto docFileName = "document.tex"; |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
19 auto depGraphDocFile = "dependencies.tex"; |
463 | 20 auto depGraphFile = "depgraph.dot"; |
21 auto listingFile = "files.tex"; | |
22 auto modulesFile = "modules.tex"; | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
23 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
24 public: |
463 | 25 |
26 this(DocGeneratorOptions options, ParserDg parser, GraphCache graphcache) { | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
27 genDir = "latex"; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
28 docFormat = DocFormat.LaTeX; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
29 |
463 | 30 super(options, parser, graphcache); |
31 } | |
32 | |
33 /** | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
34 * Generates the documentation. |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
35 */ |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
36 void generate() { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
37 parseSources(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
38 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
39 generateDoc(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
40 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
41 if (options.listing.enableListings) |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
42 generateListings(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
43 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
44 generateClasses(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
45 generateModules(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
46 generateDependencies(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
47 generateMakeFile(docFileName, "pdf"); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
48 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
49 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
50 protected: |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
51 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
52 /** |
463 | 53 * Generates document skeleton. |
54 */ | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
55 void generateDoc() { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
56 auto docFile = outputFile(docFileName); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
57 docWriter = pageFactory.createPageWriter( [ docFile ], docFormat ); |
463 | 58 |
59 docWriter.generateFirstPage(); | |
60 docWriter.generateTOC(modules); | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
61 docWriter.generateClassSection(); |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
62 docWriter.generateModuleSection(modules); |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
63 docWriter.generateListingSection(modules); |
463 | 64 docWriter.generateDepGraphSection(); |
65 docWriter.generateIndexSection(); | |
66 docWriter.generateLastPage(); | |
67 | |
68 docFile.close(); | |
69 } | |
70 | |
71 /** | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
72 * Generates documentation for classes. |
463 | 73 */ |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
74 void generateClasses() { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
75 auto docFile = outputFile(modulesFile); |
463 | 76 docFile.close(); |
77 } | |
78 | |
79 /** | |
80 * Generates documentation for modules. | |
81 */ | |
82 void generateModules() { | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
83 auto docFile = outputFile(modulesFile); |
463 | 84 docFile.close(); |
85 } | |
86 | |
87 /** | |
88 * Generates source file listings. | |
89 */ | |
90 void generateListings() { | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
91 writeSimpleFile(listingFile, { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
92 auto writer = listingFactory.createListingWriter(docWriter, docFormat); |
463 | 93 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
94 foreach(mod; modules) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
95 auto dstFname = replace(mod.moduleFQN.dup, '.', '_') ~ ".d"; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
96 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
97 auto srcFile = new FileInput(mod.filePath); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
98 auto dstFile = outputFile(dstFname); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
99 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
100 writer.generateListing(srcFile, dstFile, mod.moduleFQN); |
463 | 101 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
102 srcFile.close(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
103 dstFile.close(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
104 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
105 }); |
463 | 106 } |
107 | |
108 /** | |
109 * Generates dependency graphs. | |
110 */ | |
111 void generateDependencies() { | |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
112 writeSimpleFile(depGraphDocFile, { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
113 auto imgFile = outputFile(depGraphFile); |
463 | 114 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
115 auto writer = graphFactory.createGraphWriter( docWriter, GraphFormat.Dot ); |
729 | 116 writer.generateDepGraph(depGraph, imgFile); |
463 | 117 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
118 imgFile.close(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
119 }); |
463 | 120 } |
121 } |