docgenerator 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/build_test_and_doc.rb +505 -0
  2. data/examples/creole_example.rb +82 -0
  3. data/examples/creole_example_footnote.rb +67 -0
  4. data/examples/creole_example_placeholder.rb +77 -0
  5. data/examples/creole_example_rail.rb +154 -0
  6. data/examples/creole_example_rubycode.rb +144 -0
  7. data/examples/creole_example_struktex.rb +169 -0
  8. data/examples/docgenerator_example.rb +1 -1
  9. data/examples/docgenerator_example_footnote.rb +1 -0
  10. data/examples/docgenerator_example_list.rb +3 -0
  11. data/examples/docgenerator_example_restrictions.rb +1 -1
  12. data/examples/docgenerator_example_tabular.rb +1 -1
  13. data/examples/docgenerator_example_tripfalls.rb +2 -2
  14. data/examples/results/readme +2 -1
  15. data/examples/wiki2docgenerator_example.rb +61 -32
  16. data/lib/creole/creole2doc.rb +57 -58
  17. data/lib/creole/creole_characters.rb +56 -0
  18. data/lib/creole/creole_inclusion_and_plugins.rb +59 -284
  19. data/lib/creole/creole_inclusions.rb +142 -0
  20. data/lib/creole/creole_placeholder.rb +57 -23
  21. data/lib/creole/creole_plugins.rb +198 -0
  22. data/lib/creole/creole_tabular.rb +16 -8
  23. data/lib/creole/plugins/rail.rb +182 -0
  24. data/lib/creole/plugins/rubycode4creole.rb +136 -0
  25. data/lib/creole/plugins/struktex.rb +59 -0
  26. data/lib/creole/plugins/todonotes.rb +70 -0
  27. data/lib/docgenerator.rb +161 -71
  28. data/lib/docgenerator/attribute.rb +189 -156
  29. data/lib/docgenerator/characters.rb +824 -267
  30. data/lib/docgenerator/compatibility_v1.rb +249 -0
  31. data/lib/docgenerator/css.rb +53 -32
  32. data/lib/docgenerator/document.rb +119 -56
  33. data/lib/docgenerator/element.rb +304 -351
  34. data/lib/docgenerator/element_meta.rb +303 -0
  35. data/lib/docgenerator/elements.rb +1112 -481
  36. data/lib/docgenerator/environments.rb +153 -62
  37. data/lib/docgenerator/footnote.rb +30 -9
  38. data/lib/docgenerator/lists.rb +71 -47
  39. data/lib/docgenerator/packages/attachfile.rb +136 -0
  40. data/lib/{packages/docgenerator_caption.rb → docgenerator/packages/caption.rb} +28 -19
  41. data/lib/docgenerator/packages/hyperref.rb +194 -0
  42. data/lib/docgenerator/packages/listings.rb +179 -0
  43. data/lib/docgenerator/packages/pdfpages.rb +43 -0
  44. data/lib/docgenerator/packages/rubycode4doc.rb +227 -0
  45. data/lib/{packages/docgenerator_scrlettr2.rb → docgenerator/packages/scrlettr2.rb} +25 -16
  46. data/lib/docgenerator/packages/scrpage2.rb +410 -0
  47. data/lib/docgenerator/packages/struktex.rb +447 -0
  48. data/lib/docgenerator/packages/todonotes.rb +85 -0
  49. data/lib/{packages/docgenerator_url.rb → docgenerator/packages/url.rb} +7 -6
  50. data/lib/docgenerator/sections.rb +257 -83
  51. data/lib/docgenerator/standard.rb +19 -11
  52. data/lib/docgenerator/tabular.rb +234 -118
  53. data/lib/{templates → docgenerator/templates}/docgenerator_template.rb +52 -44
  54. data/lib/{templates → docgenerator/templates}/docgenerator_template.yaml +0 -0
  55. data/lib/{templates → docgenerator/templates}/docgenerator_template_css.rb +22 -16
  56. data/lib/wiki2doc/plugins/rubycode4wiki.rb +53 -0
  57. data/lib/wiki2doc/plugins/struktex.rb +12 -0
  58. data/lib/wiki2doc/wiki2docgenerator.rb +39 -38
  59. data/lib/wiki2doc/wikimedia_document.rb +24 -0
  60. data/manpage_elements.rb +10411 -0
  61. data/readme.rd +34 -24
  62. data/unittest/creole_testtext.creole +11 -0
  63. data/unittest/expected/test_document_usepackage_undefined.log +2 -2
  64. data/unittest/expected/test_runtex.stdout +0 -1
  65. data/unittest/expected/test_runtex_2.stdout +0 -1
  66. data/unittest/expected/toc_css.css +3 -2
  67. data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
  68. data/unittest/expected_creole/test_creole_characters_all.html +15 -15
  69. data/unittest/expected_creole/test_creole_characters_all.latex +15 -15
  70. data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
  71. data/unittest/expected_creole/test_creole_links_file.html +2 -2
  72. data/unittest/expected_creole/test_creole_links_file.latex +2 -2
  73. data/unittest/expected_creole/test_creole_links_file.text +2 -2
  74. data/unittest/expected_creole/test_creole_picture_link.html +1 -1
  75. data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
  76. data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
  77. data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
  78. data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
  79. data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
  80. data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
  81. data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
  82. data/unittest/expected_rubycode4doc/creole_output.html +2 -0
  83. data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
  84. data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
  85. data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
  86. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
  87. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
  88. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
  89. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
  90. data/unittest/expected_rubycode4doc/wiki_1.html +8 -0
  91. data/unittest/expected_rubycode4doc/wiki_2.html +8 -0
  92. data/unittest/expected_rubycode4doc/wiki_3.html +9 -0
  93. data/unittest/expected_rubycode4doc/wiki_immediate_1.html +5 -0
  94. data/unittest/expected_rubycode4doc/wiki_immediate_2.html +5 -0
  95. data/unittest/expected_rubycode4doc/wiki_immediate_3.html +8 -0
  96. data/unittest/expected_rubycode4doc/wiki_immediate_full.html +21 -0
  97. data/unittest/expected_struktex/test_struktex_krug.creole +15 -0
  98. data/unittest/expected_struktex/test_struktex_krug.tex +19 -0
  99. data/unittest/expected_struktex/test_struktex_krug.wiki +15 -0
  100. data/unittest/expected_struktex/test_struktex_statement.creole +7 -0
  101. data/unittest/expected_struktex/test_struktex_statement.tex +9 -0
  102. data/unittest/expected_struktex/test_struktex_statement.wiki +7 -0
  103. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.html +0 -0
  104. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.latex +0 -0
  105. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.text +0 -0
  106. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.wiki +0 -0
  107. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.html +1 -1
  108. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.latex +1 -1
  109. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.text +1 -1
  110. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.wiki +1 -1
  111. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.html +0 -0
  112. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.latex +0 -0
  113. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.text +0 -0
  114. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.wiki +0 -0
  115. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_2.html +0 -0
  116. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_groupid.html +0 -0
  117. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.html +0 -0
  118. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.latex +0 -0
  119. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.text +0 -0
  120. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.wiki +0 -0
  121. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.html +0 -0
  122. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.latex +0 -0
  123. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.text +0 -0
  124. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.wiki +0 -0
  125. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_label.html +0 -0
  126. data/unittest/expected_wikimedia/test_wiki_link.html +8 -0
  127. data/unittest/expected_wikimedia/test_wiki_link.latex +17 -0
  128. data/unittest/expected_wikimedia/test_wiki_link.wiki +11 -0
  129. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.html +0 -0
  130. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.latex +0 -0
  131. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.text +0 -0
  132. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.wiki +0 -0
  133. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.html +0 -0
  134. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.latex +0 -0
  135. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.text +0 -0
  136. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.wiki +0 -0
  137. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.html +0 -0
  138. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.latex +0 -0
  139. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.text +0 -0
  140. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.wiki +0 -0
  141. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.html +0 -0
  142. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.latex +0 -0
  143. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.text +0 -0
  144. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.wiki +0 -0
  145. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.html +0 -0
  146. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.latex +0 -0
  147. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.text +0 -0
  148. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.wiki +0 -0
  149. data/unittest/expected_wikimedia/test_wiki_picture.html +55 -0
  150. data/unittest/expected_wikimedia/test_wiki_picture.latex +76 -0
  151. data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +5 -0
  152. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.html +0 -0
  153. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.latex +0 -0
  154. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.wiki +0 -0
  155. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.html +0 -0
  156. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.latex +0 -0
  157. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.text +0 -0
  158. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.wiki +0 -0
  159. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.html +0 -0
  160. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.latex +0 -0
  161. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.text +0 -0
  162. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.wiki +0 -0
  163. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.html +0 -0
  164. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.latex +0 -0
  165. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.text +0 -0
  166. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.wiki +0 -0
  167. data/unittest/{unittest_creole2doc.rb → unittest_creole.rb} +385 -476
  168. data/unittest/unittest_creole_placeholders.rb +272 -0
  169. data/unittest/unittest_creole_plugin_rail.rb +147 -0
  170. data/unittest/unittest_docgenerator.rb +206 -332
  171. data/unittest/unittest_docgenerator_characters.rb +650 -0
  172. data/unittest/unittest_docgenerator_runtex.rb +48 -20
  173. data/unittest/unittest_packages_struktex.rb +187 -0
  174. data/unittest/unittest_rubycode4doc.rb +275 -0
  175. data/unittest/unittest_wikimedia.rb +479 -0
  176. metadata +245 -172
  177. data/examples/results_expected/docgenerator_example.html +0 -39
  178. data/examples/results_expected/docgenerator_example.pdf +0 -0
  179. data/examples/results_expected/docgenerator_example.tex +0 -56
  180. data/examples/results_expected/docgenerator_example_footnote.html +0 -40
  181. data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
  182. data/examples/results_expected/docgenerator_example_footnote.tex +0 -50
  183. data/examples/results_expected/docgenerator_example_list.html +0 -18
  184. data/examples/results_expected/docgenerator_example_list.pdf +0 -0
  185. data/examples/results_expected/docgenerator_example_list.tex +0 -46
  186. data/examples/results_expected/docgenerator_example_restrictions.html +0 -22
  187. data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
  188. data/examples/results_expected/docgenerator_example_restrictions.tex +0 -31
  189. data/examples/results_expected/docgenerator_example_tabular.html +0 -37
  190. data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
  191. data/examples/results_expected/docgenerator_example_tabular.tex +0 -41
  192. data/examples/results_expected/docgenerator_example_tripfalls.html +0 -27
  193. data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
  194. data/examples/results_expected/docgenerator_example_tripfalls.tex +0 -31
  195. data/lib/packages/docgenerator_attachfile.rb +0 -71
  196. data/lib/packages/docgenerator_hyperref.rb +0 -109
  197. data/lib/packages/docgenerator_listings.rb +0 -103
  198. data/lib/packages/docgenerator_pdfpages.rb +0 -24
  199. data/lib/packages/docgenerator_scrpage2.rb +0 -172
  200. data/self_docgenerator.rb +0 -163
  201. data/unittest/expected_wiki/test_wiki_link.html +0 -8
  202. data/unittest/expected_wiki/test_wiki_link.latex +0 -17
  203. data/unittest/expected_wiki/test_wiki_link.wiki +0 -11
  204. data/unittest/expected_wiki/test_wiki_picture.html +0 -55
  205. data/unittest/expected_wiki/test_wiki_picture.latex +0 -76
  206. data/unittest/expected_wiki/test_wiki_picture_thumb.html +0 -5
  207. data/unittest/test_rakefile_docgenerator.rb +0 -43
  208. data/unittest/unittest_versions.rb +0 -44
  209. data/unittest/unittest_wiki2doc.rb +0 -464
