docgenerator 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -16,12 +16,12 @@ Often there is the problem, that you get an error when you write the element.
16
16
  But the error is done, when the element is created.
17
17
  When you redefine ELEMENTS_TRACE, some tracing information are stored during creation.
18
18
  =end
19
- class Element
20
- include Docgenerator #get VERSION
19
+ class Element
20
+ include Docgenerator #get VERSION
21
21
 
22
- SUPPORTED_TARGETS = [ :latex, :html, :wiki, :text, :debug ]
23
- SUPPORTED_TARGETS << :context #Added later
24
- SUPPORTED_TARGETS << :creole #Added later
22
+ SUPPORTED_TARGETS = [ :latex, :html, :wiki, :text, :debug ]
23
+ SUPPORTED_TARGETS << :context #Added later
24
+ SUPPORTED_TARGETS << :creole #Added later
25
25
 
26
26
  =begin rdoc
27
27
  Defines an element.
@@ -36,64 +36,64 @@ There are two ways to add values:
36
36
  :log is the default attribute for the logger.
37
37
  In Elementto_doc you can give another logger!
38
38
  =end
39
- def initialize( attr={}, content = nil)
40
- #@attr is a hash containing the values for each attribute.
41
- @attr = Hash.new( )
42
- #Attention! in to_doc another logger may be given.
43
- @log = attr[:log] || DOCGENERATOR_DEFAULT_LOGGER
44
- attr.delete(:log) #remove from attr-interface
45
- #attr alias
46
- @attr_alias = Hash.new( )
47
- if self.content?()
48
- @content = []
49
- else
50
- @content = nil
51
- end
52
- @crbefore = false #make \n before element
53
- @crmid = false #make \n before and after opening/closing html-tag
54
- @crafter = false #make \n after element
55
- #List of targets, where the element can be used.
56
- #Details see method restrict_to()
57
- #Default: allsupported targets
58
- @targets = SUPPORTED_TARGETS.dup
59
- @suppressed_targets = []
60
-
61
- #Initialize the attribute hash.
62
- self.class.attributes.each{ |k,a|
63
- #type check on Attribute does not work .
64
- if a.kind_of?( Symbol )
65
- #Filled in the second run
66
- #~ @attr[k] = @attr[a]
67
- elsif a #.kind_of?( Attribute )
68
- @attr[k] = a.new( k, self )
69
- else
70
- @attr[k] = Attribute.create().new( k, self )
71
- end
72
- }
73
- #Assign Alias-Attributes
74
- self.class.attributes.each{ |k,a|
75
- next if !a.kind_of?( Symbol )
76
- if @attr[a]
77
- @attr_alias[k] = @attr[a]
39
+ def initialize( attr={}, content = nil)
40
+ #@attr is a hash containing the values for each attribute.
41
+ @attr = Hash.new( )
42
+ #Attention! in to_doc another logger may be given.
43
+ @log = attr[:log] || DOCGENERATOR_DEFAULT_LOGGER
44
+ attr.delete(:log) #remove from attr-interface
45
+ #attr alias
46
+ @attr_alias = Hash.new( )
47
+ if self.content?()
48
+ @content = []
78
49
  else
79
- @log.warn("Undefined Alias-Attribute #{k}") if @log.warn?
80
- @attr[k] = Attribute.create().new( k, self )
50
+ @content = nil
81
51
  end
82
- }
83
- attr.each{ |k,v|
84
- if @attr[k]
85
- @attr[k] << v
86
- elsif @attr_alias[k]
87
- @attr_alias[k] << v
88
- else
89
- @log.warn("Usage of unknown attribute '#{k}' in #{self.inspect}") if @log.warn?
90
- #~ @log.debug(caller) if @log.debug?
91
- end
92
- }
93
- #store info, where the element was created
94
- @creation_caller = prepare_tracing_info() if Docgenerator.trace_on?
95
- self << content if content
96
- end
52
+ @crbefore = false #make \n before element
53
+ @crmid = false #make \n before and after opening/closing html-tag
54
+ @crafter = false #make \n after element
55
+ #List of targets, where the element can be used.
56
+ #Details see method restrict_to()
57
+ #Default: allsupported targets
58
+ @targets = SUPPORTED_TARGETS.dup
59
+ @suppressed_targets = []
60
+
61
+ #Initialize the attribute hash.
62
+ self.class.attributes.each{ |k,a|
63
+ #type check on Attribute does not work .
64
+ if a.kind_of?( Symbol )
65
+ #Filled in the second run
66
+ #~ @attr[k] = @attr[a]
67
+ elsif a #.kind_of?( Attribute )
68
+ @attr[k] = a.new( k, self )
69
+ else
70
+ @attr[k] = Attribute.create().new( k, self )
71
+ end
72
+ }
73
+ #Assign Alias-Attributes
74
+ self.class.attributes.each{ |k,a|
75
+ next if !a.kind_of?( Symbol )
76
+ if @attr[a]
77
+ @attr_alias[k] = @attr[a]
78
+ else
79
+ @log.warn("Undefined Alias-Attribute #{k}") if @log.warn?
80
+ @attr[k] = Attribute.create().new( k, self )
81
+ end
82
+ }
83
+ attr.each{ |k,v|
84
+ if @attr[k]
85
+ @attr[k] << v
86
+ elsif @attr_alias[k]
87
+ @attr_alias[k] << v
88
+ else
89
+ @log.warn("Usage of unknown attribute '#{k}' in #{self.inspect}") if @log.warn?
90
+ #~ @log.debug(caller) if @log.debug?
91
+ end
92
+ }
93
+ #store info, where the element was created
94
+ @creation_caller = prepare_tracing_info() if Docgenerator.trace_on?
95
+ self << content if content
96
+ end
97
97
  =begin rdoc
