Mercurial > projects > dil
diff trunk/src/docgen/sourcelisting/latexwriter.d @ 444:0bda71dc9c4f
More document template and source listing code.
author | Jari-Matti M?kel? <jmjm@iki.fi> |
---|---|
date | Wed, 17 Oct 2007 03:12:46 +0300 |
parents | |
children | c82b36b9cadf |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/trunk/src/docgen/sourcelisting/latexwriter.d Wed Oct 17 03:12:46 2007 +0300 @@ -0,0 +1,42 @@ +/** + * Author: Jari-Matti Mäkelä + * License: GPL3 + */ +module docgen.sourcelisting.latexwriter; + +public import docgen.sourcelisting.writer; +import dil.Parser; +import tango.io.protocol.Writer : Writer; +import tango.io.FileConduit : FileConduit; +import tango.io.Buffer : Buffer; +import tango.io.Print: Print; +import tango.text.convert.Layout : Layout; + +/** + * Adds a code listing section for the given file. + */ +class LaTeXWriter : AbstractListingWriter { + this(ListingWriterFactory factory, OutputStream[] outputs) { + super(factory, outputs); + assert(outputs.length == 2, "Wrong number of outputs"); + } + + void generateListing(Parser parser) { + auto output2 = new Print!(char)(new Layout!(char), outputs[0]); + auto output = new Print!(char)(new Layout!(char), outputs[1]); + /* TODO */ + } + + void generateListing(InputStream input) { + auto output2 = new Print!(char)(new Layout!(char), outputs[0]); + + if (cast(FileConduit)outputs[1]) { + char[] fn = (cast(FileConduit)outputs[1]).toUtf8(); + output2.format("\\lstinputlisting[language=d]{{{0}}", fn); + } + + auto buf = new Buffer(256); + buf.output = outputs[1]; + buf.copy(input); + } +}