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/build_test_and_doc.rb
DELETED
@@ -1,505 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
=begin
|
3
|
-
Generates new versions for test.
|
4
|
-
|
5
|
-
Generates:
|
6
|
-
*unittest_docgenerator_characters.rb based on
|
7
|
-
* test for each element
|
8
|
-
=end
|
9
|
-
|
10
|
-
#~ Dir['lib/**/wiki*/*'].each{|file| puts "require '#{file}'".sub(/lib\//,'') }
|
11
|
-
#~ exit
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
$:.unshift('lib')
|
15
|
-
require 'docgenerator'
|
16
|
-
Docgenerator::DOCGENERATOR_LOGGER.level = Log4r::WARN
|
17
|
-
#~ require 'docgenerator/compatibility_v1'
|
18
|
-
require 'docgenerator/packages/attachfile.rb'
|
19
|
-
require 'docgenerator/packages/caption.rb'
|
20
|
-
require 'docgenerator/packages/hyperref.rb'
|
21
|
-
require 'docgenerator/packages/listings.rb'
|
22
|
-
require 'docgenerator/packages/pdfpages.rb'
|
23
|
-
require 'docgenerator/packages/rubycode4doc.rb'
|
24
|
-
require 'docgenerator/packages/scrlettr2.rb'
|
25
|
-
require 'docgenerator/packages/scrpage2.rb'
|
26
|
-
require 'docgenerator/packages/struktex.rb'
|
27
|
-
require 'docgenerator/packages/todonotes.rb'
|
28
|
-
require 'docgenerator/packages/url.rb'
|
29
|
-
|
30
|
-
require 'creole/creole2doc.rb'
|
31
|
-
require 'creole/plugins/rail.rb'
|
32
|
-
require 'creole/plugins/rubycode4creole.rb'
|
33
|
-
require 'creole/plugins/struktex.rb'
|
34
|
-
require 'creole/plugins/todonotes.rb'
|
35
|
-
|
36
|
-
require 'wiki2doc/wiki2docgenerator.rb'
|
37
|
-
require 'wiki2doc/plugins/rubycode4wiki.rb'
|
38
|
-
require 'wiki2doc/plugins/struktex.rb'
|
39
|
-
|
40
|
-
|
41
|
-
=begin rdoc
|
42
|
-
List all known elements
|
43
|
-
=end
|
44
|
-
def puts_elements
|
45
|
-
ObjectSpace.each_object(Class).map{|o|
|
46
|
-
o.name || ''
|
47
|
-
}.sort.each{|o|
|
48
|
-
puts o if o =~ /^Docgenerator/
|
49
|
-
#~ puts o if o.is_a?(Docgenerator::Element)
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
=begin rdoc
|
56
|
-
Define a new outputter to catch data into an array
|
57
|
-
=end
|
58
|
-
class ArrayOutputter < Log4r::StdoutOutputter
|
59
|
-
=begin rdoc
|
60
|
-
Collect messages in array.
|
61
|
-
=end
|
62
|
-
def write(message)
|
63
|
-
@messages ||= [] #create with first call
|
64
|
-
@messages << message
|
65
|
-
end
|
66
|
-
=begin rdoc
|
67
|
-
Clear message array and return messages
|
68
|
-
=end
|
69
|
-
def flush
|
70
|
-
@messages ||= [] #create with first call
|
71
|
-
messages = @messages.dup
|
72
|
-
@messages.clear
|
73
|
-
messages
|
74
|
-
end
|
75
|
-
end #ArrayOutputter
|
76
|
-
|
77
|
-
TESTHEAD = <<testhead
|
78
|
-
#encoding: utf-8
|
79
|
-
|
80
|
-
=begin rdoc
|
81
|
-
Test generated by #{__FILE__} #{Date.today}
|
82
|
-
=end
|
83
|
-
|
84
|
-
gem 'test-unit'
|
85
|
-
require 'test/unit'
|
86
|
-
|
87
|
-
if $0 == __FILE__
|
88
|
-
$:.unshift("../lib")
|
89
|
-
end
|
90
|
-
require 'docgenerator'
|
91
|
-
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
92
|
-
|
93
|
-
=begin rdoc
|
94
|
-
Define a new outputter to catch data into an array
|
95
|
-
=end
|
96
|
-
class ArrayOutputter < Log4r::StdoutOutputter
|
97
|
-
=begin rdoc
|
98
|
-
Collect messages in array.
|
99
|
-
=end
|
100
|
-
def write(message)
|
101
|
-
@messages ||= [] #create with first call
|
102
|
-
@messages << message
|
103
|
-
end
|
104
|
-
=begin rdoc
|
105
|
-
Clear message array and return messages
|
106
|
-
=end
|
107
|
-
def flush
|
108
|
-
@messages ||= [] #create with first call
|
109
|
-
messages = @messages.dup
|
110
|
-
@messages.clear
|
111
|
-
messages
|
112
|
-
end
|
113
|
-
end #ArrayOutputter
|
114
|
-
|
115
|
-
testhead
|
116
|
-
|
117
|
-
def mk_character_test(filename = "unittest/unittest_docgenerator_characters_#{Date.today}.xx")
|
118
|
-
File.open(filename, 'w:utf-8'){|f_test|
|
119
|
-
puts "Create #{f_test.path}"
|
120
|
-
f_test << TESTHEAD
|
121
|
-
f_test << <<code
|
122
|
-
include Docgenerator
|
123
|
-
class Test_characters < Test::Unit::TestCase
|
124
|
-
def self.startup()
|
125
|
-
#DEBUG would contain messages
|
126
|
-
@@log = Log4r::Logger.new('Test_characters', Log4r::INFO)
|
127
|
-
@@log.outputters = @@logoutputter = ArrayOutputter.new('xx')
|
128
|
-
end #self.startup()
|
129
|
-
|
130
|
-
code
|
131
|
-
|
132
|
-
#Some Coding to prepare the unit tests
|
133
|
-
els = nil
|
134
|
-
lclass = nil
|
135
|
-
File.open('../lib/docgenerator/characters.rb', 'r:utf-8').each_line{|line|#
|
136
|
-
case line
|
137
|
-
when /\A\s*#/ #skip
|
138
|
-
when /class\s*(\w+)\s/
|
139
|
-
lclass = $1
|
140
|
-
els = [ $1.downcase.to_sym ]
|
141
|
-
when /add_id\s*(\w+)/
|
142
|
-
els << $1
|
143
|
-
when /add_(html|latex|wiki|creole|text)_output\s*'(.+?)'/
|
144
|
-
target = $1
|
145
|
-
result = $2.sub(/'/, "''")
|
146
|
-
f_test << "\n def test_character_#{lclass}_#{target}()\n"
|
147
|
-
els.each{|el|
|
148
|
-
if result.sub!(/\#\{@content\}/, '1')
|
149
|
-
f_test << " assert_equal( '#{result}', element(#{el.inspect}, {}, 1).to_#{target}( :log => @@log))\n"
|
150
|
-
else
|
151
|
-
f_test << " assert_equal( '#{result}', element(#{el.inspect}).to_#{target}( :log => @@log))\n"
|
152
|
-
end
|
153
|
-
f_test << " assert_equal( [], @@logoutputter.flush)\n"
|
154
|
-
}
|
155
|
-
f_test << " end #test_character_#{lclass}_#{target}\n"
|
156
|
-
end
|
157
|
-
}
|
158
|
-
|
159
|
-
f_test << <<code
|
160
|
-
end #class Test_characters
|
161
|
-
code
|
162
|
-
}
|
163
|
-
end #mk_character_test()
|
164
|
-
|
165
|
-
class Docgenerator::Element
|
166
|
-
def self.each()
|
167
|
-
@@ids.values.uniq.each{|cl| yield cl }
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def mk_element_test(pattern)
|
172
|
-
|
173
|
-
testcode= []
|
174
|
-
Docgenerator::Element.each{|cl|
|
175
|
-
next unless cl.name =~ pattern
|
176
|
-
#exclude dummy element.
|
177
|
-
next if %w{Docgenerator::Sectioning::DummySectioning}.include?(cl.name.to_s)
|
178
|
-
p cl.name
|
179
|
-
|
180
|
-
testclass = "Test_element_#{cl.name.downcase.gsub(/::/, '_')}"
|
181
|
-
@@log = Log4r::Logger.new(cl.element_ids.first.to_s, Log4r::DEBUG)
|
182
|
-
@@log.outputters = @@logoutputter = ArrayOutputter.new('xx')
|
183
|
-
@@el = cl.new(:log => @@log )
|
184
|
-
testcode << <<code
|
185
|
-
=begin rdoc
|
186
|
-
Test #{cl.name}.
|
187
|
-
=end
|
188
|
-
class #{testclass} < Test::Unit::TestCase
|
189
|
-
def self.startup()
|
190
|
-
@@log = Log4r::Logger.new('#{cl.element_ids.first.to_s}', Log4r::DEBUG)
|
191
|
-
@@log.outputters = @@logoutputter = ArrayOutputter.new('xx')
|
192
|
-
@@el = #{cl.name}.new(:log => @@log)
|
193
|
-
|
194
|
-
#fill attributes
|
195
|
-
code
|
196
|
-
@@el.attr.each{|k,a|
|
197
|
-
if a.required?
|
198
|
-
#this may give an error, if the attribute has wrong type/layout...
|
199
|
-
@@el[k] << "Attr_#{k}"
|
200
|
-
testcode << " @@el[#{k.inspect}] << 'Attr_#{k}'"
|
201
|
-
else #only as template
|
202
|
-
testcode << " \#@@el[#{k.inspect}] << 'Attr_#{k}'"
|
203
|
-
end
|
204
|
-
}
|
205
|
-
|
206
|
-
if @@el.content?
|
207
|
-
@@el << 'content'
|
208
|
-
testcode<< " #fill content"
|
209
|
-
testcode<< " @@el << 'content'"
|
210
|
-
else
|
211
|
-
testcode<< " #element allows no content"
|
212
|
-
end
|
213
|
-
|
214
|
-
testcode<< " #Store log messages"
|
215
|
-
testcode<< " @@messages = @@logoutputter.flush"
|
216
|
-
#test log-content
|
217
|
-
@@messages = @@log.outputters.first.flush
|
218
|
-
testname = "test_element_#{cl.name.downcase.gsub(/::/, '_')}_log"
|
219
|
-
|
220
|
-
testcode<< <<code
|
221
|
-
end #self.startup()
|
222
|
-
=begin rdoc
|
223
|
-
Check messages from logger.
|
224
|
-
This may include warnings for wrong content format...
|
225
|
-
|
226
|
-
The following messages are expected:
|
227
|
-
#{@@messages.to_yaml}
|
228
|
-
=end
|
229
|
-
def #{testname}
|
230
|
-
assert_equal(
|
231
|
-
#{@@messages.inspect},
|
232
|
-
@@messages
|
233
|
-
)
|
234
|
-
end ##{testname}
|
235
|
-
code
|
236
|
-
%w{latex html context text wiki creole}.each{|target|
|
237
|
-
testname = "test_element_#{cl.name.downcase.gsub(/::/, '_')}_#{target}"
|
238
|
-
result = @@el.send("to_#{target}".to_sym, :log => @@log)
|
239
|
-
|
240
|
-
testcode<< <<code
|
241
|
-
=begin
|
242
|
-
Test #{cl.name}#to_#{target}.
|
243
|
-
=end
|
244
|
-
def #{testname}()
|
245
|
-
assert_equal(
|
246
|
-
code
|
247
|
-
#Problem:
|
248
|
-
if result.count("\n") < 2 #einzeilig
|
249
|
-
#\u (\url...) wird als Unicode-eingabe interpretiert. Desahlb muss \ maskiert werden.
|
250
|
-
testcode<< " #{result.inspect.gsub(/\\/, '\\\\')},"
|
251
|
-
else #mehrzeilig
|
252
|
-
=begin
|
253
|
-
Problem: %{inhalt} macht Probleme bei Strings mit { und }
|
254
|
-
<<<xx fügt leerzeichen ein, komma für nächste Parameter geht auch nicht.
|
255
|
-
=end
|
256
|
-
testcode<< " %Q{#{result.gsub(/\\/, '\\\\\\\\')}}," #mehrzeilig
|
257
|
-
#~ testcode<< "#~ <<result"
|
258
|
-
#~ testcode<< @@el.send("to_#{target}".to_sym).gsub(/\\/, '\\\\\\\\').gsub(/^/, '#~ ')
|
259
|
-
#~ testcode<< "#~ result"
|
260
|
-
end
|
261
|
-
testcode<< " @@el.to_#{target}( :log => @@log).encode('utf-8')"
|
262
|
-
testcode<< " )"
|
263
|
-
messages = @@logoutputter.flush
|
264
|
-
testcode<< <<code
|
265
|
-
=begin
|
266
|
-
Check messages from #{cl.name}#to_#{target}. Expected:
|
267
|
-
#{messages.to_yaml}
|
268
|
-
=end
|
269
|
-
assert_equal(
|
270
|
-
#{messages.inspect},
|
271
|
-
@@logoutputter.flush
|
272
|
-
)
|
273
|
-
code
|
274
|
-
testcode<< " end ##{testname}"
|
275
|
-
}
|
276
|
-
testcode<< "end ##{testclass}"
|
277
|
-
|
278
|
-
}
|
279
|
-
|
280
|
-
File.open("unittest/x_unittest_docgenerator_elements_#{Date.today}.rb", 'w:utf-8'){|f_test|
|
281
|
-
puts "Create #{f_test.path}"
|
282
|
-
f_test << TESTHEAD
|
283
|
-
f_test << testcode.join("\n")
|
284
|
-
}
|
285
|
-
|
286
|
-
#~ puts testcode.join("\n")
|
287
|
-
end #mk_element_test
|
288
|
-
|
289
|
-
=begin rdoc
|
290
|
-
Prepare a documentation, based on execution and meta-analyse.
|
291
|
-
=end
|
292
|
-
def mk_element_doc(pattern, filename = "manpage_element.rb")
|
293
|
-
|
294
|
-
rd_code= [<<xx
|
295
|
-
=begin rdoc
|
296
|
-
Generated manpages for elements.
|
297
|
-
=end
|
298
|
-
|
299
|
-
module Doc
|
300
|
-
|
301
|
-
module Docgenerator
|
302
|
-
module Characters; end
|
303
|
-
module Creole; end
|
304
|
-
module Elements; end
|
305
|
-
module Environments; end
|
306
|
-
module Letter; end
|
307
|
-
module Listings; end
|
308
|
-
module Lists; end
|
309
|
-
module Sectioning; end
|
310
|
-
module Tables; end
|
311
|
-
module Wikimedia; end
|
312
|
-
end
|
313
|
-
|
314
|
-
module Struktex; end
|
315
|
-
|
316
|
-
xx
|
317
|
-
]
|
318
|
-
log = Log4r::Logger.new('log', Log4r::WARN) #avoid message
|
319
|
-
log.outputters = logoutputter = ArrayOutputter.new('xx')
|
320
|
-
|
321
|
-
Docgenerator::Element.each{|cl|
|
322
|
-
next unless cl.name =~ pattern
|
323
|
-
|
324
|
-
#exclude dummy element.
|
325
|
-
next if %w{Docgenerator::Sectioning::DummySectioning}.include?(cl.name.to_s)
|
326
|
-
p cl.name
|
327
|
-
|
328
|
-
el = cl.new(:log => log )
|
329
|
-
rd_code << <<code
|
330
|
-
=begin rdoc
|
331
|
-
=#{cl.name}
|
332
|
-
See also ::#{cl.name}
|
333
|
-
|
334
|
-
code
|
335
|
-
if ! el.attr.empty?
|
336
|
-
tab = element(:tabular, columns: 10).Cr
|
337
|
-
tab << row = element(:row ).cr
|
338
|
-
row << element(:th, {}, 'Name')
|
339
|
-
row << element(:th, {}, 'required?')
|
340
|
-
row << element(:th, {}, 'HTML')
|
341
|
-
row << element(:th, {}, 'LaTeX')
|
342
|
-
row << element(:th, {}, '~keyval')
|
343
|
-
row << element(:th, {}, 'ConTeXt')
|
344
|
-
row << element(:th, {}, 'Text')
|
345
|
-
row << element(:th, {}, 'Wiki')
|
346
|
-
row << element(:th, {}, 'Creole')
|
347
|
-
row << element(:th, {}, 'Values')
|
348
|
-
|
349
|
-
el.attr.each{|k,a|
|
350
|
-
##fixme element(:radic) statt 'X'?
|
351
|
-
tab << row = element(:row).cr
|
352
|
-
row << element(:col, {}, k.inspect)
|
353
|
-
row << element(:col, {}, a.required? ? 'X' : '-' )
|
354
|
-
row << element(:col, {}, a.html? ? 'X' : '-' )
|
355
|
-
row << element(:col, {}, a.latex? ? 'X' : '-' )
|
356
|
-
row << element(:col, {}, a.texkeyval? ? 'X' : '-' )
|
357
|
-
row << element(:col, {}, a.context? ? 'X' : '-' )
|
358
|
-
row << element(:col, {}, a.text? ? 'X' : '-' )
|
359
|
-
row << element(:col, {}, a.wiki? ? 'X' : '-' )
|
360
|
-
row << element(:col, {}, a.creole? ? 'X' : '-' )
|
361
|
-
#~ rd_code << "===Attribute #{k.inspect}"
|
362
|
-
if a.required?
|
363
|
-
#this may give an error, if the attribute has wrong type/layout...
|
364
|
-
el[k] << "Value for #{k}"
|
365
|
-
#~ rd_code << "* required"
|
366
|
-
#~ else
|
367
|
-
#~ rd_code << "* optional"
|
368
|
-
end
|
369
|
-
#~ rd_code << "* used for:"
|
370
|
-
#~ rd_code << " * HTML" if a.html?()
|
371
|
-
#~ rd_code << " * LaTeX" if a.latex?()
|
372
|
-
#~ rd_code << " * LaTeX as key-val parameter" if a.texkeyval?()
|
373
|
-
#~ rd_code << " * ConTeXt" if a.context?()
|
374
|
-
#~ rd_code << " * text" if a.text?()
|
375
|
-
#~ rd_code << " * wiki (wikimedia)" if a.wiki?()
|
376
|
-
#~ rd_code << " * wiki (creole)" if a.creole?()
|
377
|
-
|
378
|
-
row << col = element(:col)
|
379
|
-
if a.allowed_values
|
380
|
-
col << ul = element(:ul)
|
381
|
-
#~ rd_code << "* Allowed values:"
|
382
|
-
a.allowed_values.each{|x|
|
383
|
-
ul << element(:li,{}, x.inspect)
|
384
|
-
#~ rd_code << " * #{x.inspect}"
|
385
|
-
}
|
386
|
-
end
|
387
|
-
}
|
388
|
-
|
389
|
-
rd_code<< "==Attributes"
|
390
|
-
rd_code<< tab.to_html(:log=> log)
|
391
|
-
end
|
392
|
-
|
393
|
-
#~ rd_code<< "==Content"
|
394
|
-
if el.content?
|
395
|
-
el << 'content'
|
396
|
-
rd_code<< "The element can contain content"
|
397
|
-
else
|
398
|
-
rd_code<< "The element allows no content"
|
399
|
-
end
|
400
|
-
|
401
|
-
rd_code<< "\n==Generate an object"
|
402
|
-
cmd = " test = #{el.class}.new( "
|
403
|
-
el.attr.each{|k,a|
|
404
|
-
cmd << "\n #{k.inspect} => #{a.content.inspect}," unless a.content.empty?
|
405
|
-
}
|
406
|
-
cmd.sub!(/,\Z/, "\n") #delete last , from attributes if available.
|
407
|
-
cmd << " )"
|
408
|
-
cmd << "\n test << #{el.content.inspect}" if el.content?
|
409
|
-
|
410
|
-
cmd << "\n\nAlternative generation\n"
|
411
|
-
el.element_ids.each{|id|
|
412
|
-
cmd << " test = element(#{id.inspect}#{ ' , { ...Attributes... }' unless el.attr.empty?})\n"
|
413
|
-
}
|
414
|
-
rd_code << cmd
|
415
|
-
|
416
|
-
|
417
|
-
rd_code<< "\n==Outputs"
|
418
|
-
|
419
|
-
%w{latex html context text wiki creole}.each{|target|
|
420
|
-
|
421
|
-
el2 = el.dup #later check with cr, cR... would modify the result
|
422
|
-
|
423
|
-
logoutputter.flush #clear messages
|
424
|
-
result = el.send("to_#{target}".to_sym, :log => log)
|
425
|
-
rd_code<< <<code
|
426
|
-
===test.to_#{target}
|
427
|
-
#{result.gsub(/^/, " ")}
|
428
|
-
code
|
429
|
-
logoutputter.flush.each{|message|
|
430
|
-
case message
|
431
|
-
when /(Missing output routine for .*)\(/
|
432
|
-
rd_code << "* #{$1}"
|
433
|
-
when /No related document for tableofcontents/
|
434
|
-
when %r{ERROR log: :li/wiki: Unknown list type nil}
|
435
|
-
else
|
436
|
-
p "Uncatched message: #{message}"
|
437
|
-
end
|
438
|
-
}#logoutputter.flush
|
439
|
-
|
440
|
-
cr_first = true
|
441
|
-
#try different cr-commands
|
442
|
-
[ :cr, :cR, :Cr, :CR ].each{| cr |
|
443
|
-
el2.send(cr)
|
444
|
-
result2 = el2.send("to_#{target}".to_sym, :log => log)
|
445
|
-
|
446
|
-
if result != result2
|
447
|
-
if cr_first #first difference -> print start information
|
448
|
-
rd_code << <<code
|
449
|
-
====:cr, :cR, :Cr, :CR
|
450
|
-
With Element#cr, Element#cR, Element#Cr, Element#CR you may influence
|
451
|
-
the code layout.
|
452
|
-
[[START]]/[[END]] are not part of the output, but needed to illustrate the
|
453
|
-
line breaks.
|
454
|
-
|
455
|
-
Default:
|
456
|
-
#{"[[START]]#{result}[[END]]".gsub(/^/, " ")}
|
457
|
-
code
|
458
|
-
cr_first = false
|
459
|
-
end #cr_first
|
460
|
-
rd_code << <<code
|
461
|
-
Result after Element##{cr}:
|
462
|
-
#{"[[START]]#{result2}[[END]]".gsub(/^/, " ")}
|
463
|
-
code
|
464
|
-
end
|
465
|
-
} #different cr-commands
|
466
|
-
} #targets
|
467
|
-
rd_code << <<code
|
468
|
-
=end
|
469
|
-
class #{cl.name}
|
470
|
-
end ##{cl.name}
|
471
|
-
code
|
472
|
-
} #Element.each
|
473
|
-
|
474
|
-
rd_code << "end"
|
475
|
-
|
476
|
-
puts rd_code.join("\n").encoding
|
477
|
-
puts rd_code.join("\n").valid_encoding?
|
478
|
-
|
479
|
-
File.open(filename, 'w:cp1252'){|f_test|
|
480
|
-
puts "Create #{f_test.path}"
|
481
|
-
f_test << rd_code.join("\n")
|
482
|
-
}
|
483
|
-
|
484
|
-
end #mk_element_doc(pattern)
|
485
|
-
|
486
|
-
#~ mk_character_test( )
|
487
|
-
#~ mk_character_test( "unittest_docgenerator_characters.rb" )
|
488
|
-
|
489
|
-
#~ mk_element_test(/./i)
|
490
|
-
#~ mk_element_test(/\A(?:.(?<!Characters))*\Z/i) #ohne characters
|
491
|
-
#~ mk_element_test(/include/i)
|
492
|
-
#~ mk_element_test(/img/i)
|
493
|
-
#~ mk_element_test(/Section/i)
|
494
|
-
|
495
|
-
#~ mk_element_doc(/img/i, 'manpage_extract.rb')
|
496
|
-
mk_element_doc(/sectioning/i, 'manpage_extract.rb')
|
497
|
-
#~ mk_element_doc(/elements/i, 'manpage_extract.rb')
|
498
|
-
#~ mk_element_doc(/tables/i, 'manpage_extract.rb')
|
499
|
-
#~ mk_element_doc(/envi/i, 'manpage_extract.rb')
|
500
|
-
#~ mk_element_doc(/list/i, 'manpage_extract.rb')
|
501
|
-
#~ mk_element_doc(/style|foot/i, 'manpage_extract.rb')
|
502
|
-
#~ mk_element_doc(/\A(?:.(?<!Characters))*\Z/i) #ohne characters
|
503
|
-
#~ mk_element_doc(/./i)
|
504
|
-
|
505
|
-
#~ puts_elements
|