98
98
  Only for debbuging reasons.
99
99
 
@@ -103,31 +103,31 @@ This should be the location, where the element is created.
103
103
 
104
104
  Via Element#inspect you get access to this information.
105
105
  =end
106
- def prepare_tracing_info()
107
- caller().each{|c|
108
- next if ( /lib\/(docgenerator|creole|wiki2doc)/ =~ c )
109
- return c
110
- }
111
- #--> No calling stack outside lib/docgenerator found --> Error
112
- @log.error('Element#prepare_tracing_info: Found no starting place in caller stack') if @log.error?
113
- caller().each{|c| @log.debug("\t#{c}") } if @log.debug?
114
- return caller()
115
- end
106
+ def prepare_tracing_info()
107
+ caller().each{|c|
108
+ next if ( /lib\/(docgenerator|creole|wiki2doc)/ =~ c )
109
+ return c
110
+ }
111
+ #--> No calling stack outside lib/docgenerator found --> Error
112
+ @log.error('Element#prepare_tracing_info: Found no starting place in caller stack') if @log.error?
113
+ caller().each{|c| @log.debug("\t#{c}") } if @log.debug?
114
+ return caller()
115
+ end
116
116
  =begin rdoc
117
117
  Set a text for the inspect command.
118
118
 
119
119
  Nil if the information was not collected at Element#new.
120
120
  =end
121
- def inspect_creation_caller
122
- if @creation_caller
123
- ", created at #{@creation_caller}"
124
- else
125
- nil #'unknown. Please set Elements.trace if needed'
121
+ def inspect_creation_caller
122
+ if @creation_caller
123
+ ", created at #{@creation_caller}"
124
+ else
125
+ nil #'unknown. Please set Elements.trace if needed'
126
+ end
127
+ end
128
+ def inspect()
129
+ return "<#{self.class}#{inspect_creation_caller}>"
126
130
  end
127
- end
128
- def inspect()
129
- return "<#{self.class}#{inspect_creation_caller}>"
130
- end
131
131
 
132
132
  =begin rdoc
133
133
  List (array) of targets, where the element can be used.
@@ -135,100 +135,100 @@ Default are all supported targets.
135
135
 
136
136
  With restrictions of this attribute, elements can be restricted on special documents.
137
137
  =end
