docgenerator 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/examples/creole_example_tabular.rb +95 -0
  2. data/examples/docgenerator_example.rb +5 -5
  3. data/lib/creole/creole2doc.rb +28 -18
  4. data/lib/creole/creole_inclusions.rb +4 -4
  5. data/lib/creole/creole_placeholder.rb +4 -1
  6. data/lib/creole/creole_tabular.rb +173 -155
  7. data/lib/creole/plugins/rail.rb +118 -119
  8. data/lib/creole/plugins/struktex.rb +35 -35
  9. data/lib/creole/plugins/todonotes.rb +8 -1
  10. data/lib/docgenerator/attribute.rb +160 -160
  11. data/lib/docgenerator/characters.rb +343 -311
  12. data/lib/docgenerator/css.rb +167 -167
  13. data/lib/docgenerator/document.rb +525 -511
  14. data/lib/docgenerator/element.rb +316 -316
  15. data/lib/docgenerator/element_meta.rb +114 -114
  16. data/lib/docgenerator/elements.rb +19 -9
  17. data/lib/docgenerator/environments.rb +3 -1
  18. data/lib/docgenerator/lists.rb +177 -174
  19. data/lib/docgenerator/packages/hyperref.rb +74 -70
  20. data/lib/docgenerator/packages/multicol.rb +33 -0
  21. data/lib/docgenerator/packages/scrlettr2.rb +152 -151
  22. data/lib/docgenerator/packages/todonotes.rb +1 -1
  23. data/lib/docgenerator/tabular.rb +463 -400
  24. data/lib/docgenerator/templates/docgenerator_template.rb +94 -84
  25. data/lib/docgenerator/templates/docgenerator_template.yaml +75 -15
  26. data/lib/docgenerator.rb +1 -1
  27. data/lib/wiki2doc/wiki2docgenerator.rb +1 -1
  28. data/meta_test_and_doc/build__meta.rb +125 -0
  29. data/meta_test_and_doc/build_doc.rb +333 -0
  30. data/meta_test_and_doc/build_test.rb +251 -0
  31. data/meta_test_and_doc/manpages/attachfile.rb +389 -0
  32. data/meta_test_and_doc/manpages/caption.rb +133 -0
  33. data/meta_test_and_doc/manpages/characters.rb +3738 -0
  34. data/meta_test_and_doc/manpages/elements.rb +6851 -0
  35. data/meta_test_and_doc/manpages/environments.rb +985 -0
  36. data/meta_test_and_doc/manpages/footnote.rb +439 -0
  37. data/meta_test_and_doc/manpages/hyperref.rb +605 -0
  38. data/meta_test_and_doc/manpages/listings.rb +988 -0
  39. data/meta_test_and_doc/manpages/lists.rb +1463 -0
  40. data/meta_test_and_doc/manpages/others.rb +129 -0
  41. data/meta_test_and_doc/manpages/packages.rb +13 -0
  42. data/meta_test_and_doc/manpages/pdfpages.rb +108 -0
  43. data/meta_test_and_doc/manpages/readme.rdoc +9 -0
  44. data/meta_test_and_doc/manpages/scrlettr2.rb +362 -0
  45. data/meta_test_and_doc/manpages/scrpage2.rb +2028 -0
  46. data/meta_test_and_doc/manpages/sectioning.rb +2467 -0
  47. data/meta_test_and_doc/manpages/tables.rb +2088 -0
  48. data/meta_test_and_doc/manpages/todonotes.rb +235 -0
  49. data/meta_test_and_doc/manpages/wiki2docgenerator.rb +64 -0
  50. data/{readme.rd → readme.rdoc} +18 -1
  51. data/unittest/expected/test_tabular.creole +33 -0
  52. data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
  53. data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
  54. data/unittest/expected_creole/test_creole_creole1.0test.text +3 -3
  55. data/unittest/expected_creole/test_creole_inline_apostroph.html +6 -0
  56. data/unittest/expected_creole/test_creole_inline_apostroph.latex +8 -0
  57. data/unittest/expected_creole/test_creole_inline_apostroph.text +4 -0
  58. data/unittest/expected_creole/test_creole_input.normsource +12 -12
  59. data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
  60. data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
  61. data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
  62. data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
  63. data/unittest/expected_creole/test_creole_links_implicit_end.html +1 -1
  64. data/unittest/expected_creole/test_creole_links_implicit_end.latex +1 -1
  65. data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
  66. data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +83 -0
  67. data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
  68. data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +27 -0
  69. data/unittest/expected_creole/test_creole_tabular.creole +22 -0
  70. data/unittest/expected_creole/test_creole_tabular_creole.creole +19 -0
  71. data/unittest/expected_creole/test_creole_tabular_css.creole +24 -0
  72. data/unittest/expected_creole/test_creole_tabular_multicols.creole +16 -0
  73. data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
  74. data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
  75. data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
  76. data/unittest/expected_creole/test_creole_toc_level_text.html +2 -2
  77. data/unittest/expected_creole/test_creole_toc_level_text.latex +2 -2
  78. data/unittest/expected_packages/test_multicol_3.tex +2 -0
  79. data/unittest/expected_packages/test_multicol_3_titleline.tex +2 -0
  80. data/unittest/expected_templates/test_article.tex +23 -0
  81. data/unittest/expected_templates/test_article_utf8.tex +34 -0
  82. data/unittest/expected_templates/test_context.miv +18 -0
  83. data/unittest/expected_templates/test_creole.creole +8 -0
  84. data/unittest/expected_templates/test_html.html +12 -0
  85. data/unittest/expected_templates/test_html401_strict.html +14 -0
  86. data/unittest/expected_templates/test_html401_trans.html +14 -0
  87. data/unittest/expected_templates/test_html_utf8.html +14 -0
  88. data/unittest/expected_templates/test_include.tex +17 -0
  89. data/unittest/expected_templates/test_include_utf8.tex +17 -0
  90. data/unittest/expected_templates/test_text.txt +6 -0
  91. data/unittest/expected_templates/test_wiki.wiki +6 -0
  92. data/unittest/expected_templates/test_xhtml_strict.html +14 -0
  93. data/unittest/expected_templates/test_xhtml_trans.html +14 -0
  94. data/unittest/unittest_creole.rb +27 -6
  95. data/unittest/unittest_creole_placeholders.rb +1 -123
  96. data/unittest/unittest_creole_tabular.rb +174 -0
  97. data/unittest/unittest_docgenerator.rb +4 -3
  98. data/unittest/unittest_docgenerator_characters.rb +4769 -615
  99. data/unittest/unittest_packages_multicol.rb +84 -0
  100. data/unittest/unittest_rubycode4doc.rb +0 -1
  101. data/unittest/unittest_templates.rb +64 -0
  102. metadata +163 -77
  103. data/build_test_and_doc.rb +0 -505
  104. data/manpage_elements.rb +0 -10411
