docgenerator 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/creole_example_tabular.rb +95 -0
- data/examples/docgenerator_example.rb +5 -5
- data/lib/creole/creole2doc.rb +28 -18
- data/lib/creole/creole_inclusions.rb +4 -4
- data/lib/creole/creole_placeholder.rb +4 -1
- data/lib/creole/creole_tabular.rb +173 -155
- data/lib/creole/plugins/rail.rb +118 -119
- data/lib/creole/plugins/struktex.rb +35 -35
- data/lib/creole/plugins/todonotes.rb +8 -1
- data/lib/docgenerator/attribute.rb +160 -160
- data/lib/docgenerator/characters.rb +343 -311
- data/lib/docgenerator/css.rb +167 -167
- data/lib/docgenerator/document.rb +525 -511
- data/lib/docgenerator/element.rb +316 -316
- data/lib/docgenerator/element_meta.rb +114 -114
- data/lib/docgenerator/elements.rb +19 -9
- data/lib/docgenerator/environments.rb +3 -1
- data/lib/docgenerator/lists.rb +177 -174
- data/lib/docgenerator/packages/hyperref.rb +74 -70
- data/lib/docgenerator/packages/multicol.rb +33 -0
- data/lib/docgenerator/packages/scrlettr2.rb +152 -151
- data/lib/docgenerator/packages/todonotes.rb +1 -1
- data/lib/docgenerator/tabular.rb +463 -400
- data/lib/docgenerator/templates/docgenerator_template.rb +94 -84
- data/lib/docgenerator/templates/docgenerator_template.yaml +75 -15
- data/lib/docgenerator.rb +1 -1
- data/lib/wiki2doc/wiki2docgenerator.rb +1 -1
- data/meta_test_and_doc/build__meta.rb +125 -0
- data/meta_test_and_doc/build_doc.rb +333 -0
- data/meta_test_and_doc/build_test.rb +251 -0
- data/meta_test_and_doc/manpages/attachfile.rb +389 -0
- data/meta_test_and_doc/manpages/caption.rb +133 -0
- data/meta_test_and_doc/manpages/characters.rb +3738 -0
- data/meta_test_and_doc/manpages/elements.rb +6851 -0
- data/meta_test_and_doc/manpages/environments.rb +985 -0
- data/meta_test_and_doc/manpages/footnote.rb +439 -0
- data/meta_test_and_doc/manpages/hyperref.rb +605 -0
- data/meta_test_and_doc/manpages/listings.rb +988 -0
- data/meta_test_and_doc/manpages/lists.rb +1463 -0
- data/meta_test_and_doc/manpages/others.rb +129 -0
- data/meta_test_and_doc/manpages/packages.rb +13 -0
- data/meta_test_and_doc/manpages/pdfpages.rb +108 -0
- data/meta_test_and_doc/manpages/readme.rdoc +9 -0
- data/meta_test_and_doc/manpages/scrlettr2.rb +362 -0
- data/meta_test_and_doc/manpages/scrpage2.rb +2028 -0
- data/meta_test_and_doc/manpages/sectioning.rb +2467 -0
- data/meta_test_and_doc/manpages/tables.rb +2088 -0
- data/meta_test_and_doc/manpages/todonotes.rb +235 -0
- data/meta_test_and_doc/manpages/wiki2docgenerator.rb +64 -0
- data/{readme.rd → readme.rdoc} +18 -1
- data/unittest/expected/test_tabular.creole +33 -0
- data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.text +3 -3
- data/unittest/expected_creole/test_creole_inline_apostroph.html +6 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.latex +8 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.text +4 -0
- data/unittest/expected_creole/test_creole_input.normsource +12 -12
- data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
- data/unittest/expected_creole/test_creole_links_implicit_end.html +1 -1
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +1 -1
- data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
- data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +83 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
- data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +27 -0
- data/unittest/expected_creole/test_creole_tabular.creole +22 -0
- data/unittest/expected_creole/test_creole_tabular_creole.creole +19 -0
- data/unittest/expected_creole/test_creole_tabular_css.creole +24 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.creole +16 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
- data/unittest/expected_creole/test_creole_toc_level_text.html +2 -2
- data/unittest/expected_creole/test_creole_toc_level_text.latex +2 -2
- data/unittest/expected_packages/test_multicol_3.tex +2 -0
- data/unittest/expected_packages/test_multicol_3_titleline.tex +2 -0
- data/unittest/expected_templates/test_article.tex +23 -0
- data/unittest/expected_templates/test_article_utf8.tex +34 -0
- data/unittest/expected_templates/test_context.miv +18 -0
- data/unittest/expected_templates/test_creole.creole +8 -0
- data/unittest/expected_templates/test_html.html +12 -0
- data/unittest/expected_templates/test_html401_strict.html +14 -0
- data/unittest/expected_templates/test_html401_trans.html +14 -0
- data/unittest/expected_templates/test_html_utf8.html +14 -0
- data/unittest/expected_templates/test_include.tex +17 -0
- data/unittest/expected_templates/test_include_utf8.tex +17 -0
- data/unittest/expected_templates/test_text.txt +6 -0
- data/unittest/expected_templates/test_wiki.wiki +6 -0
- data/unittest/expected_templates/test_xhtml_strict.html +14 -0
- data/unittest/expected_templates/test_xhtml_trans.html +14 -0
- data/unittest/unittest_creole.rb +27 -6
- data/unittest/unittest_creole_placeholders.rb +1 -123
- data/unittest/unittest_creole_tabular.rb +174 -0
- data/unittest/unittest_docgenerator.rb +4 -3
- data/unittest/unittest_docgenerator_characters.rb +4769 -615
- data/unittest/unittest_packages_multicol.rb +84 -0
- data/unittest/unittest_rubycode4doc.rb +0 -1
- data/unittest/unittest_templates.rb +64 -0
- metadata +163 -77
- data/build_test_and_doc.rb +0 -505
- data/manpage_elements.rb +0 -10411
@@ -1,5 +1,6 @@
|
|
1
|
-
#encoding:
|
1
|
+
#encoding: utf-8
|
2
2
|
|
3
|
+
require 'yaml'
|
3
4
|
#
|
4
5
|
module Docgenerator
|
5
6
|
=begin rdoc
|
@@ -7,22 +8,24 @@ Definition of templates.
|
|
7
8
|
|
8
9
|
This templates are used for document types.
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
All templates will include their encoding.
|
12
|
+
Default is UTF-8.
|
12
13
|
=end
|
13
14
|
class DocumentTemplate
|
14
|
-
|
15
|
+
@@templates = {}
|
15
16
|
=begin rdoc
|
16
17
|
|
17
18
|
Define a template.
|
18
19
|
|
19
|
-
A template gets a key, a target
|
20
|
+
A template gets a key, a target, the corresponding source and a encoding.
|
20
21
|
|
21
22
|
Valid targets are:
|
22
23
|
-:latex
|
23
24
|
-:html
|
24
|
-
-:
|
25
|
+
-:creole
|
26
|
+
-:context
|
25
27
|
-:text
|
28
|
+
-:wiki (obsolete)
|
26
29
|
|
27
30
|
The source should contain the following place holder:
|
28
31
|
- <<prefix>> Contains later some admin data like time of creation...
|
@@ -30,25 +33,26 @@ The source should contain the following place holder:
|
|
30
33
|
- <<body>> The main text
|
31
34
|
- <<classoptions>> Class options (LaTeX)
|
32
35
|
=end
|
33
|
-
|
36
|
+
def initialize( key, target, template, encoding = Encoding.find('UTF-8'))
|
34
37
|
@key = key
|
35
38
|
@target = target
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
@encoding = encoding
|
40
|
+
@template = template.gsub(/^\t*/, '').encode(@encoding)
|
41
|
+
case target
|
42
|
+
when :text
|
43
|
+
when :wiki
|
44
|
+
when :creole
|
45
|
+
when :latex
|
46
|
+
when :context
|
47
|
+
when :html
|
44
48
|
else
|
45
49
|
DOCGENERATOR_LOGGER.error("DocumentTemplate: Undefined target #{target.inspect}") if DOCGENERATOR_LOGGER.error?
|
46
|
-
|
50
|
+
end
|
47
51
|
|
48
|
-
|
52
|
+
if @@templates[key]
|
49
53
|
DOCGENERATOR_LOGGER.warn("DocumentTemplate: Double definition of template #{key.inspect}") if DOCGENERATOR_LOGGER.warn?
|
50
54
|
end
|
51
|
-
|
55
|
+
@@templates[key] = self
|
52
56
|
|
53
57
|
end
|
54
58
|
=begin rdoc
|
@@ -64,6 +68,8 @@ Base for the document to be created.
|
|
64
68
|
end
|
65
69
|
#Target format of the Template (:html, :latex...)
|
66
70
|
attr_reader :target
|
71
|
+
#Target encoding of the template
|
72
|
+
attr_reader :encoding
|
67
73
|
|
68
74
|
def inspect()
|
69
75
|
"<#{self.class} #{@key} for #{@target.inspect}>"
|
@@ -92,8 +98,12 @@ You can use DocumentTemplate.to_yaml() to build your file.
|
|
92
98
|
def load( yamlfile )
|
93
99
|
File.open(yamlfile){|yaml|
|
94
100
|
YAML.load(yaml).each{|key, data|
|
95
|
-
DocumentTemplate.new( key,
|
101
|
+
DocumentTemplate.new( key,
|
102
|
+
data[:target], data[:source],
|
103
|
+
Encoding.find( data[:encoding] || 'UTF-8')
|
104
|
+
)
|
96
105
|
}}
|
106
|
+
|
97
107
|
end
|
98
108
|
#Litte helper to build yaml-files
|
99
109
|
def to_yaml()
|
@@ -120,7 +130,7 @@ If you 'compile' your script with ocra, the template file is not found.
|
|
120
130
|
You have to add it yourself with
|
121
131
|
ocra <your_script>.rb docgenerator_template.yaml
|
122
132
|
|
123
|
-
(How to do it better?
|
133
|
+
(How to do it better?)
|
124
134
|
=end
|
125
135
|
"#{File.dirname(__FILE__)}/../../../../../../../../src/docgenerator_template.yaml", #for ocra-version (exe)
|
126
136
|
].each{| template_file |
|
@@ -138,84 +148,84 @@ You have to add it yourself with
|
|
138
148
|
end #module Docgenerator
|
139
149
|
__END__
|
140
150
|
DocumentTemplate.new(
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
151
|
+
:include, :latex, %q|<<prefix>>
|
152
|
+
% ----------------------------------------------------------------
|
153
|
+
<<head>>
|
154
|
+
% ----------------------------------------------------------------
|
155
|
+
<<body>>
|
156
|
+
% ----------------------------------------------------------------
|
157
|
+
|)
|
158
|
+
|
149
159
|
DocumentTemplate.new(
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
160
|
+
:article, :latex, %q|<<prefix>>
|
161
|
+
\documentclass[<<classoptions>>]{scrartcl}
|
162
|
+
\usepackage{babel}
|
163
|
+
\usepackage[ansinew]{inputenc}
|
164
|
+
\usepackage{hyperref}
|
165
|
+
% ----------------------------------------------------------------
|
166
|
+
<<head>>
|
167
|
+
% ----------------------------------------------------------------
|
168
|
+
\begin{document}
|
169
|
+
<<body>>
|
170
|
+
\end{document}
|
171
|
+
% ----------------------------------------------------------------
|
172
|
+
|)
|
163
173
|
#~ DocumentTemplate.new(
|
164
|
-
|
165
|
-
|
174
|
+
#~ :report, '',
|
175
|
+
#~ |)
|
166
176
|
#~ DocumentTemplate.new(
|
167
|
-
|
168
|
-
|
177
|
+
#~ :book, '',
|
178
|
+
#~ |)
|
169
179
|
|
170
|
-
|
180
|
+
#~ <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
171
181
|
|
172
182
|
DocumentTemplate.new(
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
183
|
+
:context, %q|<<prefix>>
|
184
|
+
% ----------------------------------------------------------------
|
185
|
+
<<head>>
|
186
|
+
% ----------------------------------------------------------------
|
177
187
|
\starttext
|
178
|
-
|
188
|
+
<<body>>
|
179
189
|
\stoptext
|
180
|
-
|
181
|
-
|
190
|
+
% ----------------------------------------------------------------
|
191
|
+
|)
|
182
192
|
|
183
193
|
DocumentTemplate.new(
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
:html, :html, %q|<!--
|
195
|
+
<<prefix>>
|
196
|
+
-->
|
197
|
+
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
198
|
+
<html>
|
199
|
+
<<head>>
|
200
|
+
<<body>>
|
201
|
+
</html>
|
202
|
+
|)
|
193
203
|
|
194
204
|
{
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
205
|
+
:xhtml_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
206
|
+
:xhtml_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
207
|
+
:html401_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
208
|
+
:html401_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
199
209
|
}.each{ |key, doctype|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
210
|
+
DocumentTemplate.new(
|
211
|
+
key, :html, %Q|<!--
|
212
|
+
<<prefix>>
|
213
|
+
-->
|
214
|
+
#{doctype}
|
215
|
+
<html>
|
216
|
+
|
217
|
+
<<head>>
|
218
|
+
|
219
|
+
<<body>>
|
220
|
+
</html>
|
221
|
+
|)
|
212
222
|
}
|
213
223
|
|
214
224
|
DocumentTemplate.new(
|
215
|
-
|
216
|
-
|
217
|
-
|
225
|
+
:text, :text, %q|
|
226
|
+
<<body>>
|
227
|
+
|)
|
218
228
|
DocumentTemplate.new(
|
219
|
-
|
220
|
-
|
221
|
-
|
229
|
+
:wiki, :wiki, %q|
|
230
|
+
<<body>>
|
231
|
+
|)
|
@@ -4,8 +4,21 @@
|
|
4
4
|
|
5
5
|
<<body>>
|
6
6
|
|
7
|
+
:wiki:
|
8
|
+
:target: :wiki
|
9
|
+
:source: |
|
10
|
+
|
11
|
+
<<body>>
|
12
|
+
|
13
|
+
:creole:
|
14
|
+
:target: :creole
|
15
|
+
:source: |
|
16
|
+
|
17
|
+
<<body>>
|
18
|
+
|
7
19
|
:xhtml_strict:
|
8
20
|
:target: :html
|
21
|
+
:encoding: cp1252
|
9
22
|
:source: |
|
10
23
|
<!--
|
11
24
|
<<prefix>>
|
@@ -18,25 +31,29 @@
|
|
18
31
|
<<body>>
|
19
32
|
</html>
|
20
33
|
|
21
|
-
:
|
22
|
-
:target: :
|
34
|
+
:xhtml_trans:
|
35
|
+
:target: :html
|
36
|
+
:encoding: cp1252
|
23
37
|
:source: |
|
38
|
+
<!--
|
39
|
+
<<prefix>>
|
40
|
+
-->
|
41
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
42
|
+
<html>
|
24
43
|
|
25
|
-
<<
|
26
|
-
|
27
|
-
:creole:
|
28
|
-
:target: :creole
|
29
|
-
:source: |
|
44
|
+
<<head>>
|
30
45
|
|
31
46
|
<<body>>
|
47
|
+
</html>
|
32
48
|
|
33
|
-
:
|
49
|
+
:html401_strict:
|
34
50
|
:target: :html
|
51
|
+
:encoding: cp1252
|
35
52
|
:source: |
|
36
53
|
<!--
|
37
54
|
<<prefix>>
|
38
55
|
-->
|
39
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD
|
56
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
40
57
|
<html>
|
41
58
|
|
42
59
|
<<head>>
|
@@ -44,13 +61,14 @@
|
|
44
61
|
<<body>>
|
45
62
|
</html>
|
46
63
|
|
47
|
-
:
|
64
|
+
:html401_trans:
|
48
65
|
:target: :html
|
66
|
+
:encoding: cp1252
|
49
67
|
:source: |
|
50
68
|
<!--
|
51
69
|
<<prefix>>
|
52
70
|
-->
|
53
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/
|
71
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
54
72
|
<html>
|
55
73
|
|
56
74
|
<<head>>
|
@@ -60,6 +78,7 @@
|
|
60
78
|
|
61
79
|
:html:
|
62
80
|
:target: :html
|
81
|
+
:encoding: cp1252
|
63
82
|
:source: |
|
64
83
|
<!--
|
65
84
|
<<prefix>>
|
@@ -70,22 +89,23 @@
|
|
70
89
|
<<body>>
|
71
90
|
</html>
|
72
91
|
|
73
|
-
:
|
92
|
+
:html_utf8:
|
74
93
|
:target: :html
|
94
|
+
:encoding: utf-8
|
95
|
+
#~ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
75
96
|
:source: |
|
76
97
|
<!--
|
77
98
|
<<prefix>>
|
78
99
|
-->
|
79
|
-
<!
|
100
|
+
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
80
101
|
<html>
|
81
|
-
|
82
102
|
<<head>>
|
83
|
-
|
84
103
|
<<body>>
|
85
104
|
</html>
|
86
105
|
|
87
106
|
:include:
|
88
107
|
:target: :latex
|
108
|
+
:encoding: cp1252
|
89
109
|
:source: |
|
90
110
|
<<prefix>>
|
91
111
|
% ----------------------------------------------------------------
|
@@ -96,6 +116,7 @@
|
|
96
116
|
|
97
117
|
:article:
|
98
118
|
:target: :latex
|
119
|
+
:encoding: cp1252
|
99
120
|
:source: |
|
100
121
|
<<prefix>>
|
101
122
|
\documentclass[<<classoptions>>]{scrartcl}
|
@@ -110,6 +131,45 @@
|
|
110
131
|
\end{document}
|
111
132
|
% ----------------------------------------------------------------
|
112
133
|
|
134
|
+
:include_utf8:
|
135
|
+
:target: :latex
|
136
|
+
:encoding: utf-8
|
137
|
+
:source: |
|
138
|
+
<<prefix>>
|
139
|
+
% ----------------------------------------------------------------
|
140
|
+
<<head>>
|
141
|
+
% ----------------------------------------------------------------
|
142
|
+
<<body>>
|
143
|
+
% ----------------------------------------------------------------
|
144
|
+
|
145
|
+
:article_utf8:
|
146
|
+
:target: :latex
|
147
|
+
:encoding: utf-8
|
148
|
+
:source: |
|
149
|
+
<<prefix>>
|
150
|
+
\documentclass[<<classoptions>>]{scrartcl}
|
151
|
+
\usepackage{babel}
|
152
|
+
%Encoding-package depends on TeX-engine
|
153
|
+
\usepackage{ifpdf,ifxetex,ifluatex}
|
154
|
+
\ifxetex
|
155
|
+
\usepackage{fontspec} %Without, umlauts are missing
|
156
|
+
\fi
|
157
|
+
\ifluatex
|
158
|
+
\usepackage[utf8]{luainputenc} %Or in first line: % !Mode:: "TeX:UTF-8".
|
159
|
+
\else
|
160
|
+
\ifpdf\relax
|
161
|
+
\usepackage[utf8]{inputenc}
|
162
|
+
\fi
|
163
|
+
\fi
|
164
|
+
\usepackage{hyperref}
|
165
|
+
% ----------------------------------------------------------------
|
166
|
+
<<head>>
|
167
|
+
% ----------------------------------------------------------------
|
168
|
+
\begin{document}
|
169
|
+
<<body>>
|
170
|
+
\end{document}
|
171
|
+
% ----------------------------------------------------------------
|
172
|
+
|
113
173
|
:context:
|
114
174
|
:target: :context
|
115
175
|
:source: |
|
data/lib/docgenerator.rb
CHANGED
@@ -750,7 +750,7 @@ tabhelp
|
|
750
750
|
lines << Wiki_line.new(:p, nil, @lineno)
|
751
751
|
when /^((?:\*|\#)+)(\s*)/ #:li
|
752
752
|
lines << Wiki_line.new(:li, self.inline($~.post_match, log), @lineno, $2.size, $1)
|
753
|
-
#Experiment
|
753
|
+
#Experiment for items in description
|
754
754
|
#~ when /^(:)?((?:\*|\#)+)(\s*)/ #:li
|
755
755
|
#~ puts '>' * 15
|
756
756
|
#~ puts line.inspect
|
@@ -0,0 +1,125 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
Some modification and helper to generate tests and manpages.
|
3
|
+
=end
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
require 'rake'
|
7
|
+
|
8
|
+
=begin
|
9
|
+
Load all Docgenerator parts
|
10
|
+
=end
|
11
|
+
$:.unshift('../lib')
|
12
|
+
require 'docgenerator'
|
13
|
+
module Docgenerator
|
14
|
+
=begin rdoc
|
15
|
+
Extend Element to get ids.
|
16
|
+
=end
|
17
|
+
class Element
|
18
|
+
#Hash with source files and the Element-classes inside.
|
19
|
+
SOURCE = {}
|
20
|
+
class << self
|
21
|
+
alias :old_inherited :inherited
|
22
|
+
def inherited(subclass)
|
23
|
+
old_inherited(subclass)
|
24
|
+
(SOURCE[caller.first.split(/:\d/,2).first] ||= []) << subclass
|
25
|
+
#~ puts "%-30s -> %s" % [ subclass, caller.first]
|
26
|
+
#subclass.method(:to_html).source_location]
|
27
|
+
end
|
28
|
+
#loop on each id of the Element
|
29
|
+
def each()
|
30
|
+
@@ids.values.uniq.each{|cl| yield cl } if block_given?
|
31
|
+
@@ids.values.uniq
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end #class Element
|
35
|
+
end #module Docgenerator
|
36
|
+
Docgenerator::DOCGENERATOR_LOGGER.level = Log4r::WARN
|
37
|
+
#~ require 'docgenerator/compatibility_v1'
|
38
|
+
require 'docgenerator/packages/attachfile.rb'
|
39
|
+
require 'docgenerator/packages/caption.rb'
|
40
|
+
require 'docgenerator/packages/hyperref.rb'
|
41
|
+
require 'docgenerator/packages/listings.rb'
|
42
|
+
require 'docgenerator/packages/pdfpages.rb'
|
43
|
+
require 'docgenerator/packages/rubycode4doc.rb'
|
44
|
+
require 'docgenerator/packages/scrlettr2.rb'
|
45
|
+
require 'docgenerator/packages/scrpage2.rb'
|
46
|
+
require 'docgenerator/packages/struktex.rb'
|
47
|
+
require 'docgenerator/packages/todonotes.rb'
|
48
|
+
require 'docgenerator/packages/url.rb'
|
49
|
+
|
50
|
+
##does not influence this
|
51
|
+
require 'creole/creole2doc.rb'
|
52
|
+
require 'creole/plugins/rail.rb'
|
53
|
+
require 'creole/plugins/rubycode4creole.rb'
|
54
|
+
require 'creole/plugins/struktex.rb'
|
55
|
+
require 'creole/plugins/todonotes.rb'
|
56
|
+
|
57
|
+
require 'wiki2doc/wiki2docgenerator.rb'
|
58
|
+
require 'wiki2doc/plugins/rubycode4wiki.rb'
|
59
|
+
require 'wiki2doc/plugins/struktex.rb'
|
60
|
+
|
61
|
+
=begin rdoc
|
62
|
+
List all known elements
|
63
|
+
=end
|
64
|
+
def puts_elements
|
65
|
+
ObjectSpace.each_object(Class).map{|o|
|
66
|
+
o.name || ''
|
67
|
+
}.sort.each{|o|
|
68
|
+
puts o if o =~ /^Docgenerator/
|
69
|
+
#~ puts o if o.is_a?(Docgenerator::Element)
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
=begin rdoc
|
74
|
+
Define a new outputter to catch data into an array
|
75
|
+
=end
|
76
|
+
class ArrayOutputter < Log4r::StdoutOutputter
|
77
|
+
=begin rdoc
|
78
|
+
Collect messages in array.
|
79
|
+
=end
|
80
|
+
def write(message)
|
81
|
+
@messages ||= [] #create with first call
|
82
|
+
@messages << message
|
83
|
+
end
|
84
|
+
=begin rdoc
|
85
|
+
Clear message array and return messages
|
86
|
+
=end
|
87
|
+
def flush
|
88
|
+
@messages ||= [] #create with first call
|
89
|
+
messages = @messages.dup
|
90
|
+
@messages.clear
|
91
|
+
messages
|
92
|
+
end
|
93
|
+
end #ArrayOutputter
|
94
|
+
|
95
|
+
|
96
|
+
=begin
|
97
|
+
Separate the elements to different files (manpage/testfile)
|
98
|
+
=end
|
99
|
+
FILE_SEPARATION = {}
|
100
|
+
FILE_SEPARATION_REQUIREMENTS = {} #needed for tests
|
101
|
+
#Dummy-element makes error and is not needed to be tested.
|
102
|
+
already_in_elementlist = [ Docgenerator::Sectioning::DummySectioning ]
|
103
|
+
|
104
|
+
Docgenerator::Element::SOURCE.each{|sourcefile, elementlist|
|
105
|
+
FILE_SEPARATION[File.basename(sourcefile)] = elementlist
|
106
|
+
FILE_SEPARATION_REQUIREMENTS[File.basename(sourcefile)] = sourcefile.split(/lib\//).last
|
107
|
+
already_in_elementlist.concat(elementlist)
|
108
|
+
}
|
109
|
+
#Splitt base-elements in different files
|
110
|
+
{
|
111
|
+
'characters.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Characters::/},
|
112
|
+
'environments.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Environments::/},
|
113
|
+
'lists.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Lists::/},
|
114
|
+
'footnote.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Footnote/}, #no own module
|
115
|
+
'sectioning.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Sectioning::/} - [ ],
|
116
|
+
'tables.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Tables::/},
|
117
|
+
#~ #If not already read by others
|
118
|
+
'elements.rb' => Docgenerator::Element.each.select{|cl| cl.name =~ /::Elements::/},
|
119
|
+
'others.rb' => Docgenerator::Element.each #/./,#all other elements
|
120
|
+
}.each{|basefile, elementlist|
|
121
|
+
FILE_SEPARATION[basefile] = ( elementlist - already_in_elementlist )
|
122
|
+
already_in_elementlist.concat(elementlist)
|
123
|
+
}
|
124
|
+
|
125
|
+
|