138
- def restrict_to( *argv )
139
- @targets = []
140
- @suppressed_targets = SUPPORTED_TARGETS.dup
141
- @log.info("Element#restrict_to: #{self.inspect} restrict to #{argv.inspect}") if @log.warn?
142
- argv.each{ |arg|
143
- #~ if ! SUPPORTED_TARGETS.include?( arg )
144
- if ! @suppressed_targets.delete( arg )
145
- @log.warn("Restriction for unsupported target #{arg}") if @log.warn?
146
- end
147
- @targets << arg
148
- }
149
- self
150
- end
151
- #Accessor on content
152
- attr_reader :content
153
- #Logger of the element
154
- attr_reader :log
138
+ def restrict_to( *argv )
139
+ @targets = []
140
+ @suppressed_targets = SUPPORTED_TARGETS.dup
141
+ @log.info("Element#restrict_to: #{self.inspect} restrict to #{argv.inspect}") if @log.warn?
142
+ argv.each{ |arg|
143
+ #~ if ! SUPPORTED_TARGETS.include?( arg )
144
+ if ! @suppressed_targets.delete( arg )
145
+ @log.warn("Restriction for unsupported target #{arg}") if @log.warn?
146
+ end
147
+ @targets << arg
148
+ }
149
+ self
150
+ end
151
+ #Accessor on content
152
+ attr_reader :content
153
+ #Logger of the element
154
+ attr_reader :log
155
155
  =begin rdoc
156
156
  Add something to the content.
157
157
  Only possible on elements, which supports "content".
158
158
  =end
159
- def << ( content )
160
- if @content
161
- @content << content
162
- else
163
- @log.warn("Add content to an element without this feature #{self.inspect}, #{content.inspect}") if @log.warn?
159
+ def << ( content )
160
+ if @content
161
+ @content << content
162
+ else
163
+ @log.warn("Add content to an element without this feature #{self.inspect}, #{content.inspect}") if @log.warn?
164
+ end
164
165
  end
165
- end
166
166
 
167
167
  =begin rdoc
168
168
  Add content after a target (other content)
169
169
  insertafter(target,*obj)
170
170
  Requires the ability of "content".
171
171
  =end
172
- def insertafter(target,*obj)
173
- self.insert(target, 1, obj)
174
- end
172
+ def insertafter(target,*obj)
173
+ self.insert(target, 1, obj)
174
+ end
175
175
  =begin rdoc
176
176
  Add content before a target (other content)
177
177
  insertbefore(target,*obj)
178
178
  Requires the ability of "content".
179
179
  =end
180
- def insertbefore(target,*obj)
181
- self.insert(target, 0, obj)
182
- end
180
+ def insertbefore(target,*obj)
181
+ self.insert(target, 0, obj)
182
+ end
183
183
  =begin rdoc
184
184
  Insert content relative to a given target.
185
185
  The target must exist, pos defines the relative position (0=before, 1=one after the element).
186
186
  Method called by Element#insertbefore and Element#insertafter.
187
187
  =end
188
- def insert(target,pos,*obj )
189
- if @content
190
- if @content.include?( target )
191
- @content[@content.index(target)+pos ,0] = obj
188
+ def insert(target,pos,*obj )
189
+ if @content
190
+ if @content.include?( target )
191
+ @content[@content.index(target)+pos ,0] = obj
192
+ else
193
+ @log.warn("Insert content not possible. Reference object does not exist (#{target.inspect})") if @log.warn?
194
+ end
192
195
  else
193
- @log.warn("Insert content not possible. Reference object does not exist (#{target.inspect})") if @log.warn?
194
- end
195
- else
196
- @log.warn("Add content to an element without this feature") if @log.warn?
197
- end
198
- self
199
- end
196
+ @log.warn("Add content to an element without this feature") if @log.warn?
197
+ end
198
+ self
199
+ end
200
200
  =begin rdoc
201
201
  Delete the given object from content.
202
202
  =end
203
- def delete(target )
204
- if @content
205
- @content.delete( target )
206
- else
207
- @log.warn("Delete content of an element without this feature") if @log.warn?
208
- end
209
- self
210
- end
203
+ def delete(target )
204
+ if @content
205
+ @content.delete( target )
206
+ else
207
+ @log.warn("Delete content of an element without this feature") if @log.warn?
208
+ end
209
+ self
210
+ end
211
211
  =begin rdoc
212
212
  Insert an empty line after the last entry.
213
213
 
214
214
  Example:
215
215
  <tag>content</tag>[CR]
216
216
  =end
217
- def cr()
218
- @crafter = true
219
- self
220
- end
217
+ def cr()
218
+ @crafter = true
219
+ self
220
+ end
221
221
  =begin rdoc
222
222
  Insert an empty line before and after the last entry.
223
223
 
224
224
  Example:
225
225
  [CR]<tag>content</tag>[CR]
226
226
  =end
