annotate trunk/src/docgen/sourcelisting/latexwriter.d @ 449:757bd048482c

Depgraph test + minor modifications.
author Jari-Matti M?kel? <jmjm@iki.fi>
date Wed, 17 Oct 2007 20:35:56 +0300
parents c82b36b9cadf
children 3f44c38bf870
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
1 /**
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
2 * Author: Jari-Matti Mäkelä
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
3 * License: GPL3
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
4 */
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
5 module docgen.sourcelisting.latexwriter;
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
6
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
7 public import docgen.sourcelisting.writer;
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
8 import dil.Parser;
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
9 import tango.io.protocol.Writer : Writer;
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
10 import tango.io.FileConduit : FileConduit;
449
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
11 import tango.io.Print;
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
12 import tango.io.FilePath;
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
13 import tango.text.convert.Layout : Layout;
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
14
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
15 /**
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
16 * Adds a code listing section for the given file.
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
17 */
448
c82b36b9cadf Simpler writer hierarchy.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 444
diff changeset
18 class LaTeXWriter : AbstractWriter!(ListingWriterFactory, 2), ListingWriter {
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
19 this(ListingWriterFactory factory, OutputStream[] outputs) {
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
20 super(factory, outputs);
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
21 }
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
22
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
23 void generateListing(Parser parser) {
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
24 auto output2 = new Print!(char)(new Layout!(char), outputs[0]);
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
25 auto output = new Print!(char)(new Layout!(char), outputs[1]);
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
26 /* TODO */
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
27 }
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
28
449
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
29 void generateListing(InputStream input, char[] moduleName) {
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
30 auto output2 = new Print!(char)(new Layout!(char), outputs[0]);
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
31
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
32 if (cast(FileConduit)outputs[1]) {
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
33 char[] fn = (cast(FileConduit)outputs[1]).toUtf8();
449
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
34 fn = FilePath(fn).file;
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
35 output2.format("\\section{{Module {0}}\n", moduleName);
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
36 output2.format("\\lstinputlisting[language=d]{{{0}}\n", fn);
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
37 }
449
757bd048482c Depgraph test + minor modifications.
Jari-Matti M?kel? <jmjm@iki.fi>
parents: 448
diff changeset
38 outputs[1].copy(input);
444
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
39 }
0bda71dc9c4f More document template and source listing code.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
diff changeset
40 }