docgenerator 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/build_test_and_doc.rb +505 -0
- data/examples/creole_example.rb +82 -0
- data/examples/creole_example_footnote.rb +67 -0
- data/examples/creole_example_placeholder.rb +77 -0
- data/examples/creole_example_rail.rb +154 -0
- data/examples/creole_example_rubycode.rb +144 -0
- data/examples/creole_example_struktex.rb +169 -0
- data/examples/docgenerator_example.rb +1 -1
- data/examples/docgenerator_example_footnote.rb +1 -0
- data/examples/docgenerator_example_list.rb +3 -0
- data/examples/docgenerator_example_restrictions.rb +1 -1
- data/examples/docgenerator_example_tabular.rb +1 -1
- data/examples/docgenerator_example_tripfalls.rb +2 -2
- data/examples/results/readme +2 -1
- data/examples/wiki2docgenerator_example.rb +61 -32
- data/lib/creole/creole2doc.rb +57 -58
- data/lib/creole/creole_characters.rb +56 -0
- data/lib/creole/creole_inclusion_and_plugins.rb +59 -284
- data/lib/creole/creole_inclusions.rb +142 -0
- data/lib/creole/creole_placeholder.rb +57 -23
- data/lib/creole/creole_plugins.rb +198 -0
- data/lib/creole/creole_tabular.rb +16 -8
- data/lib/creole/plugins/rail.rb +182 -0
- data/lib/creole/plugins/rubycode4creole.rb +136 -0
- data/lib/creole/plugins/struktex.rb +59 -0
- data/lib/creole/plugins/todonotes.rb +70 -0
- data/lib/docgenerator.rb +161 -71
- data/lib/docgenerator/attribute.rb +189 -156
- data/lib/docgenerator/characters.rb +824 -267
- data/lib/docgenerator/compatibility_v1.rb +249 -0
- data/lib/docgenerator/css.rb +53 -32
- data/lib/docgenerator/document.rb +119 -56
- data/lib/docgenerator/element.rb +304 -351
- data/lib/docgenerator/element_meta.rb +303 -0
- data/lib/docgenerator/elements.rb +1112 -481
- data/lib/docgenerator/environments.rb +153 -62
- data/lib/docgenerator/footnote.rb +30 -9
- data/lib/docgenerator/lists.rb +71 -47
- data/lib/docgenerator/packages/attachfile.rb +136 -0
- data/lib/{packages/docgenerator_caption.rb → docgenerator/packages/caption.rb} +28 -19
- data/lib/docgenerator/packages/hyperref.rb +194 -0
- data/lib/docgenerator/packages/listings.rb +179 -0
- data/lib/docgenerator/packages/pdfpages.rb +43 -0
- data/lib/docgenerator/packages/rubycode4doc.rb +227 -0
- data/lib/{packages/docgenerator_scrlettr2.rb → docgenerator/packages/scrlettr2.rb} +25 -16
- data/lib/docgenerator/packages/scrpage2.rb +410 -0
- data/lib/docgenerator/packages/struktex.rb +447 -0
- data/lib/docgenerator/packages/todonotes.rb +85 -0
- data/lib/{packages/docgenerator_url.rb → docgenerator/packages/url.rb} +7 -6
- data/lib/docgenerator/sections.rb +257 -83
- data/lib/docgenerator/standard.rb +19 -11
- data/lib/docgenerator/tabular.rb +234 -118
- data/lib/{templates → docgenerator/templates}/docgenerator_template.rb +52 -44
- data/lib/{templates → docgenerator/templates}/docgenerator_template.yaml +0 -0
- data/lib/{templates → docgenerator/templates}/docgenerator_template_css.rb +22 -16
- data/lib/wiki2doc/plugins/rubycode4wiki.rb +53 -0
- data/lib/wiki2doc/plugins/struktex.rb +12 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +39 -38
- data/lib/wiki2doc/wikimedia_document.rb +24 -0
- data/manpage_elements.rb +10411 -0
- data/readme.rd +34 -24
- data/unittest/creole_testtext.creole +11 -0
- data/unittest/expected/test_document_usepackage_undefined.log +2 -2
- data/unittest/expected/test_runtex.stdout +0 -1
- data/unittest/expected/test_runtex_2.stdout +0 -1
- data/unittest/expected/toc_css.css +3 -2
- data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
- data/unittest/expected_creole/test_creole_characters_all.html +15 -15
- data/unittest/expected_creole/test_creole_characters_all.latex +15 -15
- data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
- data/unittest/expected_creole/test_creole_links_file.html +2 -2
- data/unittest/expected_creole/test_creole_links_file.latex +2 -2
- data/unittest/expected_creole/test_creole_links_file.text +2 -2
- data/unittest/expected_creole/test_creole_picture_link.html +1 -1
- data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
- data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
- data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
- data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
- data/unittest/expected_rubycode4doc/creole_output.html +2 -0
- data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
- data/unittest/expected_rubycode4doc/wiki_1.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_2.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_3.html +9 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_1.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_2.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_3.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_full.html +21 -0
- data/unittest/expected_struktex/test_struktex_krug.creole +15 -0
- data/unittest/expected_struktex/test_struktex_krug.tex +19 -0
- data/unittest/expected_struktex/test_struktex_krug.wiki +15 -0
- data/unittest/expected_struktex/test_struktex_statement.creole +7 -0
- data/unittest/expected_struktex/test_struktex_statement.tex +9 -0
- data/unittest/expected_struktex/test_struktex_statement.wiki +7 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.html +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.latex +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.text +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.wiki +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_2.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_groupid.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_label.html +0 -0
- data/unittest/expected_wikimedia/test_wiki_link.html +8 -0
- data/unittest/expected_wikimedia/test_wiki_link.latex +17 -0
- data/unittest/expected_wikimedia/test_wiki_link.wiki +11 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.wiki +0 -0
- data/unittest/expected_wikimedia/test_wiki_picture.html +55 -0
- data/unittest/expected_wikimedia/test_wiki_picture.latex +76 -0
- data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +5 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.wiki +0 -0
- data/unittest/{unittest_creole2doc.rb → unittest_creole.rb} +385 -476
- data/unittest/unittest_creole_placeholders.rb +272 -0
- data/unittest/unittest_creole_plugin_rail.rb +147 -0
- data/unittest/unittest_docgenerator.rb +206 -332
- data/unittest/unittest_docgenerator_characters.rb +650 -0
- data/unittest/unittest_docgenerator_runtex.rb +48 -20
- data/unittest/unittest_packages_struktex.rb +187 -0
- data/unittest/unittest_rubycode4doc.rb +275 -0
- data/unittest/unittest_wikimedia.rb +479 -0
- metadata +245 -172
- data/examples/results_expected/docgenerator_example.html +0 -39
- data/examples/results_expected/docgenerator_example.pdf +0 -0
- data/examples/results_expected/docgenerator_example.tex +0 -56
- data/examples/results_expected/docgenerator_example_footnote.html +0 -40
- data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
- data/examples/results_expected/docgenerator_example_footnote.tex +0 -50
- data/examples/results_expected/docgenerator_example_list.html +0 -18
- data/examples/results_expected/docgenerator_example_list.pdf +0 -0
- data/examples/results_expected/docgenerator_example_list.tex +0 -46
- data/examples/results_expected/docgenerator_example_restrictions.html +0 -22
- data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
- data/examples/results_expected/docgenerator_example_restrictions.tex +0 -31
- data/examples/results_expected/docgenerator_example_tabular.html +0 -37
- data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tabular.tex +0 -41
- data/examples/results_expected/docgenerator_example_tripfalls.html +0 -27
- data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tripfalls.tex +0 -31
- data/lib/packages/docgenerator_attachfile.rb +0 -71
- data/lib/packages/docgenerator_hyperref.rb +0 -109
- data/lib/packages/docgenerator_listings.rb +0 -103
- data/lib/packages/docgenerator_pdfpages.rb +0 -24
- data/lib/packages/docgenerator_scrpage2.rb +0 -172
- data/self_docgenerator.rb +0 -163
- data/unittest/expected_wiki/test_wiki_link.html +0 -8
- data/unittest/expected_wiki/test_wiki_link.latex +0 -17
- data/unittest/expected_wiki/test_wiki_link.wiki +0 -11
- data/unittest/expected_wiki/test_wiki_picture.html +0 -55
- data/unittest/expected_wiki/test_wiki_picture.latex +0 -76
- data/unittest/expected_wiki/test_wiki_picture_thumb.html +0 -5
- data/unittest/test_rakefile_docgenerator.rb +0 -43
- data/unittest/unittest_versions.rb +0 -44
- data/unittest/unittest_wiki2doc.rb +0 -464
@@ -6,27 +6,64 @@ if $0 == __FILE__
|
|
6
6
|
$:.unshift("../lib")
|
7
7
|
end
|
8
8
|
require 'docgenerator'
|
9
|
+
include Docgenerator
|
10
|
+
|
9
11
|
require 'rake4latex'
|
10
12
|
|
11
|
-
|
13
|
+
=begin rdoc
|
14
|
+
Define a new outputter to catch data into an array
|
15
|
+
=end
|
16
|
+
class ArrayOutputter < Log4r::StdoutOutputter
|
17
|
+
=begin rdoc
|
18
|
+
Collect messages in array.
|
19
|
+
=end
|
20
|
+
def write(message)
|
21
|
+
@messages ||= [] #create with first call
|
22
|
+
@messages << message
|
23
|
+
end
|
24
|
+
=begin rdoc
|
25
|
+
Clear message array and return messages
|
26
|
+
=end
|
27
|
+
def flush
|
28
|
+
@messages ||= [] #create with first call
|
29
|
+
messages = @messages.dup
|
30
|
+
@messages.clear
|
31
|
+
messages
|
32
|
+
end
|
33
|
+
end #ArrayOutputter
|
12
34
|
|
13
35
|
|
14
36
|
class Test_document_runtex < Test::Unit::TestCase
|
15
|
-
def
|
37
|
+
def clean_examples()
|
38
|
+
%w{test_runtex test_runtex_2}.each{|filename|
|
39
|
+
%w{tex pdf aux log out}.each{|ext|
|
40
|
+
File.delete(filename.ext(ext)) if File.exist?(filename.ext(ext))
|
41
|
+
}
|
42
|
+
}
|
43
|
+
end #clean_examples()
|
44
|
+
def setup()
|
45
|
+
clean_examples
|
46
|
+
|
47
|
+
@log = Log4r::Logger.new('Doc', Log4r::WARN )
|
48
|
+
@log.outputters = ArrayOutputter.new('log_xxx')
|
49
|
+
|
50
|
+
end
|
51
|
+
def teardown; clean_examples; end
|
52
|
+
def test_runtex()
|
16
53
|
doc = Document.new(
|
17
54
|
:title => 'Testdokument',
|
18
55
|
:keywords => 'Test',
|
19
56
|
:description => 'This is a test for a Document, generated by docgenerator.rb',
|
20
57
|
:author => 'docgenerator.rb',
|
21
|
-
:maketitle => true
|
58
|
+
:maketitle => true,
|
59
|
+
:log => @log
|
22
60
|
)
|
23
61
|
doc.body << element(:p,{}, 'This is some content' )
|
24
62
|
#~ doc.save('test_document.html')
|
25
63
|
assert_instance_of( Log4r::Logger, doc.log)
|
26
64
|
assert_not_same( DOCGENERATOR_LOGGER, doc.log)
|
27
65
|
|
28
|
-
filename = "
|
29
|
-
#~ doc.runtex = true
|
66
|
+
filename = "#{__method__}.tex"
|
30
67
|
|
31
68
|
assert_equal(false, File.exist?(filename))
|
32
69
|
assert_equal(false, File.exist?(filename.ext('pdf')))
|
@@ -34,33 +71,29 @@ class Test_document_runtex < Test::Unit::TestCase
|
|
34
71
|
assert_equal_filecontent( "expected/test_runtex.stdout",
|
35
72
|
catch_stdout(Proc.new{ doc.save(filename, :runtex => [:statistic]) } )
|
36
73
|
)
|
74
|
+
assert_equal([" INFO Doc: Save changed #{__method__}.tex\n"], @log.outputters.first.flush)
|
37
75
|
|
38
76
|
assert_equal(true, File.exist?(filename))
|
39
77
|
assert_equal(true, File.exist?(filename.ext('pdf')))
|
40
78
|
|
41
|
-
File.delete(filename)
|
42
|
-
File.delete(filename.ext('pdf'))
|
43
|
-
File.delete(filename.ext('aux'))
|
44
|
-
File.delete(filename.ext('log'))
|
45
|
-
File.delete(filename.ext('out'))
|
46
|
-
|
47
79
|
end
|
48
80
|
|
49
81
|
#test with doc.runtex = ...
|
50
|
-
def
|
82
|
+
def test_runtex_2()
|
51
83
|
doc = Document.new(
|
52
84
|
:title => 'Testdokument',
|
53
85
|
:keywords => 'Test',
|
54
86
|
:description => 'This is a test for a Document, generated by docgenerator.rb',
|
55
87
|
:author => 'docgenerator.rb',
|
56
|
-
:maketitle => true
|
88
|
+
:maketitle => true,
|
89
|
+
:log => @log
|
57
90
|
)
|
58
91
|
doc.body << element(:p,{}, 'This is some content' )
|
59
92
|
#~ doc.save('test_document.html')
|
60
93
|
assert_instance_of( Log4r::Logger, doc.log)
|
61
94
|
assert_not_same( DOCGENERATOR_LOGGER, doc.log)
|
62
95
|
|
63
|
-
filename = "
|
96
|
+
filename = "#{__method__}.tex"
|
64
97
|
doc.runtex = [:statistic]
|
65
98
|
|
66
99
|
assert_equal(false, File.exist?(filename))
|
@@ -69,15 +102,10 @@ class Test_document_runtex < Test::Unit::TestCase
|
|
69
102
|
assert_equal_filecontent( "expected/test_runtex_2.stdout",
|
70
103
|
catch_stdout(Proc.new{ doc.save(filename) } )
|
71
104
|
)
|
105
|
+
assert_equal([" INFO Doc: Save changed #{__method__}.tex\n"], @log.outputters.first.flush)
|
72
106
|
|
73
107
|
assert_equal(true, File.exist?(filename))
|
74
108
|
assert_equal(true, File.exist?(filename.ext('pdf')))
|
75
109
|
|
76
|
-
File.delete(filename)
|
77
|
-
File.delete(filename.ext('pdf'))
|
78
|
-
File.delete(filename.ext('aux'))
|
79
|
-
File.delete(filename.ext('log'))
|
80
|
-
File.delete(filename.ext('out'))
|
81
|
-
|
82
110
|
end
|
83
111
|
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
#
|
2
|
+
#Tests for creole/plugins//struktex.rb
|
3
|
+
#
|
4
|
+
#Check after __END__ for missing tests.
|
5
|
+
#
|
6
|
+
|
7
|
+
if $0 == __FILE__
|
8
|
+
$:.unshift("../lib")
|
9
|
+
end
|
10
|
+
|
11
|
+
gem 'test-unit'
|
12
|
+
require 'test/unit'
|
13
|
+
require 'more_unit_test/assert_equal_filecontent.rb'
|
14
|
+
|
15
|
+
require 'creole/creole2doc'
|
16
|
+
require 'creole/plugins/struktex.rb'
|
17
|
+
require 'wiki2doc/wiki2docgenerator'
|
18
|
+
require 'wiki2doc/plugins/struktex.rb'
|
19
|
+
|
20
|
+
|
21
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
22
|
+
#Avoid warnings about missing logger in to_doc
|
23
|
+
OPT = { :log => Docgenerator::DOCGENERATOR_DEFAULT_LOGGER } unless defined? OPT
|
24
|
+
|
25
|
+
#~ $log = Log4r::Logger.new( 'test struktex', Log4r::WARN )
|
26
|
+
#~ $log.outputters = Log4r::StdoutOutputter.new('test struktex')
|
27
|
+
#~ $log.level = Log4r::INFO
|
28
|
+
#~ $log.info("Remark: Known errors/problems and missing checks are logged.")
|
29
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
30
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::INFO
|
31
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::WARN
|
32
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::ERROR
|
33
|
+
|
34
|
+
#~ include Log4r
|
35
|
+
|
36
|
+
class Test_struktex < Test::Unit::TestCase
|
37
|
+
|
38
|
+
def test_struktex_krug()
|
39
|
+
struct = Docgenerator::Packages::Struktex::Structogramm.new('Krug', 120, 45, <<-cmd
|
40
|
+
WHILE Krug nicht zerbrochen
|
41
|
+
Krug geht zum Brunnen
|
42
|
+
ENDWHILE
|
43
|
+
Qualitaetspruefung
|
44
|
+
-> Krug Testgut
|
45
|
+
<- res_1 Pruefergebnis
|
46
|
+
IF Krug zerbrochen
|
47
|
+
THEN
|
48
|
+
Schade
|
49
|
+
ELSE
|
50
|
+
Stabiler Krug
|
51
|
+
ENDIF
|
52
|
+
cmd
|
53
|
+
)
|
54
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.tex", struct.to_doc(:latex, OPT))
|
55
|
+
#~ $log.warn("No test krug.construct") if $log.warn?
|
56
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.wiki", struct.to_doc(:wiki, OPT))
|
57
|
+
#~ $log.warn("No test krug.construct") if $log.warn?
|
58
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.creole", struct.to_doc(:creole, OPT))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_struktex_statement()
|
62
|
+
struct = Docgenerator::Packages::Struktex::Structogramm.new('Simple Statements', 120, 30, <<-cmd
|
63
|
+
Statement
|
64
|
+
=> Call procedure
|
65
|
+
<> Return value
|
66
|
+
<= Exit with return value
|
67
|
+
cmd
|
68
|
+
)
|
69
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.tex", struct.to_doc(:latex, OPT))
|
70
|
+
|
71
|
+
#~ puts struct.to_latex[-10..-1].inspect
|
72
|
+
#~ puts struct.to_doc(:latex)[-10..-1].inspect
|
73
|
+
#~ assert_equal( struct.to_latex, struct.to_doc(:latex))
|
74
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.wiki", struct.to_doc(:wiki, OPT))
|
75
|
+
assert_equal_filecontent( "expected_struktex/#{__method__}.creole", struct.to_doc(:creole, OPT))
|
76
|
+
end
|
77
|
+
end #Test_struktex
|
78
|
+
|
79
|
+
|
80
|
+
class Test_struktex_creole < Test::Unit::TestCase
|
81
|
+
def test_struktex_collector()
|
82
|
+
assert_equal( Docgenerator::Creole::Creole_structogramm, Docgenerator::Creole::Placeholders['structogramm'])
|
83
|
+
assert_equal( Docgenerator::Creole::Creole_structogramm, Docgenerator::Creole::Placeholders::Collection['structogramm'])
|
84
|
+
#~ assert_kind_of( Placeholder, Creole::Placeholders['structogramm'])
|
85
|
+
end
|
86
|
+
end #Test_struktex
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
def newtest(name, withclass = false)
|
91
|
+
code = []
|
92
|
+
code << "class Test_struktex < Test::Unit::TestCase" if withclass
|
93
|
+
code << <<-code
|
94
|
+
def test_struktex_#{name}()
|
95
|
+
struct = ''
|
96
|
+
assert_equal_filecontent( "expected_struktex/struktex_#{name}.tex", struct.to_doc(:latex))
|
97
|
+
#~ $log.warn("No test #{name}.construct") if $log.warn?
|
98
|
+
assert_equal_filecontent( "expected_struktex/struktex_#{name}.wiki", struct.to_doc(:wiki))
|
99
|
+
#~ $log.warn("No test #{name}.construct") if $log.warn?
|
100
|
+
assert_equal_filecontent( "expected_struktex/struktex_#{name}.creole", struct.to_doc(:creole))
|
101
|
+
end
|
102
|
+
code
|
103
|
+
code << "end #Test_struktex" if withclass
|
104
|
+
puts code.join("\n")
|
105
|
+
end
|
106
|
+
|
107
|
+
#~ newtest( 'krug')
|
108
|
+
|
109
|
+
__END__
|
110
|
+
|
111
|
+
===Declarations===
|
112
|
+
With declarations you can define interfaces of sub-routines.
|
113
|
+
This declarations are part of the command
|
114
|
+
>>>structogramm{Declarations/Interfaces;120;25}
|
115
|
+
Statement
|
116
|
+
-> field1 description
|
117
|
+
<- field2 description
|
118
|
+
<-> field3 description
|
119
|
+
<<<
|
120
|
+
|
121
|
+
===IF-Statement===
|
122
|
+
IF Condition
|
123
|
+
THEN size text
|
124
|
+
ELSE size text
|
125
|
+
ENDIF
|
126
|
+
>>>structogramm{Test f�r IF;120;40}
|
127
|
+
IF Bedingung?
|
128
|
+
THEN 6 Ja
|
129
|
+
IF Andere Frage?
|
130
|
+
THEN
|
131
|
+
<= Ergebnis
|
132
|
+
ELSE
|
133
|
+
<= Anderes Ergebnis
|
134
|
+
ENDIF
|
135
|
+
ELSE 6 Nein
|
136
|
+
IF Andere Frage?
|
137
|
+
THEN 4
|
138
|
+
<= Ergebnis
|
139
|
+
ELSE 5
|
140
|
+
<= Anderes Ergebnis
|
141
|
+
ENDIF
|
142
|
+
ENDIF
|
143
|
+
<<<
|
144
|
+
|
145
|
+
===CASE-statements===
|
146
|
+
The first number after CASE defines the degree of the case-line.
|
147
|
+
|
148
|
+
The WHEN clause has an optional parameter:
|
149
|
+
*c centered
|
150
|
+
*r right-aligned
|
151
|
+
>>>structogramm{CASE Statements;120;40}
|
152
|
+
CASE 5 variable
|
153
|
+
WHEN value1
|
154
|
+
Statement 1-1
|
155
|
+
Statement 1-2
|
156
|
+
WHEN[r] value2
|
157
|
+
Statement 2-1
|
158
|
+
Statement 2-2
|
159
|
+
WHEN[c] value3
|
160
|
+
Statement 3-1
|
161
|
+
Statement 3-2
|
162
|
+
WHEN value4
|
163
|
+
Statement 4-1
|
164
|
+
Statement 4-2
|
165
|
+
ENDCASE
|
166
|
+
<<<
|
167
|
+
===While-statements===
|
168
|
+
>>>structogramm{While Statements;120;15}
|
169
|
+
WHILE Condition
|
170
|
+
Statement
|
171
|
+
ENDWHILE
|
172
|
+
<<<
|
173
|
+
|
174
|
+
===Repeat-Until-statements===
|
175
|
+
>>>structogramm{Repeat-Until Statements;120;15}
|
176
|
+
REPEAT
|
177
|
+
Statement
|
178
|
+
UNTIL Condition
|
179
|
+
<<<
|
180
|
+
|
181
|
+
===FOREVER-Loop-statements===
|
182
|
+
>>>structogramm{FOREVER-Loop Statements;120;30}
|
183
|
+
FOREVER
|
184
|
+
Statement
|
185
|
+
<= Exit
|
186
|
+
ENDFOREVER
|
187
|
+
<<<
|
@@ -0,0 +1,275 @@
|
|
1
|
+
#~ require '../test_docgenerator.rb'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'more_unit_test/assert_equal_filecontent.rb'
|
4
|
+
|
5
|
+
if $0 == __FILE__
|
6
|
+
$:.unshift("../lib")
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'docgenerator/packages/rubycode4doc'
|
10
|
+
require 'creole/plugins/rubycode4creole'
|
11
|
+
require 'wiki2doc/plugins/rubycode4wiki'
|
12
|
+
|
13
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
14
|
+
#Avoid warnings about missing logger in to_doc
|
15
|
+
OPT = { :log => Docgenerator::DOCGENERATOR_DEFAULT_LOGGER } unless defined? OPT
|
16
|
+
|
17
|
+
#
|
18
|
+
#
|
19
|
+
#
|
20
|
+
class Test_rubycode4doc < Test::Unit::TestCase
|
21
|
+
def test_codetest()
|
22
|
+
testcode_sourcecode = <<-CODE
|
23
|
+
a = 5
|
24
|
+
b = a * 5
|
25
|
+
puts b
|
26
|
+
puts b + 3
|
27
|
+
CODE
|
28
|
+
|
29
|
+
testcode_evaluated = <<-CODE
|
30
|
+
a = 5 # -> 5
|
31
|
+
b = a * 5 # -> 25
|
32
|
+
puts b # => "25\\n"
|
33
|
+
puts b + 3 # => "28\\n"
|
34
|
+
CODE
|
35
|
+
testcode_output = <<-CODE
|
36
|
+
|
37
|
+
|
38
|
+
25
|
39
|
+
28
|
40
|
+
CODE
|
41
|
+
|
42
|
+
codetest = Docgenerator::Rubycode::CodeTest.new('codetest', testcode_sourcecode )
|
43
|
+
|
44
|
+
assert_equal(testcode_sourcecode.chomp, codetest.sourcecode)
|
45
|
+
assert_equal(testcode_evaluated.chomp, codetest.code_evaluation)
|
46
|
+
assert_equal(testcode_output.chomp, codetest.output)
|
47
|
+
|
48
|
+
#Extend the code
|
49
|
+
codetest << <<-TEST
|
50
|
+
3.times{|i|
|
51
|
+
puts i
|
52
|
+
}
|
53
|
+
TEST
|
54
|
+
testcode_sourcecode << <<-CODE
|
55
|
+
3.times{|i|
|
56
|
+
puts i
|
57
|
+
}
|
58
|
+
CODE
|
59
|
+
testcode_evaluated << <<-CODE
|
60
|
+
3.times{|i|
|
61
|
+
puts i
|
62
|
+
} # -> 3 => "0\\n1\\n2\\n"
|
63
|
+
CODE
|
64
|
+
testcode_output << <<-CODE
|
65
|
+
0
|
66
|
+
1
|
67
|
+
2
|
68
|
+
CODE
|
69
|
+
|
70
|
+
assert_equal(testcode_sourcecode.chomp, codetest.sourcecode)
|
71
|
+
#15 was defined in original settings
|
72
|
+
assert_equal(testcode_evaluated.chomp, codetest.code_evaluation(15))
|
73
|
+
assert_equal(testcode_output.chomp, codetest.output)
|
74
|
+
|
75
|
+
assert_instance_of(Docgenerator::Tables::Tabular, codetest.code_in_tab)
|
76
|
+
assert_instance_of(Docgenerator::Listings::Lstlisting, codetest.code_evaluation_lstlisting)
|
77
|
+
|
78
|
+
end #test_codetest()
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
class Test_rubycode4doc_wiki < Test::Unit::TestCase
|
83
|
+
def test_wikitest()
|
84
|
+
|
85
|
+
Docgenerator::Rubycode::CodeTest.new('codetest_wiki', <<-CODE
|
86
|
+
a = 5
|
87
|
+
b = a * 5
|
88
|
+
puts b
|
89
|
+
puts b + 3
|
90
|
+
CODE
|
91
|
+
)
|
92
|
+
|
93
|
+
wiki_1 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
94
|
+
===Originalcoding===
|
95
|
+
{{rubycode|codetest_wiki}}
|
96
|
+
wiki
|
97
|
+
)
|
98
|
+
wiki_2 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
99
|
+
===Executed Coding===
|
100
|
+
{{rubycode_with_evaluation|codetest_wiki}}
|
101
|
+
wiki
|
102
|
+
)
|
103
|
+
wiki_3 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
104
|
+
===Executed Coding in einer Tabelle===
|
105
|
+
{{rubycode_in_tab|codetest_wiki}}
|
106
|
+
wiki
|
107
|
+
)
|
108
|
+
|
109
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_1.html", wiki_1.to_html(OPT) )
|
110
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_2.html", wiki_2.to_html(OPT) )
|
111
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_3.html", wiki_3.to_html(OPT) )
|
112
|
+
end #test_wikitest()
|
113
|
+
|
114
|
+
|
115
|
+
def test_wikitest_immediate()
|
116
|
+
#Code definieren (Kein output)
|
117
|
+
#Code wird unter dem Namen code_in_wiki abgelegt.
|
118
|
+
wiki = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
119
|
+
>>>rubycode{code_in_wiki}
|
120
|
+
1.upto(3){|i| puts i }
|
121
|
+
<<<
|
122
|
+
wiki
|
123
|
+
)
|
124
|
+
#Verwenden von code_in_wiki
|
125
|
+
wiki_1 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
126
|
+
===Originalcoding===
|
127
|
+
{{rubycode|code_in_wiki}}
|
128
|
+
wiki
|
129
|
+
)
|
130
|
+
wiki_2 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
131
|
+
===Executed Coding===
|
132
|
+
{{rubycode_with_evaluation|code_in_wiki}}
|
133
|
+
wiki
|
134
|
+
)
|
135
|
+
wiki_3 = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
136
|
+
===Executed Coding in a tabular===
|
137
|
+
{{rubycode_in_tab|code_in_wiki}}
|
138
|
+
wiki
|
139
|
+
)
|
140
|
+
|
141
|
+
assert_equal('', wiki.to_html(OPT))
|
142
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_immediate_1.html", wiki_1.to_html(OPT))
|
143
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_immediate_2.html", wiki_2.to_html(OPT))
|
144
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_immediate_3.html", wiki_3.to_html(OPT))
|
145
|
+
|
146
|
+
wiki_full = Docgenerator::Wikimedia::Rubywiki.new( :content => <<wiki
|
147
|
+
==Code definition==
|
148
|
+
(Nothing to see)
|
149
|
+
>>>rubycode{code_in_wiki_full}
|
150
|
+
1.upto(3){|i| puts i * 2 }
|
151
|
+
<<<
|
152
|
+
|
153
|
+
==Code with evaluation==
|
154
|
+
{{rubycode|code_in_wiki_full}}
|
155
|
+
|
156
|
+
==Code with evaluation==
|
157
|
+
{{rubycode_with_evaluation|code_in_wiki_full}}
|
158
|
+
|
159
|
+
==Code with evaluation==
|
160
|
+
{{rubycode_in_tab|code_in_wiki_full}}
|
161
|
+
wiki
|
162
|
+
)
|
163
|
+
assert_equal_filecontent( "expected_rubycode4doc/wiki_immediate_full.html", wiki_full.to_html(OPT))
|
164
|
+
|
165
|
+
end #test_wikitest_immediate()
|
166
|
+
|
167
|
+
end #class Test_rubycode4doc_wiki
|
168
|
+
|
169
|
+
|
170
|
+
class Test_rubycode4doc_creole < Test::Unit::TestCase
|
171
|
+
#This is integrated in Creole
|
172
|
+
def test_creole_inline_ruby()
|
173
|
+
wiki = Docgenerator::Creole::Creole.new()
|
174
|
+
wiki << <<wiki
|
175
|
+
*1 + 1 = <<ruby|1+1>>
|
176
|
+
*1 + 1 = <<ruby_raw|1+1>>
|
177
|
+
wiki
|
178
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_inline_ruby.html", wiki.to_html(OPT))
|
179
|
+
end
|
180
|
+
#
|
181
|
+
#
|
182
|
+
def test_creole_rubycode()
|
183
|
+
wiki = Docgenerator::Creole::Creole.new()
|
184
|
+
wiki << <<wiki
|
185
|
+
<<<rubycode
|
186
|
+
1 + 1
|
187
|
+
>>>
|
188
|
+
wiki
|
189
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode.html", wiki.to_html(OPT))
|
190
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode.tex", wiki.to_latex(OPT))
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_creole_rubycode_output()
|
194
|
+
wiki = Docgenerator::Creole::Creole.new()
|
195
|
+
wiki << <<wiki
|
196
|
+
<<<rubycode_output
|
197
|
+
1 + 1
|
198
|
+
puts 1 + 2
|
199
|
+
>>>
|
200
|
+
wiki
|
201
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_output.html", wiki.to_html(OPT))
|
202
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_output.tex", wiki.to_latex(OPT))
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_creole_rubycode_evaluated()
|
206
|
+
wiki = Docgenerator::Creole::Creole.new()
|
207
|
+
wiki << <<wiki
|
208
|
+
<<<rubycode_evaluated
|
209
|
+
1 + 1
|
210
|
+
>>>
|
211
|
+
wiki
|
212
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode_evaluated.html", wiki.to_html(OPT))
|
213
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode_evaluated.tex", wiki.to_latex(OPT))
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_creole_rubycode_evaluated_listings()
|
217
|
+
wiki = Docgenerator::Creole::Creole.new()
|
218
|
+
wiki << <<wiki
|
219
|
+
<<<rubycode_evaluated_listings
|
220
|
+
1 + 1
|
221
|
+
>>>
|
222
|
+
wiki
|
223
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode_evaluated_listings.html", wiki.to_html(OPT))
|
224
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_rubycode_evaluated_listings.tex", wiki.to_latex(OPT))
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
def test_creole_rubycode_in_tab()
|
230
|
+
wiki = Docgenerator::Creole::Creole.new()
|
231
|
+
wiki << <<wiki
|
232
|
+
<<<rubycode_in_tab
|
233
|
+
1 + 1
|
234
|
+
>>>
|
235
|
+
wiki
|
236
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_in_tab.html", wiki.to_html(OPT))
|
237
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_in_tab.tex", wiki.to_latex(OPT))
|
238
|
+
end
|
239
|
+
|
240
|
+
|
241
|
+
#
|
242
|
+
def test_creole_rubycode_complete()
|
243
|
+
wiki = Docgenerator::Creole::Creole.new()
|
244
|
+
wiki << <<wiki
|
245
|
+
rubycode
|
246
|
+
<<<rubycode
|
247
|
+
1 + 1
|
248
|
+
>>>
|
249
|
+
----
|
250
|
+
rubycode_output
|
251
|
+
<<<rubycode_output
|
252
|
+
puts 1 + 1
|
253
|
+
>>>
|
254
|
+
----
|
255
|
+
rubycode_evaluated
|
256
|
+
<<<rubycode_evaluated
|
257
|
+
1 + 1
|
258
|
+
>>>
|
259
|
+
----
|
260
|
+
rubycode_in_tab
|
261
|
+
<<<rubycode_in_tab
|
262
|
+
1 + 1
|
263
|
+
>>>
|
264
|
+
----
|
265
|
+
<<<rubycode_evaluated_listings
|
266
|
+
1 + 1
|
267
|
+
>>>
|
268
|
+
wiki
|
269
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_complete.html", wiki.to_html(OPT))
|
270
|
+
assert_equal_filecontent( "expected_rubycode4doc/creole_complete.tex", wiki.to_latex(OPT))
|
271
|
+
end
|
272
|
+
|
273
|
+
end #class Test_rubycode4doc_creole
|
274
|
+
|
275
|
+
__END__
|