227
- def Cr()
228
- @crbefore = true
229
- @crafter = true
230
- self
231
- end
227
+ def Cr()
228
+ @crbefore = true
229
+ @crafter = true
230
+ self
231
+ end
232
232
  =begin rdoc
233
233
  Insert an empty line after the last entry and after the opening of the tag.
234
234
 
@@ -244,28 +244,28 @@ Example:
244
244
  <li>item with cr</li>
245
245
  </ul>
246
246
  =end
247
- def cR()
248
- @crbefore = false
249
- @crmid = true
250
- @crafter = true
251
- self
252
- end
247
+ def cR()
248
+ @crbefore = false
249
+ @crmid = true
250
+ @crafter = true
251
+ self
252
+ end
253
253
  =begin rdoc
254
254
  Insert an empty line before and after the last entry and after the opening of the tag.
255
255
 
256
256
  Example:
257
257
  [CR]<tag>[CR]content</tag>[CR]
258
258
  =end
259
- def CR()
260
- @crbefore = true
261
- @crmid = true
262
- @crafter = true
263
- self
264
- end
259
+ def CR()
260
+ @crbefore = true
261
+ @crmid = true
262
+ @crafter = true
263
+ self
264
+ end
265
265
  =begin rdoc
266
266
  Accessor on attribute list
267
267
  =end
268
- attr_reader :attr
268
+ attr_reader :attr
269
269
  =begin rdoc
270
270
  Return an attribute to add content.
271
271
 
@@ -276,16 +276,16 @@ Example:
276
276
  Normally, this is the better solution:
277
277
  sec = element(:section, { :shorttitle => 'shorttitle'}, 'title' )
278
278
  =end
279
- def [] (key)
280
- attr = @attr[key]
281
- #If Attribute does not exist, take a look, if it is an alias-name.
282
- attr = @attr_alias[key] if !attr
283
- if ! attr
284
- @log.warn("Request unknown attribute '#{key}', return a dummy (#{self.inspect})") if @log.warn?
285
- attr = Attribute.create( ).new(key, self)
279
+ def [] (key)
280
+ attr = @attr[key]
281
+ #If Attribute does not exist, take a look, if it is an alias-name.
282
+ attr = @attr_alias[key] if !attr
283
+ if ! attr
284
+ @log.warn("Request unknown attribute '#{key}', return a dummy (#{self.inspect})") if @log.warn?
285
+ attr = Attribute.create( ).new(key, self)
286
+ end
287
+ return attr
286
288
  end
287
- return attr
288
- end
289
289
  =begin rdoc
290
290
  Default setting, each element class may contain contents.
291
291
  Can be redefined by meta-method Elements.has_no_content
@@ -294,16 +294,16 @@ Can be redefined by meta-method Elements.has_no_content
294
294
  - false: no content, no endtag, but tag closed with / (example: Docgenerator::Elements::Newline as < br/>)
295
295
  - nil: no content, no endtag, no closing (example: Docgenerator::Elements::Newline as < br>)
296
296
  =end
297
- def content?()
298
- return true
299
- end
297
+ def content?()
298
+ return true
299
+ end
300
300
  =begin rdoc
301
301
  check if there is content assigned.
302
302
  =end
303
- def empty?()
304
- return @content.empty?
305
- end
306
- @@level = 0
303
+ def empty?()
304
+ return @content.empty?
305
+ end
306
+ @@level = 0
307
307
  =begin rdoc
308
308
  Build a String to be used for the target document.
309
309
  Calls
@@ -316,99 +316,99 @@ Calls
316
316
 
317
317
  Via the options-hash, you can transport additional information.
318
318
  =end
319
- def to_doc( target, options = {} )
320
- o = set_option_defaults(options)
321
- o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
322
- #Return empty string, if target is not requested.
323
- if ! @targets.include?( target )
324
- if @suppressed_targets.include?(target)
325
- o[:log].info("Element#to_doc: Content of #{self.inspect} suppressed for Target #{target.inspect}.") if o[:log].info?
326
- else
327
- o[:log].warn("Element#to_doc: Target #{target.inspect} not supported for #{self.inspect}.") if o[:log].warn?
319
+ def to_doc( target, options = {} )
320
+ o = set_option_defaults(options)
321
+ o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
322
+ #Return empty string, if target is not requested.
323
+ if ! @targets.include?( target )
324
+ if @suppressed_targets.include?(target) #an Element#restrict_to was defined.
325
+ o[:log].debug("Element#to_doc: Content of #{self.inspect} suppressed for Target #{target.inspect}. (use of restrict_to ?)") if o[:log].debug?
326
+ else
327
+ o[:log].warn("Element#to_doc: Target #{target.inspect} not supported for #{self.inspect}.") if o[:log].warn?
328
+ end
329
+ return ''
328
330
  end
