docgenerator 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,136 @@
|
|
|
1
|
+
=begin rdoc
|
|
2
|
+
Little helper to make documention on ruby scripts,
|
|
3
|
+
Ruby fragments are defined in the creole-source,
|
|
4
|
+
You can get the code and the results.
|
|
5
|
+
|
|
6
|
+
The source code is enriched with the results and can be shown.
|
|
7
|
+
=end
|
|
8
|
+
|
|
9
|
+
#Only for quick tests
|
|
10
|
+
$:.unshift("../../") if $0 == __FILE__
|
|
11
|
+
|
|
12
|
+
#~ fixme: use listings instead verbatim
|
|
13
|
+
#~ check usage??
|
|
14
|
+
|
|
15
|
+
require 'creole/creole2doc'
|
|
16
|
+
require 'docgenerator/packages/rubycode4doc'
|
|
17
|
+
|
|
18
|
+
module Docgenerator
|
|
19
|
+
module Creole
|
|
20
|
+
|
|
21
|
+
=begin rdoc
|
|
22
|
+
Write rubycode inside creole-text
|
|
23
|
+
=end
|
|
24
|
+
module Rubycode
|
|
25
|
+
|
|
26
|
+
=begin rdoc
|
|
27
|
+
Print ruby source code as is
|
|
28
|
+
=end
|
|
29
|
+
class Code < Placeholder
|
|
30
|
+
set_placeholder_key 'rubycode'
|
|
31
|
+
#Return content in a verbatim environment
|
|
32
|
+
def to_doc( target, options = {})
|
|
33
|
+
codetest = Docgenerator::Rubycode::CodeTest.new(nil, @source.join )
|
|
34
|
+
#~ element(:verbatim,{},@source ).cr.to_doc( target, options )
|
|
35
|
+
element(:verbatim, {
|
|
36
|
+
:style => 'rubycode',
|
|
37
|
+
}, codetest.sourcecode ).cr.to_doc( target, options )
|
|
38
|
+
end
|
|
39
|
+
end #Code
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
#Print ruby source code and put the result of each line as a comment.
|
|
43
|
+
#
|
|
44
|
+
#Example:
|
|
45
|
+
# 1 + 1
|
|
46
|
+
#becomes
|
|
47
|
+
# 1 + 1 #2
|
|
48
|
+
class Code_evaluated < Placeholder
|
|
49
|
+
set_placeholder_key 'rubycode_evaluated'
|
|
50
|
+
#Return content in a verbatim environment
|
|
51
|
+
def to_doc( target, options = {})
|
|
52
|
+
codetest = Docgenerator::Rubycode::CodeTest.new(nil, @source.join )
|
|
53
|
+
#~ element(:verbatim,{},@source ).cr.to_doc( target, options )
|
|
54
|
+
element(:verbatim, {
|
|
55
|
+
:style => 'rubycode_evaluated',
|
|
56
|
+
}, codetest.code_evaluation ).cr.to_doc( target, options )
|
|
57
|
+
end
|
|
58
|
+
end #Code_evaluated
|
|
59
|
+
|
|
60
|
+
#
|
|
61
|
+
#Print ruby source code and put the result of each line as a comment.
|
|
62
|
+
#
|
|
63
|
+
#Same as Code_evaluated, but export is done for in TeX-Package listings.
|
|
64
|
+
class Code_evaluated_listings < Placeholder
|
|
65
|
+
set_placeholder_key 'rubycode_evaluated_listings'
|
|
66
|
+
#Return content in a verbatim environment
|
|
67
|
+
def to_doc( target, options = {})
|
|
68
|
+
codetest = Docgenerator::Rubycode::CodeTest.new(nil, @source.join )
|
|
69
|
+
#~ element(:verbatim, {
|
|
70
|
+
#~ :style => 'rubycode_evaluated',
|
|
71
|
+
#~ }, codetest.code_evaluation ).cr.to_doc( target, options )
|
|
72
|
+
codetest.code_evaluation_lstlisting.to_doc( target, options )
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end #Code_evaluated_listing
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
#Take only the output of the rubycode
|
|
79
|
+
#
|
|
80
|
+
class Code_output < Placeholder
|
|
81
|
+
set_placeholder_key 'rubycode_output'
|
|
82
|
+
#Return content in a verbatim environment
|
|
83
|
+
def to_doc( target, options = {})
|
|
84
|
+
codetest = Docgenerator::Rubycode::CodeTest.new(nil, @source.join )
|
|
85
|
+
#~ element(:verbatim,{},@source ).cr.to_doc( target, options )
|
|
86
|
+
element(:verbatim, {
|
|
87
|
+
:style => 'rubycode_output',
|
|
88
|
+
}, codetest.output ).cr.to_doc( target, options )
|
|
89
|
+
end
|
|
90
|
+
end #Code_output
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
#Build a table.
|
|
94
|
+
#Each row corresponds with a source code line.
|
|
95
|
+
#You get source code, result and output of the code line.
|
|
96
|
+
#
|
|
97
|
+
#
|
|
98
|
+
class Code_in_tab < Placeholder
|
|
99
|
+
set_placeholder_key 'rubycode_in_tab'
|
|
100
|
+
#Return content in a verbatim environment
|
|
101
|
+
def to_doc( target, options = {})
|
|
102
|
+
codetest = Docgenerator::Rubycode::CodeTest.new(nil, @source.join )
|
|
103
|
+
codetest.code_in_tab.to_doc( target, options )
|
|
104
|
+
end
|
|
105
|
+
end #Code_in_tab
|
|
106
|
+
end #module Rubycode
|
|
107
|
+
end #module Creole
|
|
108
|
+
end #module Docgenerator
|
|
109
|
+
|
|
110
|
+
if $0 == __FILE__
|
|
111
|
+
wiki = Docgenerator::Creole::Creole.new()
|
|
112
|
+
wiki << <<wiki
|
|
113
|
+
rubycode
|
|
114
|
+
<<<rubycode
|
|
115
|
+
1 + 1
|
|
116
|
+
>>>
|
|
117
|
+
----
|
|
118
|
+
rubycode_output
|
|
119
|
+
<<<rubycode_output
|
|
120
|
+
puts 1 + 1
|
|
121
|
+
>>>
|
|
122
|
+
----
|
|
123
|
+
rubycode_evaluated
|
|
124
|
+
<<<rubycode_evaluated
|
|
125
|
+
1 + 1
|
|
126
|
+
>>>
|
|
127
|
+
----
|
|
128
|
+
rubycode_in_tab
|
|
129
|
+
<<<rubycode_in_tab
|
|
130
|
+
1 + 1
|
|
131
|
+
>>>
|
|
132
|
+
wiki
|
|
133
|
+
puts wiki.to_html
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
__END__
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
=begin rdoc
|
|
2
|
+
Add support of Struktex::Structogramm for Creole.
|
|
3
|
+
=end
|
|
4
|
+
require 'creole/creole2doc'
|
|
5
|
+
require 'docgenerator/packages/struktex.rb'
|
|
6
|
+
|
|
7
|
+
module Docgenerator
|
|
8
|
+
module Creole
|
|
9
|
+
|
|
10
|
+
=begin rdoc
|
|
11
|
+
Define Creole placeholder.
|
|
12
|
+
|
|
13
|
+
The placeholder insertion must contain three parameters:
|
|
14
|
+
|
|
15
|
+
>>>structogramm{Declarations/Interfaces;120;25}
|
|
16
|
+
Statement
|
|
17
|
+
-> field1 description
|
|
18
|
+
<- field2 description
|
|
19
|
+
<-> field3 description
|
|
20
|
+
<<<
|
|
21
|
+
Details see Docgenerator::Structogramm
|
|
22
|
+
=end
|
|
23
|
+
class Creole_structogramm < Placeholder
|
|
24
|
+
set_placeholder_key('structogramm')
|
|
25
|
+
|
|
26
|
+
#~ fixme
|
|
27
|
+
#~ parameters optional als placeholder,
|
|
28
|
+
#~ hier aber ben�tigt.
|
|
29
|
+
#~ Defaults??
|
|
30
|
+
|
|
31
|
+
def initialize( wiki, parameters = nil)
|
|
32
|
+
super
|
|
33
|
+
#~ @wiki = wiki
|
|
34
|
+
#~ @log = @wiki.log
|
|
35
|
+
par = parameters ? parameters.split(/;/) : []
|
|
36
|
+
case par.size
|
|
37
|
+
when 0
|
|
38
|
+
raise ParameterError, "Creole_structogramm: Missing parameters"
|
|
39
|
+
when 3
|
|
40
|
+
title = par[0]
|
|
41
|
+
x = par[1]
|
|
42
|
+
y = par[2]
|
|
43
|
+
@source = ''
|
|
44
|
+
@structogramm = Packages::Struktex::Structogramm.new( title, x, y, @source )
|
|
45
|
+
else
|
|
46
|
+
raise ParameterError, "Creole_structogramm: Wrong number of parameters: #{parameters.inspect}"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
#Instance of class Structogramm.
|
|
50
|
+
attr_reader :structogramm
|
|
51
|
+
|
|
52
|
+
#Return content only for latex
|
|
53
|
+
def to_doc( target, options = {})
|
|
54
|
+
target == :latex ? @structogramm.to_doc( target, options ) : ''
|
|
55
|
+
end
|
|
56
|
+
end #Creole_latex
|
|
57
|
+
|
|
58
|
+
end #module Creole
|
|
59
|
+
end #module Docgenerator
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'docgenerator/packages/todonotes.rb'
|
|
2
|
+
|
|
3
|
+
module Docgenerator
|
|
4
|
+
module Creole
|
|
5
|
+
|
|
6
|
+
=begin rdoc
|
|
7
|
+
Classes to provide support for the todonotes-package.
|
|
8
|
+
|
|
9
|
+
* http://ctan.org/tex-archive/macros/latex/contrib/todonotes/
|
|
10
|
+
=end
|
|
11
|
+
module Todo
|
|
12
|
+
|
|
13
|
+
=begin rdoc
|
|
14
|
+
Define a plugin for the todonotes-package.
|
|
15
|
+
=end
|
|
16
|
+
class Creole_todo < Creole_inclusion_and_plugin
|
|
17
|
+
|
|
18
|
+
set_plugin_key('todo') #use <<todo|..>>
|
|
19
|
+
|
|
20
|
+
#define default options for todonotes. may be redefined for children of this class.
|
|
21
|
+
def default_options; {}; end
|
|
22
|
+
|
|
23
|
+
=begin rdoc
|
|
24
|
+
Usage:
|
|
25
|
+
<<todo|what to do|color=red>>
|
|
26
|
+
=end
|
|
27
|
+
def initialize( inclusionname, description, options, wiki )
|
|
28
|
+
#~ @inclusionname = inclusionname #fix 'todo'
|
|
29
|
+
@description = description
|
|
30
|
+
@options = default_options.dup
|
|
31
|
+
options.each{|opt|
|
|
32
|
+
case opt
|
|
33
|
+
when /color\s*=\s*/
|
|
34
|
+
@options[:color] = $~.post_match
|
|
35
|
+
when /inline/
|
|
36
|
+
@options[:inline] = true
|
|
37
|
+
else
|
|
38
|
+
wiki.log.warn("Todo #{@description} with undefined option #{opt}")
|
|
39
|
+
end
|
|
40
|
+
}
|
|
41
|
+
@wiki = wiki
|
|
42
|
+
|
|
43
|
+
raise "Inclusion received no wiki but #{wiki.inspect}" unless wiki.is_a?(Creole)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_doc(target, options = {})
|
|
47
|
+
element(:todo, @options, @description).to_doc(target, options)
|
|
48
|
+
end
|
|
49
|
+
end #Creole_todo
|
|
50
|
+
=begin rdoc
|
|
51
|
+
A variant of Creole_todo with green color.
|
|
52
|
+
=end
|
|
53
|
+
class Creole_todo_green < Creole_todo
|
|
54
|
+
set_plugin_key('todo_green') #use <<todo_green|..>>
|
|
55
|
+
#define default options for todonotes. may be redefined for children of this class.
|
|
56
|
+
def default_options; {:color => 'green'}; end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
=begin rdoc
|
|
60
|
+
A variant of Creole_todo with inline-layout.
|
|
61
|
+
=end
|
|
62
|
+
class Creole_todo_inline < Creole_todo
|
|
63
|
+
set_plugin_key('todo_inline') #use <<todo_inline|..>>
|
|
64
|
+
#define default options for todonotes. may be redefined for children of this class.
|
|
65
|
+
def default_options; {:layout => 'green'}; end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end #module Todo
|
|
69
|
+
end #module Creole
|
|
70
|
+
end #module Docgenerator
|
data/lib/docgenerator.rb
CHANGED
|
@@ -10,8 +10,10 @@ The document generation is build via 'Elements',
|
|
|
10
10
|
the target format is generic, actual supported are:
|
|
11
11
|
-LaTeX
|
|
12
12
|
-HTML
|
|
13
|
-
Plain text and
|
|
14
|
-
|
|
13
|
+
Plain text and two Wiki-version exist also (Wikimedia and Creole),
|
|
14
|
+
but they are not well maintained.
|
|
15
|
+
A context-export is planned for the future
|
|
16
|
+
(but it has a low level-importance for me).
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
==Wiki
|
|
@@ -69,33 +71,62 @@ More at http://ruby.lickert.net/docgenerator/index.html
|
|
|
69
71
|
#
|
|
70
72
|
#For quick test
|
|
71
73
|
#
|
|
72
|
-
if $0 == __FILE__ and RUBY_VERSION
|
|
73
|
-
$:.unshift('
|
|
74
|
+
if $0 == __FILE__ and RUBY_VERSION =~ /1.9/
|
|
75
|
+
$:.unshift('.')
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
=begin rdoc
|
|
79
|
-
|
|
80
|
-
This module should be included by all classes.
|
|
81
|
+
All classes of this gem are encapsulated in module Docgenerator.
|
|
81
82
|
=end
|
|
82
|
-
module Docgenerator
|
|
83
|
+
module Docgenerator
|
|
83
84
|
#Define Version number
|
|
84
|
-
VERSION = '
|
|
85
|
-
|
|
85
|
+
VERSION = '2.0.0'
|
|
86
|
+
class << self
|
|
87
|
+
@trace = nil
|
|
88
|
+
=begin rdoc
|
|
89
|
+
Set tracing on.
|
|
90
|
+
|
|
91
|
+
Often there is the problem, that you get an error
|
|
92
|
+
when you write the element (Element#to_doc).
|
|
93
|
+
|
|
94
|
+
But to correct the error, you need the location of
|
|
95
|
+
element creation, not usage.
|
|
96
|
+
|
|
97
|
+
With Docgenerator.trace_on this tracing information is
|
|
98
|
+
stored during element creation.
|
|
99
|
+
=end
|
|
100
|
+
def trace_on; @trace = true; end
|
|
101
|
+
#Set tracing off
|
|
102
|
+
def trace_off; @trace = false; end
|
|
103
|
+
#Check if element tracing is on., Details see Docgenerator.trace_on.
|
|
104
|
+
def trace_on?; @trace; end
|
|
105
|
+
end
|
|
86
106
|
|
|
87
107
|
|
|
88
108
|
=begin rdoc
|
|
89
|
-
Small include-module to define
|
|
109
|
+
Small include-module to define to_doc.
|
|
90
110
|
|
|
91
|
-
|
|
111
|
+
You may include this method instead of define a element class as
|
|
112
|
+
a subclass of Element.
|
|
113
|
+
|
|
114
|
+
In addition you get dummy definitions for
|
|
115
|
+
* to_latex
|
|
116
|
+
* to_html
|
|
117
|
+
* to_context
|
|
118
|
+
* to_creole
|
|
119
|
+
* to_wiki
|
|
120
|
+
* to_text
|
|
121
|
+
|
|
122
|
+
If you include this, please redefine this methods
|
|
92
123
|
=end
|
|
93
|
-
module
|
|
124
|
+
module Element_methods
|
|
94
125
|
=begin rdoc
|
|
95
126
|
to_doc returns the object as a string.
|
|
96
127
|
=end
|
|
97
128
|
def to_doc(target, options = {})
|
|
98
|
-
o =
|
|
129
|
+
o = set_option_defaults(options)
|
|
99
130
|
str = ""
|
|
100
131
|
case target
|
|
101
132
|
when :latex
|
|
@@ -108,6 +139,8 @@ to_doc returns the object as a string.
|
|
|
108
139
|
str = self.to_wiki(options)
|
|
109
140
|
when :creole
|
|
110
141
|
str = self.to_creole(options)
|
|
142
|
+
when :text
|
|
143
|
+
str = self.to_text(options)
|
|
111
144
|
else;
|
|
112
145
|
o[:log].error( "Unknown target #{target.inspect} for #{self.class}") if o[:log].error?
|
|
113
146
|
str = self.to_doc_str()
|
|
@@ -115,39 +148,74 @@ to_doc returns the object as a string.
|
|
|
115
148
|
str
|
|
116
149
|
end
|
|
117
150
|
=begin rdoc
|
|
118
|
-
|
|
151
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
152
|
+
|
|
153
|
+
This method should be redefinded by subclasses.
|
|
119
154
|
=end
|
|
120
155
|
def to_text(options = {})
|
|
121
|
-
o =
|
|
156
|
+
o = set_option_defaults(options)
|
|
122
157
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
123
158
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
124
159
|
end
|
|
160
|
+
=begin rdoc
|
|
161
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
162
|
+
|
|
163
|
+
This method should be redefinded by subclasses.
|
|
164
|
+
=end
|
|
125
165
|
def to_latex(options = {})
|
|
126
|
-
o =
|
|
166
|
+
o = set_option_defaults(options)
|
|
127
167
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
128
168
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
129
169
|
end
|
|
170
|
+
=begin rdoc
|
|
171
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
172
|
+
|
|
173
|
+
This method should be redefinded by subclasses.
|
|
174
|
+
=end
|
|
130
175
|
def to_context(options = {})
|
|
131
|
-
o =
|
|
176
|
+
o = set_option_defaults(options)
|
|
132
177
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
133
178
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
134
179
|
end
|
|
180
|
+
=begin rdoc
|
|
181
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
182
|
+
|
|
183
|
+
This method should be redefinded by subclasses.
|
|
184
|
+
=end
|
|
135
185
|
def to_html(options = {})
|
|
136
|
-
o =
|
|
186
|
+
o = set_option_defaults(options)
|
|
137
187
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
138
188
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
139
189
|
end
|
|
190
|
+
=begin rdoc
|
|
191
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
192
|
+
|
|
193
|
+
This method should be redefinded by subclasses.
|
|
194
|
+
=end
|
|
140
195
|
def to_wiki(options = {})
|
|
141
|
-
o =
|
|
196
|
+
o = set_option_defaults(options)
|
|
142
197
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
143
198
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
144
199
|
end
|
|
200
|
+
=begin rdoc
|
|
201
|
+
Dummy method. Returns to_str (or to_s) and throws a log-information.
|
|
202
|
+
|
|
203
|
+
This method should be redefinded by subclasses.
|
|
204
|
+
=end
|
|
145
205
|
def to_creole(options = {})
|
|
146
|
-
o =
|
|
206
|
+
o = set_option_defaults(options)
|
|
147
207
|
o[:log].fatal( "Please redefine to_text in #{self.class}") if o[:log].fatal?
|
|
148
208
|
self.respond_to?(:to_str) ? self.to_str : self.to_s
|
|
149
209
|
end
|
|
150
|
-
|
|
210
|
+
|
|
211
|
+
=begin rdoc
|
|
212
|
+
Instance-version of class method.
|
|
213
|
+
=end
|
|
214
|
+
def set_option_defaults(options)
|
|
215
|
+
Docgenerator.set_option_defaults(options, self)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
end #Element_methods
|
|
151
219
|
|
|
152
220
|
|
|
153
221
|
require 'log4r'
|
|
@@ -174,10 +242,13 @@ but normally the problems are document problems,
|
|
|
174
242
|
so we need the first step outside the docgenerator-path
|
|
175
243
|
=end
|
|
176
244
|
class LogFormatter < Log4r::BasicFormatter
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
245
|
+
=begin rdoc
|
|
246
|
+
Use another format for the logger.
|
|
247
|
+
|
|
248
|
+
Based on BasicFormatter.
|
|
249
|
+
When used with trace on, return the location from docgenerator and
|
|
250
|
+
the first non-docgenerator position.
|
|
251
|
+
=end
|
|
181
252
|
def format(event)
|
|
182
253
|
buff = sprintf(@@basicformat, Log4r::MaxLevelLength, Log4r::LNAMES[event.level],
|
|
183
254
|
event.name)
|
|
@@ -202,28 +273,55 @@ class LogFormatter < Log4r::BasicFormatter
|
|
|
202
273
|
end
|
|
203
274
|
end #LogFormatter
|
|
204
275
|
|
|
205
|
-
#
|
|
276
|
+
#Logger for Docgenerator
|
|
206
277
|
DOCGENERATOR_LOGGER = Log4r::Logger.new( 'docgenerator')
|
|
207
|
-
|
|
208
|
-
DOCGENERATOR_LOGGER
|
|
209
|
-
:formatter => LogFormatter
|
|
210
|
-
)
|
|
278
|
+
=begin
|
|
279
|
+
DOCGENERATOR_LOGGER is used for gem-internal messages and problems.
|
|
211
280
|
|
|
281
|
+
There will be a warning, if an Element gets no logger (option :log).
|
|
282
|
+
This may be a quite common thing, so we set the default level to ERROR.
|
|
283
|
+
=end
|
|
284
|
+
DOCGENERATOR_LOGGER.level = Log4r::ERROR
|
|
285
|
+
DOCGENERATOR_LOGGER.level = Log4r::WARN if $0 == __FILE__ #internal test
|
|
286
|
+
DOCGENERATOR_LOGGER.outputters = Log4r::StdoutOutputter.new('log_stdout',
|
|
287
|
+
:formatter => LogFormatter )
|
|
288
|
+
#~ DOCGENERATOR_LOGGER.trace = true
|
|
289
|
+
|
|
290
|
+
#Default Logger. Used in #set_option_defaults
|
|
291
|
+
DOCGENERATOR_DEFAULT_LOGGER = Log4r::Logger.new( 'docgenerator default')
|
|
292
|
+
=begin
|
|
293
|
+
DOCGENERATOR_DEFAULT_LOGGER is used,
|
|
294
|
+
if an Element gets no logger (option :log).
|
|
295
|
+
=end
|
|
296
|
+
#~ DOCGENERATOR_DEFAULT_LOGGER.level = Log4r::FATAL
|
|
297
|
+
DOCGENERATOR_DEFAULT_LOGGER.level = Log4r::WARN
|
|
298
|
+
DOCGENERATOR_DEFAULT_LOGGER.outputters = Log4r::StdoutOutputter.new('log_stdout',
|
|
299
|
+
:formatter => LogFormatter )
|
|
300
|
+
#~ DOCGENERATOR_DEFAULT_LOGGER.trace = true
|
|
212
301
|
|
|
213
302
|
=begin rdoc
|
|
214
|
-
|
|
303
|
+
Each to_doc, to_html, to_latex, to_wiki, to_text has an option-parameter.
|
|
304
|
+
|
|
305
|
+
This option-hash should contain at least a :log-value.
|
|
306
|
+
|
|
307
|
+
This method completes the option hash with a default logger and
|
|
308
|
+
returns a warning if no logger is given.
|
|
215
309
|
|
|
216
|
-
|
|
217
|
-
|
|
310
|
+
Usage:
|
|
311
|
+
def to_doc(target, options)
|
|
312
|
+
o = set_option_defaults(options)
|
|
218
313
|
o[:log].debug("Enter ...") if o[:log].debug?
|
|
314
|
+
...
|
|
315
|
+
end
|
|
316
|
+
|
|
219
317
|
=end
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
318
|
+
def self.set_option_defaults(options, called_by = self)
|
|
319
|
+
if ! options[:log]
|
|
320
|
+
DOCGENERATOR_LOGGER.warn("Missing logger in set_option_defaults, use DOCGENERATOR_DEFAULT_LOGGER (#{called_by.inspect})") if DOCGENERATOR_LOGGER.warn?
|
|
321
|
+
DOCGENERATOR_LOGGER.debug("\n\t#{caller.join("\n\t")}") if DOCGENERATOR_LOGGER.debug?
|
|
322
|
+
end
|
|
225
323
|
return {
|
|
226
|
-
:log =>
|
|
324
|
+
:log => DOCGENERATOR_DEFAULT_LOGGER,
|
|
227
325
|
#Added from Document:
|
|
228
326
|
# :document useable for documentation
|
|
229
327
|
# :filename useable for documentation
|
|
@@ -233,28 +331,22 @@ module Docgenerator_logger
|
|
|
233
331
|
#- parent - actually used in list to detect */# for wiki-items.
|
|
234
332
|
}.update(options)
|
|
235
333
|
end
|
|
236
|
-
end
|
|
237
|
-
require 'docgenerator/standard'
|
|
238
|
-
require 'docgenerator/element'
|
|
239
|
-
|
|
240
334
|
=begin rdoc
|
|
241
|
-
|
|
242
|
-
Attributes and content are optional parameter.
|
|
335
|
+
Instance-version of class method.
|
|
243
336
|
=end
|
|
244
|
-
def
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
element = Element.create( name, {}, true ).new(attr, content )
|
|
250
|
-
puts "Usage of undefined element #{name}"
|
|
251
|
-
end
|
|
252
|
-
return element
|
|
253
|
-
end
|
|
337
|
+
def set_option_defaults(options)
|
|
338
|
+
Docgenerator.set_option_defaults(options, self)
|
|
339
|
+
end
|
|
340
|
+
end #module Docgenerator
|
|
341
|
+
|
|
254
342
|
|
|
255
|
-
require '
|
|
343
|
+
require 'docgenerator/standard'
|
|
344
|
+
require 'docgenerator/element_meta' #Meta-class definitions
|
|
345
|
+
require 'docgenerator/element' #includes definition of method 'element'
|
|
346
|
+
#~ require 'docgenerator/compatibility_v1' #some old code
|
|
347
|
+
require 'docgenerator/templates/docgenerator_template'
|
|
256
348
|
require 'docgenerator/css'
|
|
257
|
-
require 'templates/docgenerator_template_css'
|
|
349
|
+
require 'docgenerator/templates/docgenerator_template_css'
|
|
258
350
|
require 'docgenerator/attribute'
|
|
259
351
|
require 'docgenerator/document'
|
|
260
352
|
#~ require_relative 'docgenerator/document'
|
|
@@ -268,18 +360,16 @@ require 'docgenerator/footnote'
|
|
|
268
360
|
require 'docgenerator/characters' #special characters (spaces, euro-sign...)
|
|
269
361
|
#~ require_relative 'docgenerator/characters' #special characters (spaces, euro-sign...)
|
|
270
362
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
363
|
+
#quicktest
|
|
364
|
+
if $0 == __FILE__
|
|
365
|
+
#~ Docgenerator.trace_on
|
|
366
|
+
#~ el = element(:shyx)
|
|
367
|
+
#~ el = element(:img, {:width => '5px', :src => 'name' })
|
|
368
|
+
|
|
369
|
+
doc = Docgenerator::Document.new()
|
|
370
|
+
doc.body << 'text'
|
|
371
|
+
#~ p doc.to_doc(:html, {:log => Docgenerator::DOCGENERATOR_DEFAULT_LOGGER})
|
|
372
|
+
#~ p doc.to_doc(:latex, {:log => Docgenerator::DOCGENERATOR_DEFAULT_LOGGER})
|
|
373
|
+
doc.save('xx.html')
|
|
274
374
|
end
|
|
275
|
-
|
|
276
|
-
puts test.required?
|
|
277
|
-
Test.class_eval('def required?(); false; end')
|
|
278
|
-
puts test.required?
|
|
279
|
-
|
|
280
|
-
testclass2 = Class.new( Test )
|
|
281
|
-
test2 = testclass2.new()
|
|
282
|
-
puts test2.required?
|
|
283
|
-
testclass2.class_eval('def required?(); true; end')
|
|
284
|
-
puts test2.required?
|
|
285
|
-
puts test.required?
|
|
375
|
+
__END__
|