@@ -0,0 +1,56 @@
1
+ =begin rdoc
2
+ Creole characters
3
+
4
+ This classes define special characters as inclusions.
5
+
6
+ * Inclusions are used later with {{xx}}
7
+ more at http://www.wikicreole.org/wiki/Inclusion
8
+ =end
9
+
10
+ #
11
+
12
+ module Docgenerator
13
+ module Creole
14
+
15
+ =begin rdoc
16
+ Define special characters as inclusions.
17
+
18
+ See also Creole::CHARACTERS
19
+ =end
20
+ module Characters
21
+ =begin rdoc
22
+ Define a 'shy' as {{shy}}
23
+ =end
24
+ class Creole_shy < Creole_inclusion_and_plugin
25
+ set_inclusions_key '-'
26
+ set_inclusions_key 'shy'
27
+
28
+ def to_doc(target, options = {})
29
+ element(:shy).to_doc(target, options)
30
+ end
31
+ end #Creole_shy
32
+
33
+ =begin rdoc
34
+ Define a 'radic' as {{radic}}
35
+ =end
36
+ class Creole_radic < Creole_inclusion_and_plugin
37
+ set_inclusions_key 'radic'
38
+
39
+ def to_doc(target, options = {})
40
+ element(:radic).to_doc(target, options)
41
+ end
42
+ end #Creole_shy
43
+
44
+ =begin rdoc
45
+ Define a 'nil' as {{nil}}
46
+ =end
47
+ class Creole_nil < Creole_inclusion_and_plugin
48
+ set_inclusions_key 'nil'
49
+
50
+ def to_doc(target, options = {})
51
+ ''
52
+ end
53
+ end #Creole_nil
54
+ end #module Characters
55
+ end #module Creole
56
+ end #module Docgenerator
@@ -1,20 +1,25 @@
1
- #
2
- #Creole inclusions and plugins
3
- #
4
- #
5
- #This classes are defined to implement transclusions (http://en.wikipedia.org/wiki/Transclusion)
6
- #
7
- #- http://www.wikicreole.org/wiki/Inclusion
8
- #- http://www.wikicreole.org/wiki/Plugin
9
- #
10
- #By default, Pictures are expected.
11
- #
12
- #You can extend Wikis with additional inclusions:
13
- #
14
- # wiki = Creole.new()
15
- # wiki.inclusion['xxx'] = Creole_inclusion_xxx
1
+ =begin rdoc
2
+ Creole inclusions and plugins
3
+
4
+ This classes are defined to implement transclusions (http://en.wikipedia.org/wiki/Transclusion)
5
+
6
+ * Inclusions are used later with {{xx}}
7
+ more at http://www.wikicreole.org/wiki/Inclusion
8
+ * Plugins are used later with <<xx>>
9
+ more at http://www.wikicreole.org/wiki/Plugin
10
+
11
+ By default, an inclusion expects a pictures, unless it es defined something else.
12
+
13
+ You can extend Wikis with additional inclusions:
14
+
15
+ wiki = Creole.new()
16
+ wiki.inclusion['xxx'] = Creole_inclusion_xxx
17
+ =end
18
+
16
19
  #
17
20
 
21
+ module Docgenerator
22
+ module Creole
18
23
 
19
24
  =begin rdoc
20
25
  Dummy class for all inclusions and plugins.
@@ -27,6 +32,7 @@ Derived classes (Inclusions):
27
32
  - Creole_inclusion_img
28
33
  - Creole_inclusion_footnote_group
29
34
  - Creole_inclusion_footnote
35
+
30
36
  Derived classes (Plugins):
31
37
  - Creole_default_plugin
32
38
  - Creole_plugin_ruby
@@ -34,8 +40,18 @@ Derived classes (Plugins):
34
40
  More subclasses may be possible.
35
41
  =end
36
42
  class Creole_inclusion_and_plugin
37
- include Docgenerator #get VERSION
38
-
43
+ =begin rdoc
44
+ Example:
45
+ {{inclusionname|description|option1=1,option2=2}}
46
+
47
+ Parameters:
48
+ * inclusionname: Name of the inclusion (normally fix for an instance, unless e.g. Creole_inclusion_img)
49
+ * description: First parameter of the plugin.
50
+ * options: Array with the comma separated values.
51
+ In the example:
52
+ ['option1=1','option2=2']
53
+ * wiki: creole-instance, where the plugin/inclusion is defined.
54
+ =end
39
55
  def initialize( inclusionname, description, options, wiki )
40
56
  @inclusionname = inclusionname
41
57
  @description = description
@@ -43,286 +59,45 @@ class Creole_inclusion_and_plugin
43
59
  @wiki = wiki
44
60
 
45
61
  raise "Inclusion received no wiki but #{wiki.inspect}" unless wiki.is_a?(Creole)
46
-
47
62
  end
48
63
  #Reader for the wiki.
49
64
  attr_reader :wiki
50
- end #Creole_inclusion
51
-
52
- #
53
- #Default Plugin.
54
- class Creole_default_plugin < Creole_inclusion_and_plugin
55
- Creole::Plugins.default = self
56
- def initialize( pluginname, description, options, wiki )
57
- super
58
- @wiki.log.warn("Use Default plugin instead requested #{pluginname}- nothing special done.") if @wiki.log.warn?
59
- end
60
- end
61
-
62
-
63
- #
64
- #Define a 'shy' as {{shy}}
65
- #
66
- class Creole_shy < Creole_inclusion_and_plugin
67
- #
68
- #~ Creole::Plugins['-'] = self
69
- Creole::Inclusions['-'] = self
70
- Creole::Inclusions['shy'] = self
71
-
72
- def to_doc(target, options = {})
73
- element(:shy).to_doc(target, options)
74
- end
75
- end #Creole_inclusion_footnote_group
76
-
77
- #
78
- #Define a 'nil' as {{nil}}
79
- #
80
- class Creole_nil < Creole_inclusion_and_plugin
81
- #
82
- #~ Creole::Plugins['-'] = self
83
- #~ Creole::Inclusions['-'] = self
84
- Creole::Inclusions['nil'] = self
85
-
86
- def to_doc(target, options = {})
87
- ''
88
- end
89
- end #Creole_inclusion_footnote_group
90
-
91
65
 
92
66
  =begin rdoc
93
- Include images.
94
- http://www.wikicreole.org/wiki/Images
95
-
96
- There are yet more features than in standard.
97
-
98
- This is also the default for inclusions.
99
-
100
- Usage:
101
- {{picurl.jpg|Alternate text|class=cc}}
102
- {{picurl.jpg|Alternate text|css=width:50%}}
103
-
104
- =end
105
- class Creole_inclusion_img < Creole_inclusion_and_plugin
106
- Creole::Inclusions.default = self
67
+ Define meta-methods for Creole_inclusion_and_plugin
68
+ =end
69
+ class << self
107
70
  =begin rdoc
108
- Define an image.
109
- The existence of the picture is checked.
110
-
111
- Supported options:
112
- * alt (2nd parameter of {{picsrc|...}}
113
- * css or imgcss
114
- * class or imgclass
115
- * longdesc (can take a url, at leas opera offers to call the description)
116
- * width (only LaTeX. For HTML, use css-option).
117
-
118
- =end
119
- def initialize( picname, alt_text, options, wiki )
120
- super
121
- @img = element(:img,{ :src => @inclusionname })
122
- @img[:alt] << alt_text if alt_text
123
- #Check existence of Picture. Only possible if the related wiki is available.
124
- wiki.check_link_existence( @inclusionname, wiki.log )
125
-
126
- css = CSS.new( :log => wiki.log )
127
-
128
- #
129
- #Check for options
130
- #
131
- #Missing options:
132
- #* align
133
- #* border
134
- #* height
135
- #* hspace
136
- #* name
137
- #* vspace
138
- options.each{|option|
139
- case option
140
- when /^(img)?css\s*=\s*(.*)/
141
- $2.split(/\s*;\s*/).each{|css_assignment|
142
- css_assignment =~ /(.+?)\s*:\s*(.+)/
143
- css[$1] = $2
144
- }
145
- when /^(img)?class\s*=\s*(.*)/
146
- @img[:class] << $2
147
- when /^width\s*=\s*(.*)/
148
- @img[:width] << $1
149
- when /^longdesc\s*=\s*(.*)/ #gibt einen URI (nach RFC 2396) an, wo eine Langbeschreibung der Grafik zu finden ist
150
- @img[:longdesc] << $1
151
- else
152
- wiki.log.warn("Img: Undefined option #{option}") if wiki.log.warn?
153
- end #case option
154
- } if options
155
- @img.attr[:style] << css
156
-
157
- end
158
- def to_doc(target, options = {})
159
- @img.to_doc(target, options)
160
- end
161
- end #Creole_inclusion_img
162
-
163
- #
164
- #Collection of footnotes.
165
- #
166
- class Creole_footnote_group < Creole_inclusion_and_plugin
167
- #
168
- Creole::Plugins['footnotes'] = self
169
- #~ Creole::Inclusions['footnotes'] = self
170
-
171
- def initialize( inclusionname, description, options, wiki )
172
- super
173
- description = Footnotegroup::DEFAULTGROUPID unless description
174
- @footnotesgroup = wiki.footnotegroups[description]
175
- wiki.log.error("Footnotesgroup #{description.inspect} not found") if ! @footnotesgroup and wiki.log.error?
176
- end
177
- def to_doc(target, options = {})
178
- @footnotesgroup.to_doc(target, options)
179
- end
180
- end #Creole_inclusion_footnote_group
181
-
71
+ Define class as a Inclusion.
72
+ You may use the class as:
73
+ {{key}}
74
+ =end
75
+ def set_inclusions_key(key)
76
+ Inclusions::Collection[key] = self
77
+ end
182
78
  =begin rdoc
183
- One footnote
184
-
185
- Usage:
186
- <<footnote|text>>
187
-
188
- Bug: If you create more documents, you get a common footnote counting.
189
- Has to be repaired one day.
190
- =end
191
- class Creole_footnote < Creole_inclusion_and_plugin
192
- Creole::Plugins['footnote'] = self
193
- #~ Creole::Inclusions['footnote'] = self
194
- def initialize( inclusionname, description, options, wiki )
195
- super
196
-
197
- @groupid = Footnotegroup::DEFAULTGROUPID
198
- label = nil
199
-
200
- options.each{|option|
201
- case option
202
- when /label\s*=\s*(.*)/
203
- label = $1
204
- when /groupid\s*=\s*(.*)/
205
- @groupid = $1
206
- else
207
- @wiki.log.warn("Footnote with unknown option #{option.inspect} not found") if @wiki.log.warn?
208
- end
209
- }
210
-
211
- if ! wiki.footnotegroups[@groupid]
212
- wiki.footnotegroups[@groupid] = Footnotegroup.new(@groupid)
79
+ Define class as a Plugin.
80
+ You may use the class as:
81
+ <<key>>
82
+ =end
83
+ def set_plugin_key(key)
84
+ Plugins::Collection[key] = self
213
85
  end
214
-
215
- group = wiki.footnotegroups[@groupid]
216
-
217
- @footnote = element(:footnote,{
218
- :group => group,
219
- :label => label,
220
- }, description )
221
-
222
-
223
- end
224
- def to_doc(target, options ={})
225
- @footnote.to_doc(target, options)
226
- end
227
- end #Creole_inclusion_footnote
228
-
229
86
  =begin rdoc
230
- Some short html
231
-
232
- Usage:
233
- {{html|code}}
87
+ fixme
234
88
 
235
- Note:
236
- There is also a placeholder for larger html:
237
- <<<html
238
- content
239
- >>>
240
- =end
241
- class Creole_short_html < Creole_inclusion_and_plugin
242
- #We don't use it as plugin. Closing > from html may e confusing as in:
243
- # <<html|<em>kursuiv</em>>>
244
- #~ Creole::Plugins['html'] = self
245
- Creole::Inclusions['html'] = self
246
- #~ Creole::Inclusions['footnote'] = self
247
- def initialize( inclusionname, description, options, wiki )
248
- super
249
- options.each{|option|
250
- #~ case option
251
- #~ else
252
- @wiki.log.warn("HTML with unknown option #{option.inspect} not found") if @wiki.log.warn?
253
- #~ end
254
- }
255
- @source = description
89
+ define to_doc...
90
+ =end
256
91
 
257
- end
258
- #Return content only for html
259
- def to_doc( target, options = {})
260
- target == :html ? @source.to_doc( target, options ) : ''
261
- end
262
- end #Creole_inclusion_html
263
-
264
- =begin rdoc
265
- Eval the given ruby-code and put it as "raw text".
266
-
267
-
268
- This is defined as a plugin.
269
- =end
270
- class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
271
- #~ Creole::Inclusions['ruby'] = self
272
- Creole::Plugins['ruby_raw'] = self
273
-
274
- def initialize( inclusionname, description, options, wiki )
275
- #The ruby-code may contain | - so we have to ad it again
276
- description << "|#{options.join('|')}" unless options.empty?
277
- options = nil
278
- super
279
- @code = description
280
- begin
281
- @result = eval(@code)
282
- rescue => bang
283
- wiki.log.error("Plugin ruby_raw: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
284
- end
285
- end #initioliaze
286
- def to_doc(target, options ={})
287
- @result.to_s
288
- end
289
- def inspect()
290
- "#<Creole_plugin_ruby_raw:#{@code}>"
291
- end
292
- end #Creole_plugin_ruby
293
-
294
- =begin rdoc
295
- Eval the given ruby-code and add it as a interpreted code.
92
+ end #Meta-methods
93
+ end #Creole_inclusion_and_plugin
296
94
 
297
- This is defined as a plugin.
95
+ require_relative 'creole_inclusions.rb'
96
+ require_relative 'creole_characters.rb' #inclusions
97
+ require_relative 'creole_plugins.rb'
298
98
 
299
- Ideas for further development: eval later, at doc generation.
300
- =end
301
- class Creole_plugin_ruby < Creole_inclusion_and_plugin
302
- #~ Creole::Inclusions['ruby'] = self
303
- Creole::Plugins['ruby'] = self
304
- def initialize( inclusionname, description, options, wiki )
305
- #The ruby-code may contain | - so we have to ad it again
306
- description << "|#{options.join('|')}" unless options.empty?
307
- options = nil
308
- super
309
-
310
- @code = description
311
- begin
312
- @result = eval(@code)
313
- rescue => bang
314
- wiki.log.error("Plugin ruby: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
315
- end
316
- end #initioliaze
317
- def to_doc(target, options = {})
318
- @wiki.normsource2elements(
319
- @wiki.parse(@result.to_s ), options
320
- ).to_doc(target, options )
321
- end
322
- def inspect()
323
- "#<Creole_plugin_ruby:#{@code}>"
324
- end
325
- end #Creole_plugin_ruby
99
+ end #module Creole
100
+ end #module Docgenerator
326
101
 
327
102
  #~ if $0 == __FILE__
328
103
  #~ require 'quicktest'
@@ -0,0 +1,142 @@
1
+ =begin rdoc
2
+ Creole inclusions.
3
+
4
+ This classes are defined to implement inclusions.
5
+
6
+ * Inclusions are used later with {{xx}}
7
+ more at http://www.wikicreole.org/wiki/Inclusion
8
+
9
+ By default, an inclusion expects a pictures, unless it es defined something else.
10
+
11
+ You can extend Wikis with additional inclusions:
12
+
13
+ wiki = Creole.new()
14
+ wiki.inclusion['xxx'] = Creole_inclusion_xxx
15
+ =end
16
+
17
+ #
18
+
19
+ module Docgenerator
20
+ module Creole
21
+
22
+ =begin rdoc
23
+ Define Inclusions
24
+
25
+ Inclusions are used via {{...}}
26
+
27
+ Default: Creole_inclusion_img (defined in class definition Creole_inclusion_img)
28
+ =end
29
+ module Inclusions
30
+ Collection = Hash.new()
31
+
32
+
33
+ =begin rdoc
34
+ Include images.
35
+ http://www.wikicreole.org/wiki/Images
36
+
37
+ There are yet more features than in standard.
38
+
39
+ This is also the default for inclusions.
40
+
41
+ Usage:
42
+ {{picurl.jpg|Alternate text|class=cc}}
43
+ {{picurl.jpg|Alternate text|css=width:50%}}
44
+
45
+ =end
46
+ class Creole_inclusion_img < Creole_inclusion_and_plugin
47
+ Collection.default = self
48
+ =begin rdoc
49
+ Define an image.
50
+ The existence of the picture is checked.
51
+
52
+ Supported options:
53
+ * alt (2nd parameter of {{picsrc|...}}
54
+ * css or imgcss
55
+ * class or imgclass
56
+ * longdesc (can take a url, at leas opera offers to call the description)
57
+ * width (only LaTeX. For HTML, use css-option).
58
+
59
+ =end
60
+ def initialize( picname, alt_text, options, wiki )
61
+ super
62
+ @img = element(:img,{ :src => @inclusionname })
63
+ @img[:alt] << alt_text if alt_text
64
+ #Check existence of Picture. Only possible if the related wiki is available.
65
+ wiki.check_link_existence( @inclusionname, wiki.log )
66
+
67
+ css = CSS.new( :log => wiki.log )
68
+
69
+ #
70
+ #Check for options
71
+ #
72
+ #Missing options:
73
+ #* align
74
+ #* border
75
+ #* height
76
+ #* hspace
77
+ #* name
78
+ #* vspace
79
+ options.each{|option|
80
+ case option
81
+ when /^(img)?css\s*=\s*(.*)/
82
+ $2.split(/\s*;\s*/).each{|css_assignment|
83
+ css_assignment =~ /(.+?)\s*:\s*(.+)/
84
+ css[$1] = $2
85
+ }
86
+ when /^(img)?class\s*=\s*(.*)/
87
+ @img[:class] << $2
88
+ when /^width\s*=\s*(.*)/
89
+ @img[:width] << $1
90
+ when /^longdesc\s*=\s*(.*)/ #gibt einen URI (nach RFC 2396) an, wo eine Langbeschreibung der Grafik zu finden ist
91
+ @img[:longdesc] << $1
92
+ else
93
+ wiki.log.warn("Img: Undefined option #{option}") if wiki.log.warn?
94
+ end #case option
95
+ } if options
96
+ @img.attr[:style] << css
97
+
98
+ end
99
+ def to_doc(target, options = {})
100
+ @img.to_doc(target, options)
101
+ end
102
+ end #Creole_inclusion_img
103
+
104
+ =begin rdoc
105
+ Some short html
106
+
107
+ Usage:
108
+ {{html|code}}
109
+
110
+ Note:
111
+ There is also a placeholder for larger html:
112
+ <<<html
113
+ content
114
+ >>>
115
+ =end
116
+ class Creole_short_html < Creole_inclusion_and_plugin
117
+ #We don't use it as plugin. Closing > from html may e confusing as in:
118
+ # <<html|<em>kursuiv</em>>>
119
+ set_inclusions_key 'html'
120
+
121
+
122
+ def initialize( inclusionname, description, options, wiki )
123
+ super
124
+ options.each{|option|
125
+ #~ case option
126
+ #~ else
127
+ @wiki.log.warn("HTML with unknown option #{option.inspect} not found") if @wiki.log.warn?
128
+ #~ end
129
+ }
130
+ @source = description
131
+
132
+ end
133
+ #Return content only for html
134
+ def to_doc( target, options = {})
135
+ target == :html ? @source.to_doc( target, options ) : ''
136
+ end
137
+ end #Creole_inclusion_html
138
+
139
+
140
+ end #module Inclusions
141
+ end #module Creole
142
+ end #module Docgenerator