329
- return ''
330
- end
331
- #Some checks
332
- @attr.each{|k,v|
333
- if v.required? and v.to_s == '' and v.settings.include?(target)
334
- o[:log].error "#{self.inspect}: Attribut '#{k}' without required value" if o[:log].error?
331
+ #Some checks
332
+ @attr.each{|k,v|
333
+ if v.required? and v.to_s == '' and v.settings.include?(target)
334
+ o[:log].error "#{self.inspect}: Attribut '#{k}' without required value" if o[:log].error?
335
+ end
336
+ }
337
+ #Build the string.
338
+ result = ''
339
+
340
+ case target
341
+ when :latex
342
+ result = to_latex(o)
343
+ when :context
344
+ result = to_context(o)
345
+ when :html
346
+ result = to_html(o)
347
+ when :wiki
348
+ result = to_wiki(o)
349
+ when :creole
350
+ result = to_creole(o)
351
+ when :text
352
+ result = to_text(o)
353
+ else
354
+ o[:log].fatal("Undefined target format '#{target}'") if o[:log].fatal?
335
355
  end
336
- }
337
- #Build the string.
338
- result = ''
339
-
340
- case target
341
- when :latex
342
- result = to_latex(o)
343
- when :context
344
- result = to_context(o)
345
- when :html
346
- result = to_html(o)
347
- when :wiki
348
- result = to_wiki(o)
349
- when :creole
350
- result = to_creole(o)
351
- when :text
352
- result = to_text(o)
353
- else
354
- o[:log].fatal("Undefined target format '#{target}'") if o[:log].fatal?
356
+ #Already added in submethods
357
+ #~ result = "\n#{result}" if @crbefore
358
+ #~ result << "\n" if @crafter
359
+ return result
355
360
  end
356
- #Already added in submethods
357
- #~ result = "\n#{result}" if @crbefore
358
- #~ result << "\n" if @crafter
359
- return result
360
- end
361
361
  =begin rdoc
362
362
  This is a dummy method, called from Element#to_s for the target format LaTeX.
363
363
  This method must be overwritten from the element class.
364
364
 
365
365
  By default, the concatenation of all ids and the content is taken.
366
366
  =end
367
- def to_latex(options = {})
368
- o = set_option_defaults(options)
369
- makroname = 'dummy'
370
- self.element_ids.each{|id|
371
- makroname = id if id.is_a?(Symbol) or id.is_a?(String)
372
- }
373
- o[:log].error("Missing output routine for LaTeX, use \\#{makroname} (#{self.inspect})")
374
- cmd = ''
375
- cmd << "\n" if @crbefore
376
- cmd << "\\#{makroname}{#{@content.to_latex(options)}}"
377
- cmd << "\n" if @crafter
378
- return cmd
379
- end
367
+ def to_latex(options = {})
368
+ o = set_option_defaults(options)
369
+ makroname = 'dummy'
370
+ self.element_ids.each{|id|
371
+ makroname = id if id.is_a?(Symbol) or id.is_a?(String)
372
+ }
373
+ o[:log].error("Missing output routine for LaTeX, use \\#{makroname} (#{self.inspect})")
374
+ cmd = ''
375
+ cmd << "\n" if @crbefore
376
+ cmd << "\\#{makroname}{#{@content.to_latex(options)}}"
377
+ cmd << "\n" if @crafter
378
+ return cmd
379
+ end
380
380
  =begin rdoc
381
381
  Create context-output.
382
382
 
383
383
  ConTeXt-support is added later and there are a lot of gaps (2009-07-01)
384
384
  =end
