allow tests to be embedded directly into .ship files
[fleet.git] / src / edu / berkeley / fleet / doc / Doc.java
1 package edu.berkeley.fleet.doc;
2
3 import java.io.*;
4 import java.util.*;
5
6
7 public class Doc {
8     
9     public static void print() throws Exception {
10         if (!new File(".tmp").exists())
11             new File(".tmp").mkdirs();
12         PrintWriter pw = new PrintWriter(new FileOutputStream(".tmp/FleetTwo.Manual.tex"));
13         BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("doc/archman.tex")));
14         for(String s = br.readLine(); s!=null; s = br.readLine())
15             pw.println(s);
16         for(String f : new File("ships").list()) {
17             print(pw, new ShipDescription(f, new BufferedReader(new InputStreamReader(new FileInputStream(new File("ships/"+f))))));
18         }
19         pw.println("\\end{document}");
20         pw.close();
21     }
22
23     private static void print(PrintWriter pw, ShipDescription sd) throws Exception {
24         pw.println("\\pagebreak");
25         pw.println("\\section*{The {\\tt "+sd.getName()+"} Ship}");
26         String tex = sd.getSection("tex");
27         if (tex!=null)
28             pw.println(tex);
29         for(BenkoBoxDescription bbd : sd) {
30             pw.println("\\subsection*{"+(bbd.isInbox() ? "Inbox: " : "Outbox: ")+"{\\tt "+bbd.getName()+"}}");
31         }
32     }
33
34 }