@@ -1,5 +1,6 @@
1
- #encoding: cp1252
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
- This Source-code is stored in cp1252.
11
- All templates will get this encoding.
11
+ All templates will include their encoding.
12
+ Default is UTF-8.
12
13
  =end
13
14
  class DocumentTemplate
14
- @@templates = {}
15
+ @@templates = {}
15
16
  =begin rdoc
16
17
 
17
18
  Define a template.
18
19
 
19
- A template gets a key, a target and the corresponding source.
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
- -:wiki
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
- def initialize( key, target, template)
36
+ def initialize( key, target, template, encoding = Encoding.find('UTF-8'))
34
37
  @key = key
35
38
  @target = target
36
- @template = template.gsub(/^\t*/, '')
37
- case target
38
- when :text
39
- when :wiki
40
- when :creole
41
- when :latex
42
- when :context
43
- when :html
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
- end
50
+ end
47
51
 
48
- if @@templates[key]
52
+ if @@templates[key]
49
53
  DOCGENERATOR_LOGGER.warn("DocumentTemplate: Double definition of template #{key.inspect}") if DOCGENERATOR_LOGGER.warn?
50
54
  end
51
- @@templates[key] = self
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, data[:target], data[:source] )
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
- :include, :latex, %q|<<prefix>>
142
- % ----------------------------------------------------------------
143
- <<head>>
144
- % ----------------------------------------------------------------
145
- <<body>>
146
- % ----------------------------------------------------------------
147
- |)
148
-
151
+ :include, :latex, %q|<<prefix>>
152
+ % ----------------------------------------------------------------
153
+ <<head>>
154
+ % ----------------------------------------------------------------
155
+ <<body>>
156
+ % ----------------------------------------------------------------
157
+ |)
158
+
149
159
  DocumentTemplate.new(
150
- :article, :latex, %q|<<prefix>>
151
- \documentclass[<<classoptions>>]{scrartcl}
152
- \usepackage{babel}
153
- \usepackage[ansinew]{inputenc}
154
- \usepackage{hyperref}
155
- % ----------------------------------------------------------------
156
- <<head>>
157
- % ----------------------------------------------------------------
158
- \begin{document}
159
- <<body>>
160
- \end{document}
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
- #~ :report, '',
165
- #~ |)
174
+ #~ :report, '',
175
+ #~ |)
166
176
  #~ DocumentTemplate.new(
167
- #~ :book, '',
168
- #~ |)
177
+ #~ :book, '',
178
+ #~ |)
169
179
 
170
- #~ <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
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
- :context, %q|<<prefix>>
174
- % ----------------------------------------------------------------
175
- <<head>>
176
- % ----------------------------------------------------------------
183
+ :context, %q|<<prefix>>
184
+ % ----------------------------------------------------------------
185
+ <<head>>
186
+ % ----------------------------------------------------------------
177
187
  \starttext
178
- <<body>>
188
+ <<body>>
179
189
  \stoptext
180
- % ----------------------------------------------------------------
181
- |)
190
+ % ----------------------------------------------------------------
191
+ |)
182
192
 
