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
data/lib/docgenerator/element.rb
CHANGED
@@ -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
|
-
|
19
|
+
class Element
|
20
|
+
include Docgenerator #get VERSION
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
@
|
80
|
-
@attr[k] = Attribute.create().new( k, self )
|
50
|
+
@content = nil
|
81
51
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
-
|
173
|
-
|
174
|
-
|
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
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
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("
|
194
|
-
end
|
195
|
-
|
196
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
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
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
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
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
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
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
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
|
-
|
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
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
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
|
-
|
298
|
-
|
299
|
-
|
297
|
+
def content?()
|
298
|
+
return true
|
299
|
+
end
|
300
300
|
=begin rdoc
|
301
301
|
check if there is content assigned.
|
302
302
|
=end
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
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
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
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
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
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
|
-
|
338
|
-
|
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
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
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
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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
|
-
|
403
|
-
|
404
|
-
|
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
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
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
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
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
|
-
|
460
|
-
|
461
|
-
|
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
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
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
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
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
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
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
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
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
|