Mercurial > projects > dil
annotate trunk/src/docgen/page/writer.d @ 717:cb8edb09108a
Updated docgen (mostly) to new tango.
Reflective options.
Updated translations.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Fri, 01 Feb 2008 15:05:56 +0200 |
parents | 381044a3feac |
children |
rev | line source |
---|---|
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
1 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
2 * Author: Jari-Matti Mäkelä |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
3 * License: GPL3 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
4 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
5 module docgen.page.writer; |
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 public import docgen.misc.misc; |
473 | 8 public import docgen.misc.options; |
717
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
9 public import docgen.misc.parser; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
10 import tango.io.model.IConduit : OutputStream; |
717
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
11 import tango.time.chrono.Gregorian; |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
12 import tango.text.locale.Core; |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
13 import tango.time.WallClock; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
14 import tango.text.convert.Sprint; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
15 import tango.io.stream.FileStream; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
16 import tango.io.Stdout; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
17 import tango.io.Print: Print; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
18 import tango.text.convert.Layout : Layout; |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
19 import tango.io.FilePath; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
20 import tango.io.FileScan; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
21 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
22 const templateDir = "docgen/templates/"; |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
23 |
467
32f4c3cb6a41
Support for static content.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
24 const formatDirs = [ "latex"[], "xml"[], "html"[], "plaintext"[] ]; |
32f4c3cb6a41
Support for static content.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
25 |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
26 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
27 * Writes the logical subcomponents of a document, |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
28 * e.g. sections, embedded graphics, lists |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
29 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
30 interface PageWriter { |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
31 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
32 * Updates the outputstreams. |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
33 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
34 void setOutput(OutputStream[] outputs); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
35 |
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 * Generates the first page(s). |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
38 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
39 void generateFirstPage(); |
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 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
42 * Generates table of contents. |
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 void generateTOC(Module[] modules); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
45 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
46 /** |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
47 * Generates class documentation section. |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
48 */ |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
49 void generateClassSection(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
50 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
51 /** |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
52 * Generates module documentation section. |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
53 */ |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
54 void generateModuleSection(Module[] modules); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
55 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
56 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
57 * Generates source code listing section. |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
58 */ |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
59 void generateListingSection(Module[] modules); |
457
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 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
62 * Generates dependency graph section. |
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 void generateDepGraphSection(); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
65 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
66 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
67 * Generates an index section. |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
68 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
69 void generateIndexSection(); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
70 |
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 * Generates the last page(s). |
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 void generateLastPage(); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
75 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
76 /** |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
77 * Generates a page using a custom template file. |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
78 * |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
79 * Some examples: style sheet, DTD files, makefiles. |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
80 */ |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
81 void generateCustomPage(char[] name, char[][] args ...); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
82 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
83 // --- page components |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
84 // |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
85 /* |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
86 * Adds an external graphics file. |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
87 */ |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
88 void addGraphics(char[] imageFile); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
89 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
90 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
91 * Adds a source code listing. |
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 void addListing(char[] moduleName, char[] contents, bool inline = true); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
94 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
95 /** |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
96 * Adds a list of items. |
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 void addList(char[][] contents, bool ordered); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
99 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
100 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
101 interface PageWriterFactory : WriterFactory { |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
102 PageWriter createPageWriter(OutputStream[] outputs, DocFormat outputFormat); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
103 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
104 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
105 template AbstractPageWriter(char[] format, int n = 0) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
106 abstract class AbstractPageWriter : AbstractWriter!(PageWriterFactory, n), PageWriter { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
107 protected: |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
108 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
109 char[][char[]] m_templates; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
110 Print!(char) print; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
111 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
112 public: |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
113 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
114 this(PageWriterFactory factory, OutputStream[] outputs) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
115 this(factory); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
116 setOutput(outputs); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
117 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
118 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
119 void setOutput(OutputStream[] outputs) { |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
120 this.outputs = outputs; |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
121 static if (n > 0) |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
122 assert(outputs.length == n, "Incorrect number of outputs"); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
123 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
124 print = new Print!(char)(new Layout!(char), outputs[0]); |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
125 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
126 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
127 void generateTOC(Module[] modules) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
128 print.format(getTemplate("toc")); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
129 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
130 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
131 void generateClassSection() { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
132 print.format(getTemplate("classes")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
133 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
134 |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
135 void generateModuleSection(Module[] modules) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
136 print.format(getTemplate("modules")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
137 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
138 |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
139 void generateListingSection(Module[] modules) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
140 print.format(getTemplate("listings")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
141 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
142 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
143 void generateDepGraphSection() { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
144 print.format(getTemplate("dependencies")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
145 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
146 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
147 void generateIndexSection() { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
148 print.format(getTemplate("index")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
149 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
150 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
151 void generateLastPage() { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
152 print.format(getTemplate("lastpage")); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
153 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
154 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
155 void generateCustomPage(char[] name, char[][] args ...) { |
468
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
156 switch(args.length) { |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
157 case 0: print.format(getTemplate(name)); break; |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
158 case 1: print.format(getTemplate(name), args[0]); break; |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
159 case 2: print.format(getTemplate(name), args[0], args[1]); break; |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
160 case 3: print.format(getTemplate(name), args[0], args[1], args[2]); break; |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
161 default: throw new Exception("Too many arguments"); |
7f7b2232a9eb
Fixes for the html generation.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
467
diff
changeset
|
162 } |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
163 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
164 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
165 //--- |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
166 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
167 void addGraphics(char[] imageFile) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
168 print.format(getTemplate("graphics"), imageFile); |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
169 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
170 |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
171 void addListing(char[] moduleName, char[] contents, bool inline) { |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
172 print.format(getTemplate("listing"), moduleName, contents); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
173 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
174 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
175 protected: |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
176 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
177 this(PageWriterFactory factory) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
178 super(factory); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
179 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
180 auto scan = new FileScan(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
181 scan(templateDir~factory.options.templates.templateStyle~"/"~format~"/", ".tpl"); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
182 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
183 debug Stdout(scan.files.length)(" template files loaded.\n"); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
184 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
185 foreach(tpl; scan.files) { |
717
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
186 m_templates[tpl.name] = loadTemplate(tpl.toString()); |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
187 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
188 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
189 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
190 char[] getTemplate(char[] name) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
191 auto tpl = name in m_templates; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
192 assert(tpl, "Error: template ["~format~"/"~name~"] not found!"); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
193 return *tpl; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
194 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
195 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
196 char[] loadTemplate(char[] fn) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
197 scope(failure) { |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
198 Stderr("Warning: error opening template "~fn~"."); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
199 return null; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
200 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
201 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
202 auto file = new FileInput(fn); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
203 auto content = new char[file.length]; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
204 auto bytesRead = file.read(content); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
205 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
206 assert(bytesRead == file.length, "Error reading template"); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
207 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
208 file.close(); |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
209 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
210 return content; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
211 } |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
212 |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
213 char[] timeNow() { |
717
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
214 auto n = WallClock.now; |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
215 auto c = Gregorian.generic; |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
216 auto d = c.toDate(n); |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
457
diff
changeset
|
217 auto sprint = new Sprint!(char); |
717
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
218 |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
219 auto culture = new Culture("en-GB"); |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
220 auto dateTimeFormat = culture.dateTimeFormat(); |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
221 |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
222 return sprint.format("{} {} {} {}", |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
223 dateTimeFormat.getAbbreviatedDayName(c.getDayOfWeek(n)), |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
224 1,//d.day(), |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
225 //dateTimeFormat.getAbbreviatedMonthName(d.month()), |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
226 2,//d.month(), |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
227 3//d.year()) //FIXME: something is broken here (Error: function expected before (), not *(&d + 8u) of type uint) |
cb8edb09108a
Updated docgen (mostly) to new tango.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
473
diff
changeset
|
228 ).dup; |
457
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
229 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
230 } |
33a4cb255fcc
Cached images, small fixes, reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff
changeset
|
231 } |