385
- def to_context(options = {})
386
- o = set_option_defaults(options)
387
- makroname = 'dummy'
388
- self.element_ids.each{|id|
389
- makroname = id if id.is_a?(Symbol) or id.is_a?(String)
390
- }
391
- o[:log].error("Missing output routine for ConTeXt, use \\#{makroname} (#{self.inspect})")
392
-
393
- cmd = ''
394
- cmd << "\n" if @crbefore
395
- cmd << "\\#{makroname}{#{@content.to_context(options)}}"
396
- cmd << "\n" if @crafter
397
- return cmd
398
- end
385
+ def to_context(options = {})
386
+ o = set_option_defaults(options)
387
+ makroname = 'dummy'
388
+ self.element_ids.each{|id|
389
+ makroname = id if id.is_a?(Symbol) or id.is_a?(String)
390
+ }
391
+ o[:log].error("Missing output routine for ConTeXt, use \\#{makroname} (#{self.inspect})")
392
+
393
+ cmd = ''
394
+ cmd << "\n" if @crbefore
395
+ cmd << "\\#{makroname}{#{@content.to_context(options)}}"
396
+ cmd << "\n" if @crafter
397
+ return cmd
398
+ end
399
399
  =begin rdoc
400
400
  Method for definition inside Element.create.
401
401
  =end
402
- def linebreak( flag = true )
403
- flag ? "\n" : ''
404
- end
402
+ def linebreak( flag = true )
403
+ flag ? "\n" : ''
404
+ end
405
405
  =begin rdoc
406
406
  Prints the optional attribut key inside []. If empty, nil is returned
407
407
  =end
408
- def texoptional(key)
409
- return nil unless @attr[key].filled?
410
- return "[#{@attr[key]}]"
411
- end
408
+ def texoptional(key)
409
+ return nil unless @attr[key].filled?
410
+ return "[#{@attr[key]}]"
411
+ end
412
412
  =begin rdoc
413
413
  Build key-val options from attributs.
414
414
  Used e.g. by includegraphics.
@@ -435,19 +435,19 @@ Example (Packages::IncludePDF):
435
435
 
436
436
 
437
437
  =end
438
- def texkeyval()
439
- keyval = []
440
- @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
441
- next unless v.texkeyval?
442
- case v.content
443
- when true, [true]; keyval << "#{k}"
444
- when false, [false] #ignore
445
- else #take the value
446
- keyval << "#{k}={#{v}}" unless v.to_s.empty?
447
- end
448
- }
449
- return keyval.join(', ')
450
- end
438
+ def texkeyval()
439
+ keyval = []
440
+ @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
441
+ next unless v.texkeyval?
442
+ case v.content
443
+ when true, [true]; keyval << "#{k}"
444
+ when false, [false] #ignore
445
+ else #take the value
446
+ keyval << "#{k}={#{v}}" unless v.to_s.empty?
447
+ end
448
+ }
449
+ return keyval.join(', ')
450
+ end
451
451
  =begin rdoc
452
452
  Define the tag for html-output.
453
453
 
@@ -456,9 +456,9 @@ Redfinition is made by Element.add_html_tag.
456
456
 
457
457
  htmltag nil/false supress the output.
458
458
  =end
459
- def htmltag()
460
- ''
461
- end
459
+ def htmltag()
460
+ ''
461
+ end
462
462
  =begin rdoc
463
463
  This is a dummy method, called from Element#to_doc for the target format HTML.
464
464
 
@@ -467,77 +467,77 @@ If Element#htmltag is nil/false, nothing '' is returned.
467
467
 
468
468
  This method can be overwritten from the element class.
469
469
  =end
