docgenerator 0.1.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/docgenerator_example.rb +76 -160
- data/examples/docgenerator_example_footnote.rb +98 -0
- data/examples/docgenerator_example_list.rb +62 -0
- data/examples/docgenerator_example_restrictions.rb +59 -0
- data/examples/docgenerator_example_tabular.rb +68 -0
- data/examples/docgenerator_example_tripfalls.rb +57 -0
- data/examples/wiki2docgenerator_example.rb +270 -0
- data/lib/docgenerator.rb +159 -0
- data/{docgenerator_attribute.rb → lib/docgenerator_attribute.rb} +32 -7
- data/{docgenerator_characters.rb → lib/docgenerator_characters.rb} +15 -0
- data/{docgenerator_css.rb → lib/docgenerator_css.rb} +6 -1
- data/{docgenerator_document.rb → lib/docgenerator_document.rb} +92 -93
- data/{docgenerator_element.rb → lib/docgenerator_element.rb} +125 -51
- data/{docgenerator_elements.rb → lib/docgenerator_elements.rb} +40 -56
- data/{docgenerator_environments.rb → lib/docgenerator_environments.rb} +16 -10
- data/{docgenerator_footnote.rb → lib/docgenerator_footnote.rb} +44 -22
- data/{docgenerator_lists.rb → lib/docgenerator_lists.rb} +44 -39
- data/{docgenerator_sections.rb → lib/docgenerator_sections.rb} +2 -2
- data/{docgenerator_tabular.rb → lib/docgenerator_tabular.rb} +71 -39
- data/{packages → lib/packages}/docgenerator_attachfile.rb +0 -0
- data/{packages → lib/packages}/docgenerator_caption.rb +0 -0
- data/{packages → lib/packages}/docgenerator_hyperref.rb +0 -0
- data/{packages → lib/packages}/docgenerator_listings.rb +1 -2
- data/{packages → lib/packages}/docgenerator_pdfpages.rb +0 -0
- data/{packages → lib/packages}/docgenerator_scrlettr2.rb +2 -2
- data/{packages → lib/packages}/docgenerator_scrpage2.rb +0 -0
- data/{packages → lib/packages}/docgenerator_url.rb +0 -0
- data/lib/templates/docgenerator_template.rb +176 -0
- data/lib/templates/docgenerator_template.yaml +105 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +1161 -0
- data/self_docgenerator.rb +161 -0
- data/unittest/expected/test_beamer_note.html +1 -0
- data/unittest/expected/test_beamer_note.latex +1 -0
- data/unittest/expected/test_beamer_note.text +1 -0
- data/unittest/expected/test_beamer_note.wiki +1 -0
- data/unittest/expected/test_block.html +1 -0
- data/unittest/expected/test_block.latex +1 -0
- data/unittest/expected/test_block.text +1 -0
- data/unittest/expected/test_block.wiki +2 -0
- data/unittest/expected/test_css.css +1 -0
- data/unittest/expected/test_css2.css +1 -0
- data/unittest/expected/test_description.html +1 -0
- data/unittest/expected/test_description.latex +3 -0
- data/unittest/expected/test_description.text +3 -0
- data/unittest/expected/test_description.wiki +3 -0
- data/unittest/expected/test_document_article.latex +23 -0
- data/unittest/expected/test_document_html.html +14 -0
- data/unittest/expected/test_document_replacement_article.latex +23 -0
- data/unittest/expected/test_document_replacement_html.html +14 -0
- data/unittest/expected/test_document_replacement_text.text +5 -0
- data/unittest/expected/test_document_replacement_wiki.wiki +5 -0
- data/unittest/expected/test_document_text.text +5 -0
- data/unittest/expected/test_document_wiki.wiki +5 -0
- data/unittest/expected/test_enumerate.html +1 -0
- data/unittest/expected/test_enumerate.latex +3 -0
- data/unittest/expected/test_enumerate.text +1 -0
- data/unittest/expected/test_enumerate.wiki +2 -0
- data/unittest/expected/test_footnote.html +5 -0
- data/unittest/expected/test_footnote.latex +11 -0
- data/unittest/expected/test_footnote.text +13 -0
- data/unittest/expected/test_footnote.wiki +11 -0
- data/unittest/expected/test_footnote_group.html +8 -0
- data/unittest/expected/test_footnote_group.latex +17 -0
- data/unittest/expected/test_footnote_group.wiki +17 -0
- data/unittest/expected/test_href.html +2 -0
- data/unittest/expected/test_href.latex +8 -0
- data/unittest/expected/test_href.text +4 -0
- data/unittest/expected/test_html_css.html +1 -0
- data/unittest/expected/test_itemize.html +1 -0
- data/unittest/expected/test_itemize.latex +3 -0
- data/unittest/expected/test_itemize.text +1 -0
- data/unittest/expected/test_itemize.wiki +2 -0
- data/unittest/expected/test_section.html +8 -0
- data/unittest/expected/test_section.latex +20 -0
- data/unittest/expected/test_section.text +24 -0
- data/unittest/expected/test_section.wiki +20 -0
- data/unittest/expected/test_tabular.html +10 -0
- data/unittest/expected/test_tabular.latex +10 -0
- data/unittest/expected/test_tabular.wiki +31 -0
- data/unittest/expected/test_tabular_doc.latex +22 -0
- data/unittest/expected/test_wiki.html +6 -0
- data/unittest/expected/test_wiki.latex +12 -0
- data/unittest/expected/test_wiki.text +14 -0
- data/unittest/expected/test_wiki.wiki +12 -0
- data/unittest/expected/test_wiki_amazon.html +10 -0
- data/unittest/expected/test_wiki_description.html +7 -0
- data/unittest/expected/test_wiki_description.latex +11 -0
- data/unittest/expected/test_wiki_description.text +6 -0
- data/unittest/expected/test_wiki_description.wiki +6 -0
- data/unittest/expected/test_wiki_footnote.html +8 -0
- data/unittest/expected/test_wiki_footnote.latex +15 -0
- data/unittest/expected/test_wiki_footnote.text +12 -0
- data/unittest/expected/test_wiki_footnote.wiki +12 -0
- data/unittest/expected/test_wiki_footnote_groupid.html +21 -0
- data/unittest/expected/test_wiki_html_code.html +7 -0
- data/unittest/expected/test_wiki_html_code.latex +10 -0
- data/unittest/expected/test_wiki_html_code.text +6 -0
- data/unittest/expected/test_wiki_html_code.wiki +6 -0
- data/unittest/expected/test_wiki_inline.html +6 -0
- data/unittest/expected/test_wiki_inline.latex +12 -0
- data/unittest/expected/test_wiki_inline.text +8 -0
- data/unittest/expected/test_wiki_inline.wiki +8 -0
- data/unittest/expected/test_wiki_label.html +6 -0
- data/unittest/expected/test_wiki_link.html +8 -0
- data/unittest/expected/test_wiki_link.latex +14 -0
- data/unittest/expected/test_wiki_link.log +3 -0
- data/unittest/expected/test_wiki_link.wiki +6 -0
- data/unittest/expected/test_wiki_list_ol.html +24 -0
- data/unittest/expected/test_wiki_list_ol.latex +30 -0
- data/unittest/expected/test_wiki_list_ol.text +10 -0
- data/unittest/expected/test_wiki_list_ol.wiki +12 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.html +16 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.latex +24 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.text +8 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.wiki +10 -0
- data/unittest/expected/test_wiki_list_ol_ul.html +24 -0
- data/unittest/expected/test_wiki_list_ol_ul.latex +30 -0
- data/unittest/expected/test_wiki_list_ol_ul.text +10 -0
- data/unittest/expected/test_wiki_list_ol_ul.wiki +12 -0
- data/unittest/expected/test_wiki_list_ul.html +24 -0
- data/unittest/expected/test_wiki_list_ul.latex +30 -0
- data/unittest/expected/test_wiki_list_ul.text +10 -0
- data/unittest/expected/test_wiki_list_ul.wiki +12 -0
- data/unittest/expected/test_wiki_list_ul_too_much.html +39 -0
- data/unittest/expected/test_wiki_list_ul_too_much.latex +51 -0
- data/unittest/expected/test_wiki_list_ul_too_much.text +11 -0
- data/unittest/expected/test_wiki_list_ul_too_much.wiki +15 -0
- data/unittest/expected/test_wiki_picture.html +55 -0
- data/unittest/expected/test_wiki_picture.latex +76 -0
- data/unittest/expected/test_wiki_picture_thumb.html +5 -0
- data/unittest/expected/test_wiki_tab1.html +30 -0
- data/unittest/expected/test_wiki_tab1.latex +30 -0
- data/unittest/expected/test_wiki_tab1.wiki +29 -0
- data/unittest/expected/test_wiki_textformatting.html +7 -0
- data/unittest/expected/test_wiki_textformatting.latex +16 -0
- data/unittest/expected/test_wiki_textformatting.text +11 -0
- data/unittest/expected/test_wiki_textformatting.wiki +9 -0
- data/unittest/expected/test_wiki_toc.html +9 -0
- data/unittest/expected/test_wiki_toc.latex +18 -0
- data/unittest/expected/test_wiki_toc.text +21 -0
- data/unittest/expected/test_wiki_toc.wiki +18 -0
- data/unittest/expected/test_wiki_ul_multiple_line.html +18 -0
- data/unittest/expected/test_wiki_ul_multiple_line.latex +19 -0
- data/unittest/expected/test_wiki_ul_multiple_line.text +6 -0
- data/unittest/expected/test_wiki_ul_multiple_line.wiki +7 -0
- data/unittest/test_docgenerator.rb +85 -0
- data/unittest/unittest_docgenerator.rb +454 -0
- data/unittest/unittest_wiki2doc.rb +451 -0
- metadata +155 -31
- data/docgenerator.rb +0 -137
- data/docgenerator_template.rb +0 -103
- data/packages/docgenerator_beamer.rb +0 -250
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'tempfile' #needed to get logger.data
|
3
|
+
|
4
|
+
|
5
|
+
$: << '../lib'
|
6
|
+
require 'docgenerator'
|
7
|
+
require 'wiki2doc/wiki2docgenerator'
|
8
|
+
puts "==> Version #{DOCGENERATOR_VERSION}"
|
9
|
+
|
10
|
+
$fixmes = []
|
11
|
+
#
|
12
|
+
# Mag nicht
|
13
|
+
#
|
14
|
+
#~ END{
|
15
|
+
#~ puts 'Fixmes:'
|
16
|
+
#~ puts $fixmes.join("\n")
|
17
|
+
#~ }
|
18
|
+
|
19
|
+
require 'ftools'
|
20
|
+
class Test::Unit::TestCase
|
21
|
+
#
|
22
|
+
#Takes the content of the file 'filename' and compares it with 'actual' like in assert_equal.
|
23
|
+
#If 'filname' doesn't exist, the failure
|
24
|
+
# Reference file <#{filename}> missing
|
25
|
+
#is returned.
|
26
|
+
#
|
27
|
+
#'folder_for_failure' will contain all results with differences.
|
28
|
+
#
|
29
|
+
#What will happen:
|
30
|
+
#1) text.to_doc(:html) is the test. It creates some HTML-Text
|
31
|
+
#2) "expected/test_section.html" is read and compared to text.to_doc(:html)
|
32
|
+
#2a) If the file is missing -> error
|
33
|
+
#2b) If it is the same -> fine
|
34
|
+
#2c) If there are differences:
|
35
|
+
#3) A message is given (like in assert_equal)
|
36
|
+
#4) A folder "failure#{Date.today}" is created if not already exist
|
37
|
+
#5) The file 'test_section.html' with the result is created in "failure#{Date.today}/"
|
38
|
+
#6) I can use a compare tool to compare the expected result and the real result.
|
39
|
+
#
|
40
|
+
#Recommendation to build up your test.
|
41
|
+
#1) Create two folders: 'expected' and 'failure'
|
42
|
+
#2) Define your assertion with a non-existing filename
|
43
|
+
#3) Run the test with folder_for_failure = 'failure'
|
44
|
+
#4) You will get a failure (reference file is missing).
|
45
|
+
#5) Copy the file in 'failure' to 'expected'
|
46
|
+
#6) Rerun again, you have no failure (hopefully ;-) )
|
47
|
+
def assert_equal_filecontent( filename, actual, folder_for_failure = "failure#{Date.today}", message = nil )
|
48
|
+
if File.exist?(filename)
|
49
|
+
expected = File.read(filename)
|
50
|
+
full_message = build_message(message, "<?> expected (#{filename}) but was\n<?>.\n", expected, actual)
|
51
|
+
else
|
52
|
+
full_message = "Reference file <#{filename}> missing"
|
53
|
+
end
|
54
|
+
#Write the real result to a file.
|
55
|
+
#Folder is defined with Test::Unit::TestCase#folder_for_failure
|
56
|
+
if folder_for_failure and expected != actual
|
57
|
+
File.makedirs(folder_for_failure) if ! File.directory?(folder_for_failure)
|
58
|
+
File.open( "#{folder_for_failure}/#{File.basename(filename)}", 'w'){|f|
|
59
|
+
f << actual
|
60
|
+
}
|
61
|
+
end
|
62
|
+
assert_block( full_message ){ expected == actual }
|
63
|
+
end
|
64
|
+
#
|
65
|
+
end
|
66
|
+
|
67
|
+
#~ #
|
68
|
+
#~ # Little helper. assert_equal with another order of data.
|
69
|
+
#~ # Reason: The here-documents must be the last parameter in a method call.
|
70
|
+
#~ #
|
71
|
+
#~ def assert_equal_reverse( code, expectedresult )
|
72
|
+
#~ assert_equal( expectedresult, code )
|
73
|
+
#~ end
|
74
|
+
#~ # Little helper. assert_equal with another order of data.
|
75
|
+
#~ # Reason: The here-documents must be the last parameter in a method call.
|
76
|
+
#~ #
|
77
|
+
#~ def assert_equal_reverse_chomp( code, expectedresult )
|
78
|
+
#~ assert_equal( expectedresult.chomp, code )
|
79
|
+
#~ end
|
80
|
+
|
81
|
+
|
82
|
+
if $0 == __FILE__
|
83
|
+
#~ require 'unittest_docgenerator.rb'
|
84
|
+
#~ require 'unittest_wiki2doc.rb'
|
85
|
+
end
|
@@ -0,0 +1,454 @@
|
|
1
|
+
require 'test_docgenerator.rb'
|
2
|
+
|
3
|
+
Element.log = true
|
4
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
5
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::ERROR
|
6
|
+
|
7
|
+
|
8
|
+
class Test_elements < Test::Unit::TestCase
|
9
|
+
#Redirect Logger data to temporary file
|
10
|
+
def set_temporary_logger()
|
11
|
+
templogfile = Tempfile.new("xxx_warn.log")
|
12
|
+
@loglevel = DOCGENERATOR_LOGGER.level
|
13
|
+
@outputter = DOCGENERATOR_LOGGER.outputters.first
|
14
|
+
DOCGENERATOR_LOGGER.level = Log4r::WARN
|
15
|
+
DOCGENERATOR_LOGGER.outputters = Log4r::IOOutputter.new('log_xxx', templogfile )
|
16
|
+
return templogfile
|
17
|
+
end
|
18
|
+
#Get temporary data and reset logger.
|
19
|
+
def get_temporary_logger(templogfile)
|
20
|
+
templogfile.close()
|
21
|
+
templogfile.open()
|
22
|
+
templogfile_content = templogfile.readlines.to_s
|
23
|
+
templogfile.close(true)
|
24
|
+
DOCGENERATOR_LOGGER.level = @loglevel
|
25
|
+
DOCGENERATOR_LOGGER.outputters = @outputter
|
26
|
+
return templogfile_content
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_generell_settings()
|
30
|
+
#Check the logger
|
31
|
+
assert_instance_of( Log4r::Logger, DOCGENERATOR_LOGGER)
|
32
|
+
assert_equal( Log4r::FATAL, DOCGENERATOR_LOGGER.level, "Default Level of Default-Logger (DOCGENERATOR_LOGGER) changed:")
|
33
|
+
#~ assert_equal( Log4r::ERROR, DOCGENERATOR_LOGGER.level)
|
34
|
+
assert_instance_of( Log4r::StdoutOutputter, DOCGENERATOR_LOGGER.outputters.first)
|
35
|
+
#~ assert_equal( Log4r::FATAL, DOCGENERATOR_LOGGER.outputters.first.level)
|
36
|
+
end
|
37
|
+
def test_content_flag()
|
38
|
+
#~ log = Log4r::Logger.new( 'Flags')
|
39
|
+
#~ log.level = Log4r::ERROR
|
40
|
+
#~ log.level = Log4r::DEBUG
|
41
|
+
#~ log.outputters = Log4r::StdoutOutputter.new('test_section')
|
42
|
+
|
43
|
+
assert_equal( true, element(:p).content?)
|
44
|
+
assert_equal( false, element(:br).content?)
|
45
|
+
#Result ok, but warning
|
46
|
+
assert_equal( "<br />", element(:br,{},'content').to_html)
|
47
|
+
|
48
|
+
#fixme Umsetzen des logger in methden
|
49
|
+
templogfile = set_temporary_logger()
|
50
|
+
assert_equal( "<br />", element(:br,{},'content').to_html)
|
51
|
+
#~ assert_equal_filecontent( "expected/test_content.log", get_temporary_logger() )
|
52
|
+
assert_equal(%Q{ WARN docgenerator: Add content to an element without this feature ["br/", :br, :newline, "br"], "content"\n}, get_temporary_logger(templogfile))
|
53
|
+
end
|
54
|
+
def test_symbols()
|
55
|
+
#~ log = Log4r::Logger.new( 'section_logger')
|
56
|
+
#~ log.level = Log4r::ERROR
|
57
|
+
#~ log.level = Log4r::DEBUG
|
58
|
+
#~ log.outputters = Log4r::StdoutOutputter.new('test_section')
|
59
|
+
assert_equal( ' ', element(:space).to_html)
|
60
|
+
assert_equal( ' ', element(:ensp).to_html)
|
61
|
+
assert_equal( '~', element(:space).to_latex)
|
62
|
+
assert_equal( '~', element(:ensp).to_latex)
|
63
|
+
assert_equal( ' ', element(:bigspace).to_html)
|
64
|
+
assert_equal( ' ', element(:emsp).to_html)
|
65
|
+
assert_equal( '~~', element(:bigspace).to_latex)
|
66
|
+
assert_equal( '~~', element(:emsp).to_latex)
|
67
|
+
assert_equal( ' ', element(:nbsp).to_html)
|
68
|
+
assert_equal( '~', element(:nbsp).to_latex)
|
69
|
+
assert_equal( '€', element(:euro).to_html)
|
70
|
+
assert_equal( '\euro', element(:euro).to_latex)
|
71
|
+
assert_equal( '%', element(:percent).to_html)
|
72
|
+
assert_equal( '%', element(:'%').to_html)
|
73
|
+
assert_equal( '\%', element(:percent).to_latex)
|
74
|
+
assert_equal( '\%', element(:'%').to_latex)
|
75
|
+
assert_equal( '^', element(:'^').to_html)
|
76
|
+
assert_equal( '\hat{}', element(:'^').to_latex)
|
77
|
+
assert_equal( '¿', element(:iquest).to_html)
|
78
|
+
assert_equal( '�', element(:iquest).to_latex)
|
79
|
+
assert_equal( '&', element(:ampersand).to_html)
|
80
|
+
assert_equal( '&', element(:'&').to_html)
|
81
|
+
assert_equal( '\&', element(:ampersand).to_latex)
|
82
|
+
assert_equal( '\&', element(:'&').to_latex)
|
83
|
+
assert_equal( '}', element(:rbrace).to_html)
|
84
|
+
assert_equal( '}', element(:'}').to_html)
|
85
|
+
assert_equal( '\}', element(:rbrace).to_latex)
|
86
|
+
assert_equal( '\}', element(:'}').to_latex)
|
87
|
+
assert_equal( '{', element(:lbrace).to_html)
|
88
|
+
assert_equal( '{', element(:'{').to_html)
|
89
|
+
assert_equal( '\{', element(:lbrace).to_latex)
|
90
|
+
assert_equal( '\{', element(:'{').to_latex)
|
91
|
+
assert_equal( '\\', element(:backslash).to_html)
|
92
|
+
assert_equal( '\ensuremath{\backslash}', element(:backslash).to_latex)
|
93
|
+
assert_equal( '√', element(:radic).to_html)
|
94
|
+
assert_equal( '\ensuremath{\sqrt{}}', element(:radic).to_latex)
|
95
|
+
assert_equal( '→', element(:rarr).to_html)
|
96
|
+
assert_equal( '→', element(:rightarrow).to_html)
|
97
|
+
assert_equal( '→', element(:'->').to_html)
|
98
|
+
assert_equal( '\ensuremath{\rightarrow}', element(:rarr).to_latex)
|
99
|
+
assert_equal( '\ensuremath{\rightarrow}', element(:rightarrow).to_latex)
|
100
|
+
assert_equal( '\ensuremath{\rightarrow}', element(:'->').to_latex)
|
101
|
+
assert_equal( '⇒', element(:rArr).to_html)
|
102
|
+
assert_equal( '⇒', element(:Rightarrow).to_html)
|
103
|
+
assert_equal( '⇒', element(:'=>').to_html)
|
104
|
+
assert_equal( '\ensuremath{\Rightarrow}', element(:rArr).to_latex)
|
105
|
+
assert_equal( '\ensuremath{\Rightarrow}', element(:Rightarrow).to_latex)
|
106
|
+
assert_equal( '\ensuremath{\Rightarrow}', element(:'=>').to_latex)
|
107
|
+
assert_equal( '←', element(:larr).to_html)
|
108
|
+
assert_equal( '←', element(:leftarrow).to_html)
|
109
|
+
assert_equal( '←', element(:'<-').to_html)
|
110
|
+
assert_equal( '\ensuremath{\leftarrow}', element(:larr).to_latex)
|
111
|
+
assert_equal( '\ensuremath{\leftarrow}', element(:leftarrow).to_latex)
|
112
|
+
assert_equal( '\ensuremath{\leftarrow}', element(:'<-').to_latex)
|
113
|
+
assert_equal( '⇐', element(:lArr).to_html)
|
114
|
+
assert_equal( '⇐', element(:Leftarrow).to_html)
|
115
|
+
assert_equal( '⇐', element(:'<=').to_html)
|
116
|
+
assert_equal( '\ensuremath{\Lefttarrow}', element(:lArr).to_latex)
|
117
|
+
assert_equal( '\ensuremath{\Lefttarrow}', element(:Leftarrow).to_latex)
|
118
|
+
assert_equal( '\ensuremath{\Lefttarrow}', element(:'<=').to_latex)
|
119
|
+
assert_equal( '⇑', element(:uArr).to_html)
|
120
|
+
assert_equal( '⇑', element(:Uparrow).to_html)
|
121
|
+
assert_equal( '\ensuremath{\Uparrow}', element(:uArr).to_latex)
|
122
|
+
assert_equal( '\ensuremath{\Uparrow}', element(:Uparrow).to_latex)
|
123
|
+
assert_equal( '<', element(:lt).to_html)
|
124
|
+
assert_equal( '<', element(:'<').to_html)
|
125
|
+
assert_equal( '\ensuremath{<}', element(:lt).to_latex)
|
126
|
+
assert_equal( '\ensuremath{<}', element(:'<').to_latex)
|
127
|
+
assert_equal( '>', element(:gt).to_html)
|
128
|
+
assert_equal( '>', element(:'>').to_html)
|
129
|
+
assert_equal( '\ensuremath{>}', element(:gt).to_latex)
|
130
|
+
assert_equal( '\ensuremath{>}', element(:'>').to_latex)
|
131
|
+
assert_equal( '∞', element(:infin).to_html)
|
132
|
+
assert_equal( '∞', element(:infty).to_html)
|
133
|
+
assert_equal( '\ensuremath{\infty}', element(:infin).to_latex)
|
134
|
+
assert_equal( '\ensuremath{\infty}', element(:infty).to_latex)
|
135
|
+
assert_equal( '÷', element(:divide).to_html)
|
136
|
+
assert_equal( '\ensuremath{\div}', element(:divide).to_latex)
|
137
|
+
assert_equal( '¥', element(:yen).to_html)
|
138
|
+
assert_equal( '∼', element(:sim).to_html)
|
139
|
+
assert_equal( '\ensuremath{\sim}', element(:sim).to_latex)
|
140
|
+
assert_equal( '¦', element(:brvbar).to_html)
|
141
|
+
assert_equal( '|', element(:brvbar).to_latex)
|
142
|
+
assert_equal( '5€', element(:euros,{},5).to_html)
|
143
|
+
assert_equal( '\euros{5}', element(:euros,{},5).to_latex)
|
144
|
+
assert_equal( '¬', element(:neg).to_html)
|
145
|
+
assert_equal( '¬', element(:not).to_html)
|
146
|
+
assert_equal( '\ensuremath{\neg}', element(:neg).to_latex)
|
147
|
+
assert_equal( '\ensuremath{\neg}', element(:not).to_latex)
|
148
|
+
assert_equal( '×', element(:times).to_html)
|
149
|
+
assert_equal( '\ensuremath{\times}', element(:times).to_latex)
|
150
|
+
assert_equal( '⊗', element(:otimes).to_html)
|
151
|
+
assert_equal( '\ensuremath{\otimes}', element(:otimes).to_latex)
|
152
|
+
assert_equal( '∅', element(:empty).to_html)
|
153
|
+
assert_equal( '\ensuremath{\emptyset}', element(:empty).to_latex)
|
154
|
+
assert_equal( '_', element(:'_').to_html)
|
155
|
+
assert_equal( '_', element(:underscore).to_html)
|
156
|
+
assert_equal( '\_', element(:'_').to_latex)
|
157
|
+
assert_equal( '\_', element(:underscore).to_latex)
|
158
|
+
assert_equal( '•', element(:bullet).to_html)
|
159
|
+
assert_equal( '\ensuremath{\bullet}', element(:bullet).to_latex)
|
160
|
+
assert_equal( '–', element(:'--').to_html)
|
161
|
+
assert_equal( '–', element(:ndash).to_html)
|
162
|
+
assert_equal( '--', element(:'--').to_latex)
|
163
|
+
assert_equal( '--', element(:ndash).to_latex)
|
164
|
+
assert_equal( '—', element(:'---').to_html)
|
165
|
+
assert_equal( '—', element(:mdash).to_html)
|
166
|
+
assert_equal( '---', element(:'---').to_latex)
|
167
|
+
assert_equal( '---', element(:mdash).to_latex)
|
168
|
+
assert_equal( '†', element(:dagger).to_html)
|
169
|
+
assert_equal( '\dag', element(:dagger).to_latex)
|
170
|
+
end
|
171
|
+
def test_section()
|
172
|
+
#~ log = Log4r::Logger.new( 'section_logger')
|
173
|
+
#~ log.level = Log4r::ERROR
|
174
|
+
#~ log.level = Log4r::DEBUG
|
175
|
+
#~ log.outputters = Log4r::StdoutOutputter.new('test_section')
|
176
|
+
|
177
|
+
text = [
|
178
|
+
element(:h1, {}, 'Abschnitt 1' ).cr,
|
179
|
+
element(:par, {}, 'Text zu Abschnitt 1' ).cr,
|
180
|
+
element(:h2, {}, 'Abschnitt 1.1' ).cr,
|
181
|
+
element(:p, {}, 'Text zu Abschnitt 1.1' ).cr,
|
182
|
+
element(:h1, {}, 'Abschnitt 2' ).cr,
|
183
|
+
element(:par, {}, 'Text zu Abschnitt 2' ).cr,
|
184
|
+
element(:h2, {}, 'Abschnitt 2.1' ).cr,
|
185
|
+
element(:p, {}, 'Text zu Abschnitt 2.1' ).cr
|
186
|
+
]
|
187
|
+
assert_equal_filecontent( "expected/test_section.html", text.to_doc(:html))
|
188
|
+
assert_equal_filecontent( "expected/test_section.latex", text.to_doc(:latex))
|
189
|
+
assert_equal_filecontent( "expected/test_section.wiki", text.to_doc(:wiki))
|
190
|
+
assert_equal_filecontent( "expected/test_section.text", text.to_doc(:text))
|
191
|
+
end
|
192
|
+
def test_href()
|
193
|
+
#~ log = Log4r::Logger.new( 'section_logger')
|
194
|
+
#~ log.level = Log4r::ERROR
|
195
|
+
#~ log.level = Log4r::DEBUG
|
196
|
+
#~ log.outputters = Log4r::StdoutOutputter.new('test_section')
|
197
|
+
|
198
|
+
text = [
|
199
|
+
element(:p, {}, [ 'Jetzt ein ',
|
200
|
+
element(:label, { :name => 'ilink'}, 'Ziel'),
|
201
|
+
' f�r einen Link',
|
202
|
+
] ).cr,
|
203
|
+
element(:p, {}, [ 'Und hier der Textlink zum ',
|
204
|
+
element(:a, {:href=>'#ilink'}, 'Ziel.'),
|
205
|
+
] ).cr,
|
206
|
+
]
|
207
|
+
assert_equal_filecontent( "expected/test_href.html", text.to_doc(:html))
|
208
|
+
assert_equal_filecontent( "expected/test_href.latex", text.to_doc(:latex))
|
209
|
+
#~ assert_equal_filecontent( "expected/test_href.wiki", text.to_doc(:wiki))
|
210
|
+
assert_equal_filecontent( "expected/test_href.text", text.to_doc(:text)) #not good
|
211
|
+
end
|
212
|
+
end #Test_elements
|
213
|
+
|
214
|
+
class Test_lists < Test::Unit::TestCase
|
215
|
+
def test_itemize
|
216
|
+
ul = element(:ul, {}, [
|
217
|
+
element(:li, {}, 'Listpunkt 1'),
|
218
|
+
])
|
219
|
+
assert_equal_filecontent( "expected/test_itemize.html", ul.to_doc(:html))
|
220
|
+
assert_equal_filecontent( "expected/test_itemize.latex", ul.to_doc(:latex))
|
221
|
+
assert_equal_filecontent( "expected/test_itemize.wiki", ul.to_doc(:wiki))
|
222
|
+
assert_equal_filecontent( "expected/test_itemize.text", ul.to_doc(:text))
|
223
|
+
end
|
224
|
+
def test_enumerate
|
225
|
+
ol = element(:ol, {}, [
|
226
|
+
element(:li, {}, 'Listpunkt 1'),
|
227
|
+
])
|
228
|
+
assert_equal_filecontent( "expected/test_enumerate.html", ol.to_doc(:html))
|
229
|
+
assert_equal_filecontent( "expected/test_enumerate.latex", ol.to_doc(:latex))
|
230
|
+
assert_equal_filecontent( "expected/test_enumerate.wiki", ol.to_doc(:wiki))
|
231
|
+
assert_equal_filecontent( "expected/test_enumerate.text", ol.to_doc(:text))
|
232
|
+
end
|
233
|
+
def test_description
|
234
|
+
description = element(:description, {}, [
|
235
|
+
element(:dt, {}, 'Top 1'),
|
236
|
+
element(:dd, {}, 'Listpunkt 1'),
|
237
|
+
])
|
238
|
+
assert_equal_filecontent( "expected/test_description.html", description.to_doc(:html))
|
239
|
+
assert_equal_filecontent( "expected/test_description.latex", description.to_doc(:latex))
|
240
|
+
assert_equal_filecontent( "expected/test_description.wiki", description.to_doc(:wiki))
|
241
|
+
assert_equal_filecontent( "expected/test_description.text", description.to_doc(:text))
|
242
|
+
end
|
243
|
+
end #Test_lists
|
244
|
+
|
245
|
+
class Test_footnotes < Test::Unit::TestCase
|
246
|
+
def test_footnote
|
247
|
+
text = [
|
248
|
+
element(:h1, {}, 'Abschnitt 1' ).cr,
|
249
|
+
element(:par, {}, [
|
250
|
+
'Text zu Abschnitt 1',
|
251
|
+
element(:footnote,{}, 'Fu� eins'),
|
252
|
+
'Weiterer Text',
|
253
|
+
]
|
254
|
+
).cr,
|
255
|
+
element(:h2, {}, 'Fu�noten' ).cr,
|
256
|
+
Footnotegroup.get,
|
257
|
+
]
|
258
|
+
assert_equal_filecontent( "expected/test_footnote.html", text.to_doc(:html))
|
259
|
+
assert_equal_filecontent( "expected/test_footnote.latex", text.to_doc(:latex))
|
260
|
+
#~ assert_equal_filecontent( "expected/test_footnote.wiki", text.to_doc(:wiki))
|
261
|
+
#~ assert_equal_filecontent( "expected/test_footnote.text", text.to_doc(:text))
|
262
|
+
end #test_footnote
|
263
|
+
def test_footnote_group
|
264
|
+
Footnotegroup.clear()
|
265
|
+
text = [
|
266
|
+
element(:h1, {}, 'Abschnitt 1' ).cr,
|
267
|
+
element(:par, {}, [
|
268
|
+
'Text zu Abschnitt 1',
|
269
|
+
element(:footnote,{ :groupid => 'g1' }, 'Fu� eins (g1)'),
|
270
|
+
'Weiterer Text',
|
271
|
+
element(:footnote,{}, 'Noch ne Fu�note'),
|
272
|
+
]
|
273
|
+
).cr,
|
274
|
+
element(:h2, {}, 'Fu�noten' ).cr,
|
275
|
+
Footnotegroup.get,
|
276
|
+
element(:h3, {}, 'Fu�noten g1' ).cr,
|
277
|
+
Footnotegroup.get('g1'),
|
278
|
+
]
|
279
|
+
assert_equal_filecontent( "expected/test_footnote_group.html", text.to_doc(:html))
|
280
|
+
assert_equal_filecontent( "expected/test_footnote_group.latex", text.to_doc(:latex))
|
281
|
+
#~ assert_equal_filecontent( "expected/test_footnote_group.wiki", text.to_doc(:wiki))
|
282
|
+
#~ assert_equal_filecontent( "expected/test_footnote_group.text", text.to_doc(:text))
|
283
|
+
end #test_footnote
|
284
|
+
end #Test_footnotes
|
285
|
+
|
286
|
+
class Test_tabular < Test::Unit::TestCase
|
287
|
+
def mk_tabular( columns, lines )
|
288
|
+
|
289
|
+
tab = element(:tabular, {
|
290
|
+
:columns => columns.size, #for HTML
|
291
|
+
:columndescription => 'c' * columns.size #for LaTeX
|
292
|
+
} ).CR
|
293
|
+
|
294
|
+
tab << row = element( :row, {:add_vspace=>'1ex'} ).cr
|
295
|
+
row << element(:multicolumn, {
|
296
|
+
:columns => columns.size,
|
297
|
+
:pos => 'c', #LaTeX
|
298
|
+
}, 'Titel over all columns' )
|
299
|
+
row.hline #Only LaTeX
|
300
|
+
tab << row = element( :row, {:add_vspace=>'1ex'} ).cr
|
301
|
+
row << multicol = element(:multicolumn, {
|
302
|
+
:pos => 'c', #LaTeX
|
303
|
+
}, 'SubTitel over all columns' )
|
304
|
+
multicol[:columns] <<columns.size
|
305
|
+
row.hline #Only LaTeX
|
306
|
+
|
307
|
+
lines.each{|line|
|
308
|
+
tab << row = element( :row ).cr
|
309
|
+
columns.each{|column|
|
310
|
+
row << element(:column, {}, "#{line}#{column}" )
|
311
|
+
}
|
312
|
+
}
|
313
|
+
return tab
|
314
|
+
end
|
315
|
+
def test_tabular()
|
316
|
+
text = mk_tabular( Array('A'..'D'), Array(1..5) )
|
317
|
+
assert_equal_filecontent( "expected/test_tabular.html", text.to_doc(:html))
|
318
|
+
#The line ends will be \\\\
|
319
|
+
#In usage in documents, it's converted into \\.
|
320
|
+
#
|
321
|
+
#~ doc = Document.new()
|
322
|
+
#~ doc.body << text.to_doc(:latex)
|
323
|
+
#~ doc.save('Test.tex') #\\ is ok
|
324
|
+
#
|
325
|
+
#~ $fixmes << "tabular/latex: tablines line 229 ../lib/docgenerator_tabular.rb#229"
|
326
|
+
assert_equal_filecontent( "expected/test_tabular.latex", text.to_doc(:latex))
|
327
|
+
assert_equal_filecontent( "expected/test_tabular.wiki", text.to_doc(:wiki))
|
328
|
+
$fixmes << "text-output for tables"
|
329
|
+
#~ assert_equal_filecontent( "expected/test_tabular.text", text.to_doc(:text))
|
330
|
+
end
|
331
|
+
def test_tabular_doc()
|
332
|
+
doc = Document.new()
|
333
|
+
doc.body << mk_tabular( Array('A'..'D'), Array(1..5) )
|
334
|
+
#~ doc.save('Test.tex', true) #\\ is ok
|
335
|
+
|
336
|
+
#~ doc.log.outputters = Log4r::StdoutOutputter.new('test_section')
|
337
|
+
#~ doc.log.level = Log4r::INFO
|
338
|
+
|
339
|
+
#~ assert_equal_filecontent( "expected/test_tabular_doc.html", text.to_doc(:html))
|
340
|
+
|
341
|
+
#The row ends in tabulars are \\.
|
342
|
+
#When used in documents, \\ is converted into \.
|
343
|
+
#So there is a special rule to double the \\ when used in combination with a filename.
|
344
|
+
assert_equal_filecontent( "expected/test_tabular_doc.latex", doc.to_doc(:latex,
|
345
|
+
{ :log => doc.log, :template=> DocumentTemplate[:article], :filename => 'test'}
|
346
|
+
) )
|
347
|
+
#~ assert_equal_filecontent( "expected/test_tabular_doc.wiki", text.to_doc(:wiki))
|
348
|
+
#~ assert_equal_filecontent( "expected/test_tabular_doc.text", text.to_doc(:text))
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
|
353
|
+
class Test_HTML < Test::Unit::TestCase
|
354
|
+
def test_html_css()
|
355
|
+
text = [
|
356
|
+
element(:div,{}, [ 'Block 1',
|
357
|
+
element(:span,{
|
358
|
+
:style => CSS.new(
|
359
|
+
:background_color => 'blue',
|
360
|
+
:color => 'red'
|
361
|
+
)
|
362
|
+
}, 'Zwischenblock' ),
|
363
|
+
'Ende Block 1',
|
364
|
+
]).cr
|
365
|
+
]
|
366
|
+
assert_equal_filecontent( "expected/test_html_css.html", text.to_doc(:html))
|
367
|
+
#~ assert_equal_filecontent( "expected/test_block.latex", text.to_doc(:latex))
|
368
|
+
#~ assert_equal_filecontent( "expected/test_block.wiki", text.to_doc(:wiki))
|
369
|
+
#~ assert_equal_filecontent( "expected/test_block.text", text.to_doc(:text))
|
370
|
+
end
|
371
|
+
def test_css()
|
372
|
+
css = CSS.new(
|
373
|
+
:color => 'red',
|
374
|
+
:background_color => 'blue'
|
375
|
+
)
|
376
|
+
assert_equal_filecontent( "expected/test_css.css", css.to_s)
|
377
|
+
css[:float] = 'right'
|
378
|
+
assert_equal_filecontent( "expected/test_css2.css", css.to_html)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
#~ class TestBeamer < Test::Unit::TestCase
|
382
|
+
#~ def test_beamer_note()
|
383
|
+
#~ text = element(:note,{}, 'Notiz').cr
|
384
|
+
|
385
|
+
#~ assert_equal_filecontent( "expected/test_beamer_note.html", text.to_doc(:html))
|
386
|
+
#~ assert_equal_filecontent( "expected/test_beamer_note.latex", text.to_doc(:latex))
|
387
|
+
#~ assert_equal_filecontent( "expected/test_beamer_note.wiki", text.to_doc(:wiki))
|
388
|
+
#~ assert_equal_filecontent( "expected/test_beamer_note.text", text.to_doc(:text))
|
389
|
+
|
390
|
+
#~ end
|
391
|
+
#~ end #TestBeamer
|
392
|
+
|
393
|
+
#
|
394
|
+
#Remark:
|
395
|
+
#- The <<prefix>> is replaced by Document.save.
|
396
|
+
#- With <<prefix>> we get always differences (timestamp)
|
397
|
+
class Test_document < Test::Unit::TestCase
|
398
|
+
def test_document()
|
399
|
+
doc = Document.new(
|
400
|
+
:title => 'Testdokument',
|
401
|
+
:keywords => 'Test',
|
402
|
+
:description => 'This is a test for a Document, generated by docgenerator.rb',
|
403
|
+
:author => 'docgenerator.rb',
|
404
|
+
:maketitle => true
|
405
|
+
)
|
406
|
+
doc.body << element(:p,{}, 'This is some content' )
|
407
|
+
#~ doc.save('test_document.html')
|
408
|
+
assert_instance_of( Log4r::Logger, doc.log)
|
409
|
+
assert_not_same( DOCGENERATOR_LOGGER, doc.log)
|
410
|
+
{
|
411
|
+
:html => :html,
|
412
|
+
:article => :latex,
|
413
|
+
:wiki => :wiki,
|
414
|
+
:text => :text,
|
415
|
+
}.each{|template, target|
|
416
|
+
filename = "test_document_#{template}.#{target}"
|
417
|
+
assert_equal_filecontent( "expected/#{filename}",
|
418
|
+
doc.to_doc(target, {
|
419
|
+
:template=> DocumentTemplate[template],
|
420
|
+
:filename => filename,
|
421
|
+
#~ :replacements => replacements,
|
422
|
+
:log => doc.log
|
423
|
+
}))
|
424
|
+
}
|
425
|
+
end
|
426
|
+
def test_doc_with_replacement()
|
427
|
+
doc = Document.new(
|
428
|
+
:title => 'Testdokument',
|
429
|
+
:keywords => 'Test',
|
430
|
+
:description => 'This is a test for a Document, generated by docgenerator.rb',
|
431
|
+
:author => 'docgenerator.rb',
|
432
|
+
:maketitle => true
|
433
|
+
)
|
434
|
+
doc.body << element(:p,{}, 'This is some content' )
|
435
|
+
#~ doc.save('test_document.html')
|
436
|
+
assert_instance_of( Log4r::Logger, doc.log)
|
437
|
+
assert_not_same( DOCGENERATOR_LOGGER, doc.log)
|
438
|
+
{
|
439
|
+
:html => :html,
|
440
|
+
:article => :latex,
|
441
|
+
:wiki => :wiki,
|
442
|
+
:text => :text,
|
443
|
+
}.each{|template, target|
|
444
|
+
filename = "test_document_replacement_#{template}.#{target}"
|
445
|
+
assert_equal_filecontent( "expected/#{filename}",
|
446
|
+
doc.to_doc(target, {
|
447
|
+
:template=> DocumentTemplate[template],
|
448
|
+
:filename => filename,
|
449
|
+
:replacements => {/This is some content/ => 'Etwas Inhalt' },
|
450
|
+
:log => doc.log
|
451
|
+
}))
|
452
|
+
}
|
453
|
+
end
|
454
|
+
end
|