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
@@ -0,0 +1,169 @@
|
|
1
|
+
#encoding: cp1252
|
2
|
+
=begin rdoc
|
3
|
+
Example how to define a structogramm with creole2doc.
|
4
|
+
=end
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
$:.unshift("../lib") #for local tests with uninstalled gem
|
8
|
+
require 'creole/creole2doc'
|
9
|
+
require 'creole/plugins/struktex.rb'
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'rake4latex_pdflatex'
|
13
|
+
rescue LoadError
|
14
|
+
puts "rake4latex not installed -> no translation of LaTeX-file"
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Move all results to another folder
|
19
|
+
#
|
20
|
+
Dir.chdir('results')
|
21
|
+
|
22
|
+
doc = Docgenerator::Document.new(
|
23
|
+
:title => 'creole/plugins/struktex.rb - Structogramms with Creole2Doc',
|
24
|
+
#~ :shorttitle => 'struktex.rb',
|
25
|
+
:author => 'Knut Lickert',
|
26
|
+
:maketitle => true
|
27
|
+
)
|
28
|
+
doc.head << Docgenerator::Packages::Struktex::USEPACKAGE_STRUKTEX
|
29
|
+
doc.head << Docgenerator::Packages::Struktex::USEPACKAGE_STRUKTEX_PROOF
|
30
|
+
|
31
|
+
|
32
|
+
#Redefinition to_latex for this documentation.
|
33
|
+
#Result is structogramm and sourcecode.
|
34
|
+
class Docgenerator::Packages::Struktex::Structogramm
|
35
|
+
alias :old_latex :to_latex
|
36
|
+
def to_latex(options={})
|
37
|
+
return [self.verbatim.to_latex, self.old_latex(options)].join
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
doc.body << (Docgenerator::Creole::Creole.new( :content => <<WIKI
|
43
|
+
=Preamble=
|
44
|
+
Code2Structgramm.rb translates a pseudo-code programm
|
45
|
+
to TeX-code for the \\StrukTeX-package.
|
46
|
+
\\StrukTeX\\ creates Nassi-Shneidermann-diagramms.
|
47
|
+
|
48
|
+
There is no support by this generator for:
|
49
|
+
*Interface description
|
50
|
+
*Variables and Keywords
|
51
|
+
*Comments
|
52
|
+
|
53
|
+
=Example=
|
54
|
+
An example, based on a German Saying
|
55
|
+
''Der Krug geht solange zum Brunnen bis er bricht''
|
56
|
+
<<<structogramm|Krug;120;45
|
57
|
+
WHILE Krug nicht zerbrochen
|
58
|
+
Krug geht zum Brunnen
|
59
|
+
ENDWHILE
|
60
|
+
Qualit�tspr�fung
|
61
|
+
-> Krug Testgut
|
62
|
+
<- res_1 Pr�fergebnis
|
63
|
+
IF Krug zerbrochen
|
64
|
+
THEN
|
65
|
+
Schade
|
66
|
+
ELSE
|
67
|
+
Stabiler Krug
|
68
|
+
ENDIF
|
69
|
+
>>>
|
70
|
+
|
71
|
+
=Statements=
|
72
|
+
No support for:
|
73
|
+
*Height
|
74
|
+
|
75
|
+
<<<structogramm|Simple Statements;120;30
|
76
|
+
Statement
|
77
|
+
=> Call procedure
|
78
|
+
<> Return value
|
79
|
+
<= Exit with return value
|
80
|
+
>>>
|
81
|
+
|
82
|
+
==Declarations==
|
83
|
+
With declarations you can define interfaces of sub-routines.
|
84
|
+
This declarations are part of the command
|
85
|
+
<<<structogramm|Declarations/Interfaces;120;25
|
86
|
+
Statement
|
87
|
+
-> field1 description
|
88
|
+
<- field2 description
|
89
|
+
<-> field3 description
|
90
|
+
>>>
|
91
|
+
|
92
|
+
==IF-Statement==
|
93
|
+
IF Condition
|
94
|
+
THEN size text
|
95
|
+
ELSE size text
|
96
|
+
ENDIF
|
97
|
+
<<<structogramm|Test f�r IF;120;40
|
98
|
+
IF Bedingung?
|
99
|
+
THEN 6 Ja
|
100
|
+
IF Andere Frage?
|
101
|
+
THEN
|
102
|
+
<= Ergebnis
|
103
|
+
ELSE
|
104
|
+
<= Anderes Ergebnis
|
105
|
+
ENDIF
|
106
|
+
ELSE 6 Nein
|
107
|
+
IF Andere Frage?
|
108
|
+
THEN 4
|
109
|
+
<= Ergebnis
|
110
|
+
ELSE 5
|
111
|
+
<= Anderes Ergebnis
|
112
|
+
ENDIF
|
113
|
+
ENDIF
|
114
|
+
>>>
|
115
|
+
|
116
|
+
==CASE-statements==
|
117
|
+
The first number after CASE defines the degree of the case-line.
|
118
|
+
|
119
|
+
The WHEN clause has an optional parameter:
|
120
|
+
*c centered
|
121
|
+
*r right-aligned
|
122
|
+
<<<structogramm|CASE Statements;120;40
|
123
|
+
CASE 5 variable
|
124
|
+
WHEN value1
|
125
|
+
Statement 1-1
|
126
|
+
Statement 1-2
|
127
|
+
WHEN[r] value2
|
128
|
+
Statement 2-1
|
129
|
+
Statement 2-2
|
130
|
+
WHEN[c] value3
|
131
|
+
Statement 3-1
|
132
|
+
Statement 3-2
|
133
|
+
WHEN value4
|
134
|
+
Statement 4-1
|
135
|
+
Statement 4-2
|
136
|
+
ENDCASE
|
137
|
+
>>>
|
138
|
+
==While-statements==
|
139
|
+
<<<structogramm|While Statements;120;15
|
140
|
+
WHILE Condition
|
141
|
+
Statement
|
142
|
+
ENDWHILE
|
143
|
+
>>>
|
144
|
+
|
145
|
+
==Repeat-Until-statements==
|
146
|
+
<<<structogramm|Repeat-Until Statements;120;15
|
147
|
+
REPEAT
|
148
|
+
Statement
|
149
|
+
UNTIL Condition
|
150
|
+
>>>
|
151
|
+
|
152
|
+
==FOREVER-Loop-statements==
|
153
|
+
<<<structogramm|FOREVER-Loop Statements;120;30
|
154
|
+
FOREVER
|
155
|
+
Statement
|
156
|
+
<= Exit
|
157
|
+
ENDFOREVER
|
158
|
+
>>>
|
159
|
+
|
160
|
+
WIKI
|
161
|
+
))
|
162
|
+
|
163
|
+
# ###############################
|
164
|
+
# Save the files
|
165
|
+
# ###############
|
166
|
+
#~ doc.save( __FILE__.sub(/\.rb/, ".html")) #makes no sense
|
167
|
+
doc.save( __FILE__.sub(/\.rb/, ".tex"),
|
168
|
+
:runtex => [:statistic, :clean]
|
169
|
+
)
|
@@ -19,12 +19,12 @@ Dir.chdir('results')
|
|
19
19
|
#
|
20
20
|
#Set level of gloabl error messages.
|
21
21
|
#
|
22
|
-
DOCGENERATOR_LOGGER.level = Log4r::WARN
|
22
|
+
Docgenerator::DOCGENERATOR_LOGGER.level = Log4r::WARN
|
23
23
|
|
24
24
|
#
|
25
25
|
# Create a document
|
26
26
|
#
|
27
|
-
doc = Document.new(
|
27
|
+
doc = Docgenerator::Document.new(
|
28
28
|
:title => 'Testdocument with tripfalls'
|
29
29
|
)
|
30
30
|
#~ doc.log.level = Log4r::WARN
|
data/examples/results/readme
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
Target folder for test examples
|
1
|
+
Target folder for test examples.
|
2
|
+
|
@@ -1,32 +1,62 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
#~ require '20070622_wiki2docgenerator' if ! defined? Wikitext
|
1
|
+
#encoding: cp1252
|
2
|
+
=begin rdoc
|
3
|
+
Example for wiki2doc/wiki2docgenerator
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
==Obsolete!!
|
6
|
+
There is no support for the wikimedia-syntax in docgenerator.
|
8
7
|
|
9
|
-
|
8
|
+
Please use creole/creole2doc.
|
9
|
+
=end
|
10
|
+
require 'rubygems'
|
11
|
+
$:.unshift("../lib") #for local tests with uninstalled gem
|
12
|
+
#~ require 'docgenerator'
|
13
|
+
require 'wiki2doc/wiki2docgenerator' if ! defined? Wikitext
|
14
|
+
begin
|
15
|
+
require 'rake4latex_pdflatex'
|
16
|
+
rescue LoadError
|
17
|
+
puts "rake4latex not installed -> no translation of LaTeX-file"
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Move all results to anothe folder
|
22
|
+
#
|
23
|
+
Dir.chdir('results')
|
24
|
+
|
25
|
+
=begin
|
26
|
+
Define the wiki-container
|
27
|
+
=end
|
28
|
+
wiki = Docgenerator::Wikimedia::Wikitext.new( :parsetext => true )
|
10
29
|
wiki << DATA#.readlines.to_s
|
11
|
-
#~ wiki << %q|
|
12
|
-
#~ |
|
13
30
|
|
14
|
-
|
15
|
-
|
31
|
+
|
32
|
+
=begin
|
33
|
+
Create document
|
34
|
+
=end
|
35
|
+
doc = Docgenerator::Document.new(
|
36
|
+
:title => 'wiki2docgenerator_example.rb: Test for wiki2docgenerator'
|
37
|
+
)
|
38
|
+
|
39
|
+
|
16
40
|
#For TeX you can use element(:tableofcontent),
|
17
41
|
#in HTML you can use element( :toc, :h3) in combination with sitegenerator
|
18
|
-
doc.body << wiki.toc( #include the toc
|
19
|
-
:listtype => :ul,
|
20
|
-
:level => 2,
|
21
|
-
:startlevel => 1,
|
22
|
-
:addlinks => false
|
23
|
-
)
|
42
|
+
#~ doc.body << wiki.toc( #include the toc
|
43
|
+
#~ :listtype => :ul,
|
44
|
+
#~ :level => 2,
|
45
|
+
#~ :startlevel => 1,
|
46
|
+
#~ :addlinks => false
|
47
|
+
#~ )
|
48
|
+
|
24
49
|
doc.body << wiki
|
25
|
-
doc.body << wiki.footnotes #include the footnotes
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
50
|
+
doc.body << wiki.footnotes #include the footnotes (only html)
|
51
|
+
|
52
|
+
# ###############################
|
53
|
+
# Save the files
|
54
|
+
# ###############
|
55
|
+
doc.save( __FILE__.sub(/\.rb/, ".html"))
|
56
|
+
doc.save( __FILE__.sub(/\.rb/, ".tex"),
|
57
|
+
:runtex => [:statistic, :clean]
|
58
|
+
)
|
59
|
+
|
30
60
|
|
31
61
|
__END__
|
32
62
|
==Wiki2docgenerator.rb==
|
@@ -48,10 +78,10 @@ Example-Programm:
|
|
48
78
|
doc.body << wiki.toc #include the table of content
|
49
79
|
doc.body << wiki.to_element
|
50
80
|
doc.body << wiki.footnotes #include the footnotes
|
51
|
-
doc.save('test.html'
|
52
|
-
doc.save('test.wiki'
|
53
|
-
doc.save('test.txt'
|
54
|
-
doc.save('test.tex'
|
81
|
+
doc.save('test.html')
|
82
|
+
doc.save('test.wiki')
|
83
|
+
doc.save('test.txt')
|
84
|
+
doc.save('test.tex')
|
55
85
|
|
56
86
|
==Titel 1==
|
57
87
|
===Titel 2===
|
@@ -95,7 +125,7 @@ text in neuem Absatz
|
|
95
125
|
===Wilde Mischung Punkte- und Nummerierte Liste nacheinander===
|
96
126
|
*list (*)
|
97
127
|
**list (**)
|
98
|
-
#*list (
|
128
|
+
#*list (\#*) Hier Wechsel auf erster Ebene
|
99
129
|
|
100
130
|
===Definitionsliste ===
|
101
131
|
;Definitionsliste
|
@@ -178,7 +208,7 @@ Besonderheiten:
|
|
178
208
|
==Tabellen==
|
179
209
|
Die Syntax:
|
180
210
|
*{| beginnt eine Tabelle. Hier k�nnen zus�tzliche Formatierungseigenschaften kommen.
|
181
|
-
**Zumindest columns
|
211
|
+
**Zumindest columns==?? sollte gesetzt sein
|
182
212
|
*! beginnt eine neue Zelle einer Titelzeile
|
183
213
|
*| beginnt eine neue Zelle
|
184
214
|
*|| trennt zwei Zellen (nicht unterst�tzt)
|
@@ -193,7 +223,7 @@ Die Syntax:
|
|
193
223
|
*|} beendet eine Tabelle
|
194
224
|
|
195
225
|
Beispiel 1:
|
196
|
-
{|columns=2
|
226
|
+
{|columns=2|columndescription=cc
|
197
227
|
|Zelle 1
|
198
228
|
|Zelle 2
|
199
229
|
|-
|
@@ -205,9 +235,9 @@ Beispiel 1:
|
|
205
235
|
|}
|
206
236
|
|
207
237
|
Beispiel 2:
|
208
|
-
{| border=1|columns=6
|
238
|
+
{| border=1|columns=6|columndescription=cccccc
|
209
239
|
|Zelle 1
|
210
|
-
|colspan=5|text-align=center| Zelle 2 �ber
|
240
|
+
|colspan=5|text-align=center| Zelle 2 �ber f�nf Spalten
|
211
241
|
|-
|
212
242
|
|Zelle 3
|
213
243
|
|Zelle 4
|
@@ -259,7 +289,6 @@ Mit
|
|
259
289
|
<<<
|
260
290
|
wird eine externe Aufbereitung gerufen.
|
261
291
|
key wird von WikiCollector genutzt um den Aufbereiter (Klasse) zu rufen.
|
262
|
-
Der Aufbereiter muss die Methoden << und to_element unterst�tzen.
|
263
292
|
|
264
293
|
html ist bereits definiert und erlaubt die Verwednung von Original-Htlm
|
265
294
|
|
data/lib/creole/creole2doc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#encoding: cp1252
|
2
2
|
=begin rdoc
|
3
3
|
This is a Creole-to-Docgenerator converter.
|
4
4
|
The Docgenerator-data can be exported as
|
@@ -14,16 +14,17 @@ https://rubyforge.org/projects/wikicreole/
|
|
14
14
|
More about creole at http://www.wikicreole.org/
|
15
15
|
=end
|
16
16
|
|
17
|
-
|
18
|
-
VERSION = '1.2.1'
|
19
|
-
end
|
20
|
-
#~ $:.unshift("../") #for test purposes.
|
21
|
-
#Load the same version of docgenerator
|
17
|
+
$:.unshift("..") if $0 == __FILE__ #for test purposes.
|
22
18
|
require 'docgenerator'
|
23
|
-
if Creole::VERSION != Docgenerator::VERSION
|
24
|
-
raise LoadError, "Creole V#{Creole::VERSION} needs Docgenerator #{Creole::VERSION}, but gets #{Docgenerator::VERSION}"
|
25
|
-
end
|
26
19
|
|
20
|
+
module Docgenerator
|
21
|
+
|
22
|
+
=begin rdoc
|
23
|
+
Collect the classes to handle Creole-input.
|
24
|
+
|
25
|
+
More about creole at http://www.wikicreole.org/
|
26
|
+
=end
|
27
|
+
module Creole
|
27
28
|
|
28
29
|
=begin rdoc
|
29
30
|
Some class definitions for the Creole-class.
|
@@ -32,17 +33,6 @@ class Creole
|
|
32
33
|
|
33
34
|
#Little structure to store the parsing result.
|
34
35
|
Creole_line = Struct.new('Creole_line', :type, :content, :add_info)
|
35
|
-
#Define Placeholders
|
36
|
-
#Placeholders are used via <<<...>>>
|
37
|
-
#Default: Creole_dummy_placeholder (set in class definition Creole_dummy_placeholder)
|
38
|
-
Placeholders = Hash.new()
|
39
|
-
#Define Inclusions
|
40
|
-
#Inclusions are used via {{...}}
|
41
|
-
#Default: Creole_inclusion_img (defined in class definition Creole_inclusion_img)
|
42
|
-
Inclusions = Hash.new()
|
43
|
-
#Define Plugins
|
44
|
-
#Plugins are used via <<...>>
|
45
|
-
Plugins = Hash.new()
|
46
36
|
|
47
37
|
#Hash with Characters.
|
48
38
|
#This characters will be converted into elements.
|
@@ -55,13 +45,13 @@ class Creole
|
|
55
45
|
'<-' => element(:leftarrow),
|
56
46
|
'<=' => element(:Leftarrow),
|
57
47
|
'_' => element(:underscore),
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
61
|
-
'
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'
|
48
|
+
'�' => element(:ldots),
|
49
|
+
'�' => element(:sbquo), # einfaches low-9-Zeichen, U+201A , ‚
|
50
|
+
'�' => element(:rsquo), #'zu ’
|
51
|
+
'�' => element(:bdquo), #"auf „
|
52
|
+
'�' => element(:ldquo), #"zu “
|
53
|
+
'�' => element(:ndash), # –
|
54
|
+
'�' => element(:mdash), # –
|
65
55
|
}
|
66
56
|
|
67
57
|
=begin rdoc
|
@@ -164,7 +154,7 @@ end #Creole
|
|
164
154
|
require_relative 'creole_placeholder.rb'
|
165
155
|
require_relative 'creole_tabular.rb'
|
166
156
|
require_relative 'creole_inclusion_and_plugins.rb'
|
167
|
-
begin require 'privat/creole_affiliate.rb'; rescue LoadError; end #Just some privat extension
|
157
|
+
#~ begin require 'privat/creole_affiliate.rb'; rescue LoadError; end #Just some privat extension
|
168
158
|
|
169
159
|
require 'log4r'
|
170
160
|
|
@@ -178,7 +168,6 @@ multiple HTML (corresponding to pages).
|
|
178
168
|
HTML-pagebreak could be forced with ======== or something similar.
|
179
169
|
=end
|
180
170
|
class Creole_document
|
181
|
-
include Docgenerator #get VERSION
|
182
171
|
|
183
172
|
=begin rdoc
|
184
173
|
Define a creole document. The settings are forwarded to Document#new()
|
@@ -261,7 +250,8 @@ Example:
|
|
261
250
|
=Test document
|
262
251
|
This is a little test text with **bold** and //italic// text.
|
263
252
|
txt
|
264
|
-
|
253
|
+
wiki.to_latex()
|
254
|
+
|
265
255
|
Often I use it in combination with "Here"-Documents with __END__:
|
266
256
|
|
267
257
|
require 'creole/creole2doc'
|
@@ -305,9 +295,9 @@ Options:
|
|
305
295
|
:ignore => nil, #Define a "local" comment, e.g /^#~.*$/
|
306
296
|
:encoding => __ENCODING__,
|
307
297
|
}.update(options)
|
308
|
-
@placeholders = Placeholders.dup
|
309
|
-
@inclusions = Inclusions.dup
|
310
|
-
@plugins = Plugins.dup
|
298
|
+
@placeholders = Placeholders::Collection.dup
|
299
|
+
@inclusions = Inclusions::Collection.dup
|
300
|
+
@plugins = Plugins::Collection.dup
|
311
301
|
|
312
302
|
#Store the given source text
|
313
303
|
@source = []
|
@@ -316,12 +306,13 @@ Options:
|
|
316
306
|
@toc = [] #Collection of all heading lines
|
317
307
|
@footnotegroups = {} #Collection of footnote groups
|
318
308
|
|
319
|
-
|
320
309
|
@targetdir = @options[:targetdir] if @options[:targetdir]
|
310
|
+
|
321
311
|
@log = @options[:log]
|
322
312
|
@log = Log4r::Logger.new(@options[:name], Log4r::INFO) unless @log
|
323
313
|
@log.outputters = Log4r::StdoutOutputter.new('log_stdout') if @log.outputters.empty?
|
324
314
|
|
315
|
+
@creation_caller = caller.first
|
325
316
|
self << @options[:content] if @options[:content]
|
326
317
|
end
|
327
318
|
|
@@ -479,7 +470,7 @@ Parse the given creole code and build a "normalized source"
|
|
479
470
|
normsource << Creole_line.new(:placeholder,
|
480
471
|
@placeholders['creole_tabular'].new(self),
|
481
472
|
:start => lineno
|
482
|
-
) unless normsource.last.content.is_a?(
|
473
|
+
) unless normsource.last.content.is_a?(Creole_tab)
|
483
474
|
normsource.last.content << line
|
484
475
|
#http://www.wikicreole.org/wiki/PreformattedAndNowiki
|
485
476
|
when /^\{\{\{\s*$/ #Kind of verbatim
|
@@ -489,7 +480,7 @@ Parse the given creole code and build a "normalized source"
|
|
489
480
|
when /^<<<(.*)/
|
490
481
|
ph, par = $1.split(/\|/,2)
|
491
482
|
placeholder = @placeholders[ph].new(self, par)
|
492
|
-
if placeholder.
|
483
|
+
if placeholder.instance_of?(Placeholders::Dummy)
|
493
484
|
@log.warn("Unknown placeholder #{ph.inspect} used in line #{lineno}" ) if @log.warn?
|
494
485
|
end
|
495
486
|
normsource << Creole_line.new(:placeholder, placeholder, :start => lineno )
|
@@ -529,7 +520,7 @@ Parse the given creole code and build a "normalized source"
|
|
529
520
|
#
|
530
521
|
|
531
522
|
=begin rdoc
|
532
|
-
Return a table of contents as a list
|
523
|
+
Return a table of contents as a list.
|
533
524
|
=end
|
534
525
|
def toc( i_options = {})
|
535
526
|
options = {
|
@@ -571,6 +562,10 @@ Return a table of contents as a list
|
|
571
562
|
elsif level < toclabel.size
|
572
563
|
toclabel.pop
|
573
564
|
end
|
565
|
+
if ! toclabel[level-1]
|
566
|
+
@log.fatal("toclevel error: #{__FILE__}##{__LINE__}")
|
567
|
+
return nil
|
568
|
+
end
|
574
569
|
toclabel[level-1] = toclabel[level-1] + 1
|
575
570
|
|
576
571
|
#Check if there was already a label.
|
@@ -650,7 +645,6 @@ Used by
|
|
650
645
|
}, line.content ).cr
|
651
646
|
#~ }, inline(line.content, options ) ).cr
|
652
647
|
when :list
|
653
|
-
#~ puts line[:add_info].inspect
|
654
648
|
key = line.add_info[:listtype]
|
655
649
|
if ! elements[key]
|
656
650
|
case key[-1,1]
|
@@ -771,7 +765,7 @@ Options is a Hash and may contain:
|
|
771
765
|
else #internal link
|
772
766
|
#This is normally the wiki-links.
|
773
767
|
#But this is no wiki, it's a documentgenerator with wiki syntax.
|
774
|
-
options[:log].warn("Unclear link <#{el}>") if options[:log].warn?
|
768
|
+
options[:log].warn("Unclear link <#{el}> #{self.inspect}") if options[:log].warn?
|
775
769
|
link = link
|
776
770
|
end
|
777
771
|
if link == linktext #Avoid replacement of // inside linktext
|
@@ -832,7 +826,7 @@ Options is a Hash and may contain:
|
|
832
826
|
else #text to add
|
833
827
|
#Replace characters.
|
834
828
|
if CHARACTERS[el]
|
835
|
-
insertion = CHARACTERS[el]
|
829
|
+
insertion = CHARACTERS[el]
|
836
830
|
startspace = endspace = nil
|
837
831
|
else
|
838
832
|
startspace = ( el[0,1] =~ /\s/ )
|
@@ -871,7 +865,8 @@ The last paramter contains a hash with the supported inclusions/plugins.
|
|
871
865
|
|
872
866
|
inclusion = inclusions[link]
|
873
867
|
#check inclusion.ancestors?
|
874
|
-
if inclusion.superclass != Creole_inclusion_and_plugin
|
868
|
+
#~ if inclusion.superclass != Creole_inclusion_and_plugin
|
869
|
+
if inclusion.is_a?(Creole_inclusion_and_plugin)
|
875
870
|
@log.error( "Wrong inclusion/plugin definition for #{link} (#{inclusion.inspect}, expected #{inclusions.default.superclass})") if @log.error?
|
876
871
|
return nil
|
877
872
|
end
|
@@ -898,28 +893,32 @@ Relative pathes are searched from @options[:targetdir] (default '.').
|
|
898
893
|
fpath = File.expand_path("#{Dir.pwd}/#{path}")
|
899
894
|
log.debug("Reference not found: <#{fpath}>") if log.debug?
|
900
895
|
end
|
901
|
-
end #check_link_existence
|
896
|
+
end #check_link_existence
|
897
|
+
|
898
|
+
def inspect()
|
899
|
+
"<#{self.class} (created #{@creation_caller})>"
|
900
|
+
end
|
902
901
|
end #Creole
|
902
|
+
end #module Creole
|
903
|
+
end #module Docgenerator
|
904
|
+
|
903
905
|
|
904
906
|
if [__FILE__ ].include?($0)
|
905
907
|
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
#~ puts `call "../../unittest/unittest_creole2doc.rb"`
|
920
|
-
#~ require 'quicktest'
|
908
|
+
[
|
909
|
+
:syntax,
|
910
|
+
:creole,
|
911
|
+
:wikimedia,
|
912
|
+
:trippfall,
|
913
|
+
:headings,
|
914
|
+
:links,
|
915
|
+
].each{|key|
|
916
|
+
puts '='*50
|
917
|
+
puts Docgenerator::Creole::Creole.help(key)
|
918
|
+
puts '='*50
|
919
|
+
}
|
921
920
|
|
922
|
-
creole = Creole.new
|
921
|
+
creole = Docgenerator::Creole::Creole.new
|
923
922
|
creole << 'x{{-}}y{{-}}z'
|
924
923
|
creole << 'x{{shy}}y{{shy}}z'
|
925
924
|
creole << ''
|