470
- def to_html(options = {})
471
- o = set_option_defaults(options)
472
- tag = htmltag()
473
- if ! tag
474
- o[:log].error("No HTML element available (#{self.inspect})") if o[:log].error?
475
- return ''
476
- elsif tag == ''
477
- tag = 'span'
478
- o[:log].error("Missing output routine for HTML (#{self.inspect})") if o[:log].error?
479
- end
480
- #Test if the HTML-Tag should contain something, but there is nothing.
481
- #If :empty_ok it is ok, that there is no content (e.g <td>)
482
- #May make problems, if an empty tag is used to set a id-mark.
483
- if content?() and content? != :empty_ok and
484
- ( ! @content or @content == [] or @content == [nil] )
485
- o[:log].warn("HTML-Tag #{tag} without content -> ignored #{self.inspect}") if o[:log].warn?
486
- return ''
487
- end
488
- html = String.new()
489
- html << "\n" if @crbefore
490
- html << "<#{tag} "
491
- @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
492
- html << "#{k} = \"#{v}\" " if v.to_s != '' and v.html?
493
- }
494
- if @content
495
- html << ">"
496
- html <<"\n" if @crmid
497
- html << "#{@content.to_html(options)}"
498
- html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
499
- html << "</#{tag}>"
500
- elsif content?() == nil
501
- html << '>'
502
- else
503
- html << '/>'
504
- end
505
- html << "\n" if @crafter
506
- return html
507
- end #to_html
470
+ def to_html(options = {})
471
+ o = set_option_defaults(options)
472
+ tag = htmltag()
473
+ if ! tag
474
+ o[:log].error("No HTML element available (#{self.inspect})") if o[:log].error?
475
+ return ''
476
+ elsif tag == ''
477
+ tag = 'span'
478
+ o[:log].error("Missing output routine for HTML (#{self.inspect})") if o[:log].error?
479
+ end
480
+ #Test if the HTML-Tag should contain something, but there is nothing.
481
+ #If :empty_ok it is ok, that there is no content (e.g <td>)
482
+ #May make problems, if an empty tag is used to set a id-mark.
483
+ if content?() and content? != :empty_ok and
484
+ ( ! @content or @content == [] or @content == [nil] )
485
+ o[:log].warn("HTML-Tag #{tag} without content -> ignored #{self.inspect}") if o[:log].warn?
486
+ return ''
487
+ end
488
+ html = String.new()
489
+ html << "\n" if @crbefore
490
+ html << "<#{tag} "
491
+ @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
492
+ html << "#{k} = \"#{v}\" " if v.to_s != '' and v.html?
493
+ }
494
+ if @content
495
+ html << ">"
496
+ html <<"\n" if @crmid
497
+ html << "#{@content.to_html(options)}"
498
+ html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
499
+ html << "</#{tag}>"
500
+ elsif content?() == nil
501
+ html << '>'
502
+ else
503
+ html << '/>'
504
+ end
505
+ html << "\n" if @crafter
506
+ return html
507
+ end #to_html
508
508
  =begin rdoc
509
509
  Return content in Wikimedia-Syntax.
510
510
  Support stopped.
511
511
  =end
512
- def to_wiki(options = {})
513
- o = set_option_defaults(options)
514
- o[:log].error("Missing output routine for Wiki (#{self.inspect})") if o[:log].error?
515
- return "#{@content.to_wiki(options)}\n"
516
- end
512
+ def to_wiki(options = {})
513
+ o = set_option_defaults(options)
514
+ o[:log].error("Missing output routine for Wiki (#{self.inspect})") if o[:log].error?
515
+ return "#{@content.to_wiki(options)}\n"
516
+ end
517
517
  =begin rdoc
518
518
  Return content in creole-Syntax.
519
519
  =end
520
- def to_creole(options = {})
521
- o = set_option_defaults(options)
522
- o[:log].error("Missing output routine for creole (#{self.inspect})") if o[:log].error?
523
- return "#{@content.to_creole(options)}\n"
524
- end
520
+ def to_creole(options = {})
521
+ o = set_option_defaults(options)
522
+ o[:log].error("Missing output routine for creole (#{self.inspect})") if o[:log].error?
523
+ return "#{@content.to_creole(options)}\n"
524
+ end
525
525
  =begin rdoc
526
526
  Make an Text-Representation of the content.
527
527
  =end
528
- def to_text(options = {})
529
- o = set_option_defaults(options)
530
- o[:log].error("Missing output routine for Text (#{self.inspect})") if o[:log].error?
531
- text = String.new()
532
- text << "\n" if @crbefore
533
- text = "#{@content.to_text(options)}".strip
534
- text << "\n" if @crafter
535
- return text
536
- end
537
- def to_s()
538
- return self.inspect
539
- end
540
- end #Element
528
+ def to_text(options = {})
529
+ o = set_option_defaults(options)
530
+ o[:log].error("Missing output routine for Text (#{self.inspect})") if o[:log].error?
531
+ text = String.new()
532
+ text << "\n" if @crbefore
533
+ text = "#{@content.to_text(options)}".strip
534
+ text << "\n" if @crafter
535
+ return text
536
+ end
537
+ def to_s()
538
+ return self.inspect
539
+ end
540
+ end #Element
541
541
  end #module Docgenerator
542
542
 
543
543
  =begin rdoc