183
193
  DocumentTemplate.new(
184
- :html, :html, %q|<!--
185
- <<prefix>>
186
- -->
187
- <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
188
- <html>
189
- <<head>>
190
- <<body>>
191
- </html>
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
- :xhtml_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
196
- :xhtml_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
197
- :html401_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
198
- :html401_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
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
- DocumentTemplate.new(
201
- key, :html, %Q|<!--
202
- <<prefix>>
203
- -->
204
- #{doctype}
205
- <html>
206
-
207
- <<head>>
208
-
209
- <<body>>
210
- </html>
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
- :text, :text, %q|
216
- <<body>>
217
- |)
225
+ :text, :text, %q|
226
+ <<body>>
227
+ |)
218
228
  DocumentTemplate.new(
219
- :wiki, :wiki, %q|
220
- <<body>>
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
- :wiki:
22
- :target: :wiki
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
- <<body>>
26
-
27
- :creole:
28
- :target: :creole
29
- :source: |
44
+ <<head>>
30
45
 
31
46
  <<body>>
47
+ </html>
32
48
 
33
- :xhtml_trans:
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 XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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
- :html401_strict:
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/strict.dtd">
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
- :html401_trans:
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
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
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
@@ -82,7 +82,7 @@ All classes of this gem are encapsulated in module Docgenerator.
82
82
  =end
83
83
  module Docgenerator
84
84
  #Define Version number
85
- VERSION = '2.0.0'
85
+ VERSION = '2.1.0'
86
86
  class << self
87
87
  @trace = nil
88
88
  =begin rdoc
@@ -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 f�r items in description
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
+