Mercurial > projects > dil
annotate src/docgen/document/plaintextgenerator.d @ 806:bcb74c9b895c
Moved out files in the trunk folder to the root.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 09 Mar 2008 00:12:19 +0100 |
parents | trunk/src/docgen/document/plaintextgenerator.d@ec8dd7b8bf0c |
children |
rev | line source |
---|---|
463 | 1 /** |
2 * Author: Jari-Matti Mäkelä | |
3 * License: GPL3 | |
4 */ | |
5 module docgen.document.plaintextgenerator; | |
6 | |
7 import docgen.document.generator; | |
8 import docgen.misc.misc; | |
9 import tango.io.stream.FileStream; | |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
10 import tango.io.FilePath; |
463 | 11 import tango.text.Util : replace; |
12 | |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
13 class PlainTextDocGenerator : DefaultCachingDocGenerator { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
14 private: |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
15 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
16 auto docFileNames = [ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
17 "index.txt"[], "toc.txt"[], "classes.txt"[], |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
18 "modules.txt"[], "files.txt"[] |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
19 ]; |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
20 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
21 auto depGraphFile = "depgraph.dot"; |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
22 auto depGraphDocFile = "depgraph.txt"; |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
23 |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
24 public: |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
25 |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
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 = "txt"; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
28 docFormat = DocFormat.PlainText; |
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
29 |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
30 super(options, parser, graphcache); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
31 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
32 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
33 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
34 * Generates the documentation. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
35 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
36 void generate() { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
37 parseSources(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
38 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
39 docWriter = pageFactory.createPageWriter( null, docFormat ); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
40 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
41 generateDoc(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
42 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
43 if (options.listing.enableListings) |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
44 generateListings(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
45 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
46 generateClasses(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
47 generateModules(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
48 generateDependencies(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
49 generateMakeFile(imageFormatExts[options.graph.imageFormat]); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
50 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
51 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
52 protected: |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
53 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
54 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
55 * Generates document skeleton. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
56 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
57 void generateDoc() { |
729 | 58 writeSimpleFile(docFileNames[0], { |
59 docWriter.generateFirstPage(); | |
60 }); | |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
61 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
62 writeSimpleFile(docFileNames[1], { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
63 docWriter.generateTOC(modules); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
64 }); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
65 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
66 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
67 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
68 * Generates documentation for classes. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
69 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
70 void generateClasses() { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
71 writeSimpleFile(docFileNames[2], { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
72 docWriter.generateClassSection(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
73 }); |
463 | 74 } |
466
db7e27b5c180
Fixed parts of HTML output, some reorganizing.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
463
diff
changeset
|
75 |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
76 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
77 * Generates documentation for modules. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
78 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
79 void generateModules() { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
80 writeSimpleFile(docFileNames[3], { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
81 docWriter.generateModuleSection(modules); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
82 }); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
83 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
84 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
85 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
86 * Generates source file listings. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
87 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
88 void generateListings() { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
89 writeSimpleFile(docFileNames[4], { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
90 docWriter.generateListingSection(modules); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
91 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
92 char[][] contents; |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
93 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
94 foreach(mod; modules) { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
95 auto FQN = mod.moduleFQN; |
473 | 96 contents ~= FQN ~ " (see " ~ replace(FQN.dup, '.', '_') ~ ".d)"; |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
97 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
98 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
99 docWriter.addList(contents, false); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
100 }); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
101 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
102 foreach(mod; modules) |
473 | 103 (new FilePath(outPath(replace(mod.moduleFQN.dup, '.', '_') ~ ".d"))).copy(mod.filePath); |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
104 } |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
105 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
106 /** |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
107 * Generates dependency graphs. |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
108 */ |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
109 void generateDependencies() { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
110 writeSimpleFile(depGraphDocFile, { |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
111 docWriter.generateDepGraphSection(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
112 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
113 auto imgFile = outputFile(depGraphFile); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
114 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
115 auto writer = graphFactory.createGraphWriter( docWriter, GraphFormat.Dot ); |
729 | 116 writer.generateDepGraph(depGraph, imgFile); |
470
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
117 |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
118 imgFile.close(); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
119 }); |
e48a011e687a
Initial plain text output support.
Jari-Matti M?kel? <jmjm@iki.fi>
parents:
466
diff
changeset
|
120 } |
463 | 121 } |