docgenerator 2.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docgenerator.rb +18 -18
  3. data/lib/docgenerator/characters.rb +1 -0
  4. data/lib/docgenerator/css.rb +5 -0
  5. data/lib/docgenerator/document.rb +7 -2
  6. data/lib/docgenerator/element.rb +2 -2
  7. data/lib/docgenerator/elements.rb +69 -2
  8. data/lib/docgenerator/index.rb +1 -1
  9. data/lib/docgenerator/packages/listings.rb +94 -94
  10. data/lib/docgenerator/packages/multicol.rb +1 -1
  11. data/lib/docgenerator/packages/pdfpages.rb +2 -1
  12. data/lib/docgenerator/packages/rubycode4doc.rb +173 -172
  13. data/lib/docgenerator/packages/struktex.rb +395 -379
  14. data/lib/docgenerator/packages/todonotes.rb +2 -2
  15. data/lib/docgenerator/packages/url.rb +4 -0
  16. data/lib/docgenerator/sections.rb +24 -2
  17. data/lib/docgenerator/tabular.rb +59 -14
  18. data/lib/docgenerator/templates/docgenerator_template.rb +1 -0
  19. data/lib/docgenerator/templates/docgenerator_template.yaml +30 -1
  20. data/lib/docgenerator/version.rb +13 -1
  21. data/meta_test_and_doc/build__meta.rb +3 -10
  22. data/meta_test_and_doc/build_doc.rb +4 -2
  23. data/meta_test_and_doc/build_test.rb +21 -17
  24. data/meta_test_and_doc/manpages/images.rb +152 -0
  25. data/unittest/expected/test_document_toc_article.latex +6 -6
  26. data/unittest/expected_struktex/test_struktex_krug.creole +5 -5
  27. data/unittest/expected_struktex/test_struktex_krug.wiki +5 -5
  28. data/unittest/expected_struktex/test_struktex_statement.creole +4 -4
  29. data/unittest/expected_struktex/test_struktex_statement.wiki +4 -4
  30. data/unittest/expected_templates/test_report_utf8.tex +34 -0
  31. data/unittest/expected_templates/test_standalone.tex +2 -1
  32. data/unittest/unittest_docgenerator.rb +37 -30
  33. data/unittest/unittest_docgenerator_characters.rb +113 -60
  34. data/unittest/unittest_docgenerator_runtex.rb +16 -12
  35. data/unittest/unittest_packages_multicol.rb +4 -9
  36. data/unittest/unittest_packages_struktex.rb +66 -90
  37. data/unittest/unittest_rubycode4doc.rb +38 -241
  38. data/unittest/unittest_templates.rb +4 -8
  39. metadata +23 -560
  40. data/examples/creole_example.rb +0 -81
  41. data/examples/creole_example_footnote.rb +0 -67
  42. data/examples/creole_example_new_plugin.rb +0 -51
  43. data/examples/creole_example_placeholder.rb +0 -77
  44. data/examples/creole_example_rail.rb +0 -154
  45. data/examples/creole_example_rubycode.rb +0 -144
  46. data/examples/creole_example_struktex.rb +0 -169
  47. data/examples/creole_example_tabular.rb +0 -97
  48. data/examples/wiki2docgenerator_example.rb +0 -299
  49. data/lib/creole/creole2doc.rb +0 -954
  50. data/lib/creole/creole_characters.rb +0 -120
  51. data/lib/creole/creole_inclusion_and_plugins.rb +0 -96
  52. data/lib/creole/creole_inclusions.rb +0 -154
  53. data/lib/creole/creole_placeholder.rb +0 -171
  54. data/lib/creole/creole_plugins.rb +0 -230
  55. data/lib/creole/creole_tabular.rb +0 -401
  56. data/lib/creole/plugins/rail.rb +0 -181
  57. data/lib/creole/plugins/rubycode4creole.rb +0 -136
  58. data/lib/creole/plugins/struktex.rb +0 -59
  59. data/lib/creole/plugins/todonotes.rb +0 -77
  60. data/lib/wiki2doc/plugins/rubycode4wiki.rb +0 -53
  61. data/lib/wiki2doc/plugins/struktex.rb +0 -12
  62. data/lib/wiki2doc/wiki2docgenerator.rb +0 -1276
  63. data/lib/wiki2doc/wikimedia_document.rb +0 -24
  64. data/meta_test_and_doc/manpages/packages.rb +0 -13
  65. data/unittest/Red_Flower.jpg +0 -0
  66. data/unittest/creole1.0test.txt +0 -128
  67. data/unittest/creole_testtext.creole +0 -11
  68. data/unittest/expected_creole/test_creole.html +0 -3
  69. data/unittest/expected_creole/test_creole_characters_all.creole +0 -28
  70. data/unittest/expected_creole/test_creole_characters_all.html +0 -18
  71. data/unittest/expected_creole/test_creole_characters_all.latex +0 -36
  72. data/unittest/expected_creole/test_creole_characters_special.html +0 -10
  73. data/unittest/expected_creole/test_creole_characters_special.latex +0 -18
  74. data/unittest/expected_creole/test_creole_comment.context +0 -11
  75. data/unittest/expected_creole/test_creole_comment.creole +0 -12
  76. data/unittest/expected_creole/test_creole_comment.html +0 -9
  77. data/unittest/expected_creole/test_creole_comment.latex +0 -11
  78. data/unittest/expected_creole/test_creole_countdown.html +0 -3
  79. data/unittest/expected_creole/test_creole_countdown.latex +0 -4
  80. data/unittest/expected_creole/test_creole_creole1.0test.html +0 -182
  81. data/unittest/expected_creole/test_creole_creole1.0test.latex +0 -253
  82. data/unittest/expected_creole/test_creole_creole1.0test.text +0 -160
  83. data/unittest/expected_creole/test_creole_footnotes.html +0 -9
  84. data/unittest/expected_creole/test_creole_footnotes.latex +0 -14
  85. data/unittest/expected_creole/test_creole_footnotes_groupid.html +0 -15
  86. data/unittest/expected_creole/test_creole_footnotes_label.html +0 -9
  87. data/unittest/expected_creole/test_creole_headings.html +0 -17
  88. data/unittest/expected_creole/test_creole_headings.latex +0 -19
  89. data/unittest/expected_creole/test_creole_headings.text +0 -48
  90. data/unittest/expected_creole/test_creole_headings.wiki +0 -37
  91. data/unittest/expected_creole/test_creole_hr.html +0 -7
  92. data/unittest/expected_creole/test_creole_hr.latex +0 -9
  93. data/unittest/expected_creole/test_creole_hr.text +0 -4
  94. data/unittest/expected_creole/test_creole_ignore.html +0 -3
  95. data/unittest/expected_creole/test_creole_ignore.latex +0 -4
  96. data/unittest/expected_creole/test_creole_ignore.text +0 -2
  97. data/unittest/expected_creole/test_creole_inline.html +0 -3
  98. data/unittest/expected_creole/test_creole_inline.latex +0 -4
  99. data/unittest/expected_creole/test_creole_inline.text +0 -2
  100. data/unittest/expected_creole/test_creole_inline_apostroph.html +0 -6
  101. data/unittest/expected_creole/test_creole_inline_apostroph.latex +0 -8
  102. data/unittest/expected_creole/test_creole_inline_apostroph.text +0 -4
  103. data/unittest/expected_creole/test_creole_inline_ruby.html +0 -12
  104. data/unittest/expected_creole/test_creole_inline_ruby.latex +0 -20
  105. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +0 -6
  106. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +0 -8
  107. data/unittest/expected_creole/test_creole_input.normsource +0 -25
  108. data/unittest/expected_creole/test_creole_input.normsource_1.8 +0 -23
  109. data/unittest/expected_creole/test_creole_input_file_simple.html +0 -15
  110. data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +0 -15
  111. data/unittest/expected_creole/test_creole_label.html +0 -12
  112. data/unittest/expected_creole/test_creole_label.latex +0 -15
  113. data/unittest/expected_creole/test_creole_line_break.html +0 -6
  114. data/unittest/expected_creole/test_creole_line_break.latex +0 -8
  115. data/unittest/expected_creole/test_creole_links_explicit_internal.html +0 -6
  116. data/unittest/expected_creole/test_creole_links_explicit_internal.text +0 -4
  117. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +0 -3
  118. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +0 -4
  119. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +0 -2
  120. data/unittest/expected_creole/test_creole_links_external.html +0 -6
  121. data/unittest/expected_creole/test_creole_links_external.latex +0 -8
  122. data/unittest/expected_creole/test_creole_links_external.text +0 -4
  123. data/unittest/expected_creole/test_creole_links_external_implicit.html +0 -9
  124. data/unittest/expected_creole/test_creole_links_external_implicit.latex +0 -12
  125. data/unittest/expected_creole/test_creole_links_external_implicit.text +0 -6
  126. data/unittest/expected_creole/test_creole_links_file.html +0 -6
  127. data/unittest/expected_creole/test_creole_links_file.latex +0 -8
  128. data/unittest/expected_creole/test_creole_links_file.text +0 -4
  129. data/unittest/expected_creole/test_creole_links_implicit_end.creole +0 -4
  130. data/unittest/expected_creole/test_creole_links_implicit_end.html +0 -3
  131. data/unittest/expected_creole/test_creole_links_implicit_end.latex +0 -4
  132. data/unittest/expected_creole/test_creole_list_ol.html +0 -12
  133. data/unittest/expected_creole/test_creole_list_ol.latex +0 -22
  134. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +0 -12
  135. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +0 -20
  136. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +0 -6
  137. data/unittest/expected_creole/test_creole_list_ol_ul.html +0 -15
  138. data/unittest/expected_creole/test_creole_list_ol_ul.latex +0 -26
  139. data/unittest/expected_creole/test_creole_list_ul.html +0 -22
  140. data/unittest/expected_creole/test_creole_list_ul.latex +0 -40
  141. data/unittest/expected_creole/test_creole_list_ul.normsource +0 -89
  142. data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +0 -83
  143. data/unittest/expected_creole/test_creole_list_ul_too_much.html +0 -24
  144. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +0 -44
  145. data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +0 -6
  146. data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +0 -12
  147. data/unittest/expected_creole/test_creole_mix_titles_list.html +0 -10
  148. data/unittest/expected_creole/test_creole_mix_titles_list.latex +0 -18
  149. data/unittest/expected_creole/test_creole_mix_titles_list.text +0 -12
  150. data/unittest/expected_creole/test_creole_newline.html +0 -9
  151. data/unittest/expected_creole/test_creole_newline.latex +0 -11
  152. data/unittest/expected_creole/test_creole_newline.text +0 -7
  153. data/unittest/expected_creole/test_creole_paragraphs.html +0 -6
  154. data/unittest/expected_creole/test_creole_paragraphs.latex +0 -8
  155. data/unittest/expected_creole/test_creole_paragraphs.normsource +0 -29
  156. data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +0 -27
  157. data/unittest/expected_creole/test_creole_paragraphs.text +0 -4
  158. data/unittest/expected_creole/test_creole_paragraphs.wiki +0 -4
  159. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +0 -5
  160. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +0 -6
  161. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +0 -4
  162. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +0 -4
  163. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +0 -9
  164. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +0 -11
  165. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +0 -7
  166. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +0 -7
  167. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +0 -5
  168. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +0 -6
  169. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +0 -4
  170. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +0 -4
  171. data/unittest/expected_creole/test_creole_picture_link.html +0 -6
  172. data/unittest/expected_creole/test_creole_pictures.html +0 -10
  173. data/unittest/expected_creole/test_creole_pictures.latex +0 -13
  174. data/unittest/expected_creole/test_creole_pictures_css.html +0 -6
  175. data/unittest/expected_creole/test_creole_pictures_css.latex +0 -8
  176. data/unittest/expected_creole/test_creole_pictures_imgclass.html +0 -6
  177. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +0 -8
  178. data/unittest/expected_creole/test_creole_pictures_longdesc.html +0 -3
  179. data/unittest/expected_creole/test_creole_pictures_width.html +0 -3
  180. data/unittest/expected_creole/test_creole_pictures_width.latex +0 -4
  181. data/unittest/expected_creole/test_creole_placeholders_html.html +0 -7
  182. data/unittest/expected_creole/test_creole_placeholders_html.latex +0 -8
  183. data/unittest/expected_creole/test_creole_placeholders_html.text +0 -4
  184. data/unittest/expected_creole/test_creole_placeholders_latex.html +0 -6
  185. data/unittest/expected_creole/test_creole_placeholders_latex.latex +0 -9
  186. data/unittest/expected_creole/test_creole_placeholders_latex.text +0 -4
  187. data/unittest/expected_creole/test_creole_short_html.html +0 -3
  188. data/unittest/expected_creole/test_creole_short_html.latex +0 -4
  189. data/unittest/expected_creole/test_creole_short_html.text +0 -2
  190. data/unittest/expected_creole/test_creole_shy.creole +0 -6
  191. data/unittest/expected_creole/test_creole_shy.html +0 -6
  192. data/unittest/expected_creole/test_creole_shy.latex +0 -8
  193. data/unittest/expected_creole/test_creole_shy.text +0 -4
  194. data/unittest/expected_creole/test_creole_tabular.creole +0 -22
  195. data/unittest/expected_creole/test_creole_tabular.html +0 -20
  196. data/unittest/expected_creole/test_creole_tabular.latex +0 -22
  197. data/unittest/expected_creole/test_creole_tabular_creole.creole +0 -19
  198. data/unittest/expected_creole/test_creole_tabular_creole.html +0 -18
  199. data/unittest/expected_creole/test_creole_tabular_creole.latex +0 -19
  200. data/unittest/expected_creole/test_creole_tabular_css.creole +0 -24
  201. data/unittest/expected_creole/test_creole_tabular_css.html +0 -20
  202. data/unittest/expected_creole/test_creole_tabular_css.latex +0 -22
  203. data/unittest/expected_creole/test_creole_tabular_multicols.creole +0 -16
  204. data/unittest/expected_creole/test_creole_tabular_multicols.html +0 -14
  205. data/unittest/expected_creole/test_creole_tabular_multicols.latex +0 -16
  206. data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +0 -22
  207. data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +0 -21
  208. data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +0 -20
  209. data/unittest/expected_creole/test_creole_toc.html +0 -13
  210. data/unittest/expected_creole/test_creole_toc.latex +0 -22
  211. data/unittest/expected_creole/test_creole_toc.text +0 -4
  212. data/unittest/expected_creole/test_creole_toc_level.html +0 -7
  213. data/unittest/expected_creole/test_creole_toc_level.latex +0 -10
  214. data/unittest/expected_creole/test_creole_toc_level.text +0 -3
  215. data/unittest/expected_creole/test_creole_toc_level_text.html +0 -8
  216. data/unittest/expected_creole/test_creole_toc_level_text.latex +0 -9
  217. data/unittest/expected_creole/test_creole_toc_text.html +0 -5
  218. data/unittest/expected_creole/test_creole_toc_text.latex +0 -5
  219. data/unittest/expected_creole/test_creole_ul_multiple_line.html +0 -7
  220. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +0 -14
  221. data/unittest/expected_creole/test_creole_ul_with_blank.html +0 -11
  222. data/unittest/expected_creole/test_creole_ul_with_blank.latex +0 -20
  223. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  224. data/unittest/expected_creole/test_creole_ul_with_bold.html +0 -11
  225. data/unittest/expected_creole/test_creole_ul_with_bold.latex +0 -18
  226. data/unittest/expected_creole/test_creole_ul_with_bold.text +0 -7
  227. data/unittest/expected_creole/test_creole_verbatim.html +0 -25
  228. data/unittest/expected_creole/test_creole_verbatim.latex +0 -33
  229. data/unittest/expected_creole/test_creole_verbatim.text +0 -17
  230. data/unittest/expected_creole/test_creole_verbatim_inline.html +0 -6
  231. data/unittest/expected_creole/test_creole_verbatim_inline.latex +0 -8
  232. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +0 -6
  233. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +0 -8
  234. data/unittest/expected_creole_rail/test_rail_creole_object.tex +0 -33
  235. data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +0 -40
  236. data/unittest/expected_rubycode4doc/creole_complete.html +0 -26
  237. data/unittest/expected_rubycode4doc/creole_complete.tex +0 -40
  238. data/unittest/expected_rubycode4doc/creole_in_tab.html +0 -4
  239. data/unittest/expected_rubycode4doc/creole_in_tab.tex +0 -6
  240. data/unittest/expected_rubycode4doc/creole_inline_ruby.html +0 -7
  241. data/unittest/expected_rubycode4doc/creole_output.html +0 -2
  242. data/unittest/expected_rubycode4doc/creole_output.tex +0 -4
  243. data/unittest/expected_rubycode4doc/creole_rubycode.html +0 -1
  244. data/unittest/expected_rubycode4doc/creole_rubycode.tex +0 -3
  245. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +0 -1
  246. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +0 -3
  247. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +0 -3
  248. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +0 -5
  249. data/unittest/expected_rubycode4doc/wiki_1.html +0 -8
  250. data/unittest/expected_rubycode4doc/wiki_2.html +0 -8
  251. data/unittest/expected_rubycode4doc/wiki_3.html +0 -9
  252. data/unittest/expected_rubycode4doc/wiki_immediate_1.html +0 -5
  253. data/unittest/expected_rubycode4doc/wiki_immediate_2.html +0 -5
  254. data/unittest/expected_rubycode4doc/wiki_immediate_3.html +0 -8
  255. data/unittest/expected_rubycode4doc/wiki_immediate_full.html +0 -21
  256. data/unittest/expected_wikimedia/test_wiki.html +0 -6
  257. data/unittest/expected_wikimedia/test_wiki.latex +0 -12
  258. data/unittest/expected_wikimedia/test_wiki.text +0 -14
  259. data/unittest/expected_wikimedia/test_wiki.wiki +0 -12
  260. data/unittest/expected_wikimedia/test_wiki_description.html +0 -7
  261. data/unittest/expected_wikimedia/test_wiki_description.latex +0 -11
  262. data/unittest/expected_wikimedia/test_wiki_description.text +0 -6
  263. data/unittest/expected_wikimedia/test_wiki_description.wiki +0 -6
  264. data/unittest/expected_wikimedia/test_wiki_footnote.html +0 -8
  265. data/unittest/expected_wikimedia/test_wiki_footnote.latex +0 -17
  266. data/unittest/expected_wikimedia/test_wiki_footnote.text +0 -10
  267. data/unittest/expected_wikimedia/test_wiki_footnote.wiki +0 -10
  268. data/unittest/expected_wikimedia/test_wiki_footnote_2.html +0 -8
  269. data/unittest/expected_wikimedia/test_wiki_footnote_groupid.html +0 -21
  270. data/unittest/expected_wikimedia/test_wiki_html_code.html +0 -7
  271. data/unittest/expected_wikimedia/test_wiki_html_code.latex +0 -10
  272. data/unittest/expected_wikimedia/test_wiki_html_code.text +0 -6
  273. data/unittest/expected_wikimedia/test_wiki_html_code.wiki +0 -6
  274. data/unittest/expected_wikimedia/test_wiki_inline.html +0 -6
  275. data/unittest/expected_wikimedia/test_wiki_inline.latex +0 -12
  276. data/unittest/expected_wikimedia/test_wiki_inline.text +0 -8
  277. data/unittest/expected_wikimedia/test_wiki_inline.wiki +0 -8
  278. data/unittest/expected_wikimedia/test_wiki_label.html +0 -6
  279. data/unittest/expected_wikimedia/test_wiki_link.html +0 -8
  280. data/unittest/expected_wikimedia/test_wiki_link.latex +0 -17
  281. data/unittest/expected_wikimedia/test_wiki_link.wiki +0 -11
  282. data/unittest/expected_wikimedia/test_wiki_list_ol.html +0 -24
  283. data/unittest/expected_wikimedia/test_wiki_list_ol.latex +0 -30
  284. data/unittest/expected_wikimedia/test_wiki_list_ol.text +0 -10
  285. data/unittest/expected_wikimedia/test_wiki_list_ol.wiki +0 -12
  286. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.html +0 -16
  287. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.latex +0 -24
  288. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.text +0 -8
  289. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.wiki +0 -10
  290. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.html +0 -24
  291. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.latex +0 -30
  292. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.text +0 -10
  293. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.wiki +0 -12
  294. data/unittest/expected_wikimedia/test_wiki_list_ul.html +0 -24
  295. data/unittest/expected_wikimedia/test_wiki_list_ul.latex +0 -30
  296. data/unittest/expected_wikimedia/test_wiki_list_ul.text +0 -10
  297. data/unittest/expected_wikimedia/test_wiki_list_ul.wiki +0 -12
  298. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.html +0 -39
  299. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.latex +0 -51
  300. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.text +0 -11
  301. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.wiki +0 -15
  302. data/unittest/expected_wikimedia/test_wiki_picture.html +0 -55
  303. data/unittest/expected_wikimedia/test_wiki_picture.latex +0 -76
  304. data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +0 -5
  305. data/unittest/expected_wikimedia/test_wiki_tab1.html +0 -30
  306. data/unittest/expected_wikimedia/test_wiki_tab1.latex +0 -30
  307. data/unittest/expected_wikimedia/test_wiki_tab1.wiki +0 -29
  308. data/unittest/expected_wikimedia/test_wiki_textformatting.html +0 -7
  309. data/unittest/expected_wikimedia/test_wiki_textformatting.latex +0 -16
  310. data/unittest/expected_wikimedia/test_wiki_textformatting.text +0 -11
  311. data/unittest/expected_wikimedia/test_wiki_textformatting.wiki +0 -9
  312. data/unittest/expected_wikimedia/test_wiki_toc.html +0 -9
  313. data/unittest/expected_wikimedia/test_wiki_toc.latex +0 -18
  314. data/unittest/expected_wikimedia/test_wiki_toc.text +0 -21
  315. data/unittest/expected_wikimedia/test_wiki_toc.wiki +0 -18
  316. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.html +0 -18
  317. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.latex +0 -19
  318. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.text +0 -6
  319. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.wiki +0 -7
  320. data/unittest/unittest_creole.rb +0 -1361
  321. data/unittest/unittest_creole_placeholders.rb +0 -150
  322. data/unittest/unittest_creole_plugin_rail.rb +0 -147
  323. data/unittest/unittest_creole_tabular.rb +0 -207
  324. data/unittest/unittest_wikimedia.rb +0 -479
@@ -6,7 +6,7 @@ Example:
6
6
  =end
7
7
  class Multicols < Environments::Environment
8
8
  add_attributes( {
9
- :colnum => Attribute.create( [:latex], [ Fixnum ], 1 ),
9
+ :colnum => Attribute.create( [:latex], [ Integer ], 1 ),
10
10
  :titleline => Attribute.create( [:latex], [ String,Element], 2 ),
11
11
  }#.update(HTML_ATTR_ALL)
12
12
  )
@@ -37,8 +37,9 @@ Implement includepdf from pdfpages-package.
37
37
  add_attribute :linkname, Attribute.create( [ :texkeyval], [ String ] )
38
38
  add_attribute :linktodoc, Attribute.create( [ :texkeyval], [ true, false] ) #Lets the inserted pages be hyperlinks to the document from which they were extracted.
39
39
  #~ add_attribute :addtotoc, Attribute.create( [ :texkeyval], [ /.+,.+,.+,.+,.+/] ), #
40
+ add_attribute :options, Attribute.create( [ :latex], [ String ] ) #any other option. This string is added at the end.
40
41
 
41
- add_output( :latex, '#{linebreak(@crbefore)}\includepdf[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}')
42
+ add_output( :latex, '#{linebreak(@crbefore)}\includepdf[#{texkeyval()},#{@attr[:options]}]{#{@content}}#{linebreak(@crafter)}')
42
43
 
43
44
  end #IncludePDF
44
45
  =begin rdoc
@@ -5,98 +5,101 @@ Ruby fragments are executed line by line.
5
5
  The source code is enriched with the results and can be shown.
6
6
  =end
7
7
 
8
- require 'docgenerator'
9
- require 'docgenerator/packages/listings'
8
+ require_relative '../../docgenerator'
9
+ require_relative '../packages/listings'
10
10
  #~ require '../../lib/packages/docgenerator_listings'
11
11
 
12
12
  #
13
13
  module Docgenerator
14
- module Rubycode
15
-
16
-
17
- class CodeTest
18
- #Catch output.
19
- #
20
- #Used to replace $stdout
21
- class MyIO < String
22
- def write( cont )
23
- self << cont
24
- end
25
- end #MyIO
26
-
27
- Code_line = Struct.new('Code_line', :code, :line_number, :result, :output, :outputtab, :comment )
28
- @@all = {}
14
+ module Rubycode
15
+ =begin rdoc
16
+ Basic Idea:
17
+ * Execute ruby code line by line
18
+ * Show result per line
19
+ =end
20
+ class CodeTest
21
+ #Catch output.
22
+ #
23
+ #Used to replace $stdout
24
+ class MyIO < String
25
+ def write( cont )
26
+ self << cont
27
+ end
28
+ end #MyIO
29
+
30
+ Code_line = Struct.new('Code_line', :code, :line_number, :result, :output, :outputtab, :comment )
31
+ @@all = {}
29
32
  =begin rdoc
30
33
  Get some executable ruby code and analyse it.
31
34
  If a name is given, it is stored for later reuse (see CodeTest[])
32
35
  =end
33
- def initialize( name, code = '' )
34
- @name = name
35
- if @@all[@name]
36
- raise "Double definition of CodeTest #{name.inspect}"
37
- else
38
- @@all[@name] = self
39
- end if name
40
- #Keep binding for code execution
41
- @bind = binding
42
- #Collection of all coding lines (elements are Code_line-struct)
43
- @codelines = []
44
- code.split(/\n/).each{|c|
45
- self << c
46
- }
47
- end
36
+ def initialize( name, code = '' )
37
+ @name = name
38
+ if @@all[@name]
39
+ raise "Double definition of CodeTest #{name.inspect}"
40
+ else
41
+ @@all[@name] = self
42
+ end if name
43
+ #Keep binding for code execution
44
+ @bind = binding
45
+ #Collection of all coding lines (elements are Code_line-struct)
46
+ @codelines = []
47
+ code.split(/\n/).each{|c|
48
+ self << c
49
+ }
50
+ end
48
51
  =begin rdoc
49
52
  Add one coding line.
50
53
  -Each line is executed,
51
- -The result o fthe line is added to #result
54
+ -The result of the line is added to #result
52
55
  -The output is added to #output
53
56
 
54
57
  Restrictions:
55
58
  -One line, one command (only last command returns its result)
56
59
  =end
57
- def << ( c )
58
- #fixme: command mit Strings "#...
59
- command, comment = c.chomp.split(/#/, 2 )
60
- #~ if comment
61
- #~ puts '--'*10 + 'comment'
62
- #~ puts c.chomp
63
- #~ puts command
64
- #~ puts comment.inspect
65
- #~ end
66
- begin
67
- $stdout = output = MyIO.new
68
- codeline = Code_line.new( c.chomp, @codelines.size + 1, eval(c, @bind) )
69
- rescue SyntaxError
70
- $stdout = STDOUT
71
- DOCGENERATOR_LOGGER.error("CodeTest #{@name}: Syntax Error with: '#{c}'") if DOCGENERATOR_LOGGER.error?
72
- return
73
- end
74
- $stdout = STDOUT
75
- codeline.outputtab = []
76
- if output.size > 0
77
- codeline.output = output.inspect
78
- codeline.outputtab = output.split("\n")
79
- end
80
- codeline.comment = comment
81
- @codelines << codeline
82
- end
83
- #Get 'plain' sourcecode
84
- def sourcecode()
85
- code = []
86
- @codelines.each{|codeline|
87
- code << codeline.code
88
- }
89
- code.join("\n")
90
- end
91
- #Get 'plain' output
92
- def output()
93
- output = []
94
- @codelines.each{|codeline|
95
- #~ output << codeline.output
96
- output << codeline.outputtab
97
- }
98
- output.join("\n")
99
- end
60
+ def << ( c )
61
+ #fixme: command mit Strings "#...
62
+ command, comment = c.chomp.split(/#/, 2 )
63
+ #~ if comment
64
+ #~ puts '--'*10 + 'comment'
65
+ #~ puts c.chomp
66
+ #~ puts command
67
+ #~ puts comment.inspect
68
+ #~ end
69
+ begin
70
+ $stdout = output = MyIO.new
71
+ codeline = Code_line.new( c.chomp, @codelines.size + 1, eval(c, @bind) )
72
+ rescue SyntaxError
73
+ $stdout = STDOUT
74
+ DOCGENERATOR_LOGGER.error("CodeTest #{@name}: Syntax Error with: '#{c}'") if DOCGENERATOR_LOGGER.error?
75
+ return
76
+ end
77
+ $stdout = STDOUT
78
+ codeline.outputtab = []
79
+ if output.size > 0
80
+ codeline.output = output.inspect
81
+ codeline.outputtab = output.split("\n")
82
+ end
83
+ codeline.comment = comment
84
+ @codelines << codeline
85
+ end
86
+ #Get 'plain' sourcecode
87
+ def sourcecode()
88
+ code = []
89
+ @codelines.each{|codeline|
90
+ code << codeline.code
91
+ }
92
+ code.join("\n")
93
+ end
94
+ #Get 'plain' output
95
+ def output()
96
+ output = []
97
+ @codelines.each{|codeline|
98
+ #~ output << codeline.output
99
+ output << codeline.outputtab
100
+ }
101
+ output.join("\n")
102
+ end
100
103
  =begin rdoc
101
104
  Get code and results in a verbatim env.
102
105
  The comments starts after the column max. (default: longest code line + 3 )
@@ -108,120 +111,118 @@ becomes
108
111
 
109
112
  fixme: define scope, from-to line
110
113
  =end
111
- def code_evaluation( max = @codelines.map{|f|f.code.size}.max + 3 )
112
- evaluated_code = []
113
- @codelines.each{|codeline|
114
- #Prepare coding line with result of the line if not done before
115
- evaluated_line = "%-#{max}s" % [ codeline.code ]
116
- if codeline.result or codeline.output
117
- evaluated_line << " # "
118
- end
119
- if codeline.result
120
- evaluated_line << '-> %-10s' % [ codeline.result ]
121
- end
122
- if codeline.output
123
- evaluated_line << '=> %-10s' % [ codeline.output ]
114
+ def code_evaluation( max = @codelines.map{|f|f.code.size}.max + 3 )
115
+ evaluated_code = []
116
+ @codelines.each{|codeline|
117
+ #Prepare coding line with result of the line if not done before
118
+ evaluated_line = "%-#{max}s" % [ codeline.code ]
119
+ if codeline.result or codeline.output
120
+ evaluated_line << " # "
121
+ end
122
+ if codeline.result
123
+ evaluated_line << '-> %-10s' % [ codeline.result ]
124
+ end
125
+ if codeline.output
126
+ evaluated_line << '=> %-10s' % [ codeline.output ]
127
+ end
128
+ evaluated_code << evaluated_line
129
+ }
130
+ evaluated_code.join("\n")
124
131
  end
125
- evaluated_code << evaluated_line
126
- }
127
- evaluated_code.join("\n")
128
- end
129
-
130
- #Get code and results in a lstlistings environment.
131
- def code_evaluation_lstlisting( max = @codelines.map{|f|f.code.size}.max + 3 )
132
- element(:lstlisting,{ :numbers => 'left',
133
- :numberstyle => '\tiny',
134
- :class => 'rubycode_with_result',
135
- }, self.code_evaluation( max) ).cR
136
- end #code_evaluation()
132
+
133
+ #Get code and results in a lstlistings environment.
134
+ def code_evaluation_lstlisting( max = @codelines.map{|f|f.code.size}.max + 3 )
135
+ element(:lstlisting,{ :numbers => 'left',
136
+ :numberstyle => '\tiny',
137
+ :class => 'rubycode_with_result',
138
+ }, self.code_evaluation( max) ).cR
139
+ end #code_evaluation()
137
140
  =begin rdoc
138
141
  Get code
139
142
  =end
140
- def code()
141
- element(:lstlisting,{ :numbers => 'left',
142
- :numberstyle => '\tiny',
143
- :class => 'rubycode',
144
- }, @codelines.map{|codeline| codeline.code}.join("\n")).cR
145
- end #code_evaluation()
143
+ def code()
144
+ element(:lstlisting,{ :numbers => 'left',
145
+ :numberstyle => '\tiny',
146
+ :class => 'rubycode',
147
+ }, @codelines.map{|codeline| codeline.code}.join("\n")).cR
148
+ end #code_evaluation()
146
149
  =begin rdoc
147
150
  return tabular with code, result and output.
148
151
  =end
149
- def code_in_tab()
150
- #~ element(:verbatim,{}, @code)
151
- #~ puts 'tabularx mag kein verbatim'
152
- #~ tabular = element(:tabularx, {
153
- #~ :columndescription => 'lXllXX',
154
- #~ :width => '\\textwidth',
155
- tabular = element(:tabular, {
156
- :columndescription => 'lp{3cm}llp{3cm}',
157
- :columns => 5,
158
- :border => 1,
159
- }).Cr
160
- tabular << row = element(:row).cr.hline
161
- row << element(:col, {}, 'No' )
162
- row << element(:col, {}, 'Code' )
163
- row << element(:col, {}, 'Result' )
164
- row << element(:col, {}, 'Output' )
165
- row << element(:col, {}, 'Output2' )
166
- @codelines.each{|c|
167
- tabular << row = element(:row).cr
168
- row << element(:col, {}, c.line_number )
169
- if c.code.include?("\n")
170
- row << element(:col, {}, element(:lstlisting,{:class => 'rubycode' }, ["\n", c.code]) ).Cr
171
- else
172
- row << element(:col, {}, element(:lstinline,{:class => 'rubycode' }, c.code) )
152
+ def code_in_tab()
153
+ #~ element(:verbatim,{}, @code)
154
+ #~ puts 'tabularx mag kein verbatim'
155
+ #~ tabular = element(:tabularx, {
156
+ #~ :columndescription => 'lXllXX',
157
+ #~ :width => '\\textwidth',
158
+ tabular = element(:tabular, {
159
+ :columndescription => 'lp{3cm}llp{3cm}',
160
+ :columns => 5,
161
+ :border => 1,
162
+ }).Cr
163
+ tabular << row = element(:row).cr.hline
164
+ row << element(:col, {}, 'No' )
165
+ row << element(:col, {}, 'Code' )
166
+ row << element(:col, {}, 'Result' )
167
+ row << element(:col, {}, 'Output' )
168
+ row << element(:col, {}, 'Output2' )
169
+ @codelines.each{|c|
170
+ tabular << row = element(:row).cr
171
+ row << element(:col, {}, c.line_number )
172
+ if c.code.include?("\n")
173
+ row << element(:col, {}, element(:lstlisting,{:class => 'rubycode' }, ["\n", c.code]) ).Cr
174
+ else
175
+ row << element(:col, {}, element(:lstinline,{:class => 'rubycode' }, c.code) )
176
+ end
177
+ row << element(:col, {}, c.result )
178
+ row << element(:col, {}, c.output ? element(:verb,{ :class => 'ruby_result_string' }, c.output) : nil )
179
+ #~ row << element(:col, {}, c.outputtab.map{|i| [i, element(:br)]}.flatten[0..-2] )
180
+ row << element(:col, {}, element(:verbatim,{:class => 'ruby_result'}, c.outputtab.join("\n") ) )
181
+ }
182
+ tabular
173
183
  end
174
- row << element(:col, {}, c.result )
175
- row << element(:col, {}, c.output ? element(:verb,{ :class => 'ruby_result_string' }, c.output) : nil )
176
- #~ row << element(:col, {}, c.outputtab.map{|i| [i, element(:br)]}.flatten[0..-2] )
177
- row << element(:col, {}, element(:verbatim,{:class => 'ruby_result'}, c.outputtab.join("\n") ) )
178
- }
179
- tabular
180
- end
181
184
  =begin rdoc
182
185
  Get the code fragment
183
186
  =end
184
- def self.[](name)
185
- @@all[name]
186
- end
187
+ def self.[](name)
188
+ @@all[name]
189
+ end
187
190
  =begin rdoc
188
191
  Build a Document with required head-definitions
189
192
  (usepackage...)
190
193
  =end
191
- def self.mk_document( title )
192
- doc = Document.new(
193
- :title => title
194
- )
195
- doc.head << element(:usepackage,{ }, 'listings').cr
196
- doc.head << element(:usepackage,{ }, 'color').cr
197
- doc.head << element(:lstloadlanguages,{}, 'ruby' ).cr
198
- doc.head << element(:lstset, {
199
- :language => 'ruby',
200
- :commentstyle => '\color{blue}',
201
- } ).cr
202
- return doc
203
- end
204
- end #CodeTest
205
- end #module Rubycode
194
+ def self.mk_document( title )
195
+ doc = Document.new(
196
+ :title => title
197
+ )
198
+ doc.head << element(:usepackage,{ }, 'listings').cr
199
+ doc.head << element(:usepackage,{ }, 'color').cr
200
+ doc.head << element(:lstloadlanguages,{}, 'ruby' ).cr
201
+ doc.head << element(:lstset, {
202
+ :language => 'ruby',
203
+ :commentstyle => '\color{blue}',
204
+ } ).cr
205
+ return doc
206
+ end
207
+ end #CodeTest
208
+ end #module Rubycode
206
209
  end #module Docgenerator
207
210
 
208
211
  if $0 == __FILE__
209
- test = CodeTest.new('codetest', <<CODE
210
- a = 5
211
- b = a * 5
212
- puts b
213
- puts b + 3
214
- CODE
215
- )
216
- puts test.code_evaluation
217
-
218
- puts "\n====Add more code====\n\n"
219
- test << <<TEST
220
- 3.times{|i|
221
- puts i
222
- }
223
- TEST
212
+ test = Docgenerator::Rubycode::CodeTest.new('codetest', <<-CODE)
213
+ a = 5
214
+ b = a * 5
215
+ puts b
216
+ puts b + 3
217
+ CODE
218
+ puts test.code_evaluation
224
219
 
220
+ puts "\n====Add more code====\n\n"
221
+ test << <<-TEST
222
+ 3.times{|i|
223
+ puts i
224
+ }
225
+ TEST
225
226
 
226
- puts test.code_evaluation
227
+ puts test.code_evaluation
227
228
  end #if $0 == __FILE__
@@ -30,18 +30,18 @@ end
30
30
 
31
31
 
32
32
  module Docgenerator
33
- module Packages
33
+ module Packages
34
34
  =begin rdoc
35
35
  Classes to provide support for the LaTeX-class struktex.
36
36
 
37
37
  * http://www.ctan.org/tex-archive/macros/latex/contrib/struktex/
38
38
  =end
39
- module Struktex
40
- USEPACKAGE_STRUKTEX = element(:usepackage,{}, 'struktex').cr
41
- USEPACKAGE_STRUKTEX_PROOF = '\sProofOn '
39
+ module Struktex
40
+ USEPACKAGE_STRUKTEX = element(:usepackage,{}, 'struktex').cr
41
+ USEPACKAGE_STRUKTEX_PROOF = '\sProofOn '
42
42
 
43
- #Bug: \pVar mag entgegen der Doku keine _ mag
44
- REPL_UNDERSCORE = false
43
+ #Bug: \pVar mag entgegen der Doku keine _ mag
44
+ REPL_UNDERSCORE = false
45
45
 
46
46
  =begin rdoc
47
47
  Code-generator for structex, a TeX-package to create Nassi-Shneidermann diagramms.
@@ -51,397 +51,413 @@ parameters.
51
51
 
52
52
  To define define ele Element-methods, module Element_methods is included.
53
53
  =end
54
- class Structogramm
55
-
56
- include Docgenerator::Element_methods #defines to_doc
57
-
58
- PARSTRUCT = Struct.new('PARSTRUCT', :dir, :name, :text )
59
- def self.head()
60
- USEPACKAGE_STRUKTEX
61
- end
62
- attr_accessor :sourcecode
54
+ class Structogramm
55
+
56
+ include Docgenerator::Element_methods #defines to_doc
57
+
58
+ PARSTRUCT = Struct.new('PARSTRUCT', :dir, :name, :text )
59
+ def self.head()
60
+ USEPACKAGE_STRUKTEX
61
+ end
62
+ attr_accessor :sourcecode
63
63
  =begin rdoc
64
64
  Define a structogramm.
65
65
  =end
66
- def initialize( title, x, y, code = String.new )
67
- @title = title
68
- @sourcecode = code
69
- @x = x
70
- @y = y
71
- @elements = []
72
-
73
- @log = Log4r::Logger.new("Structogramm #{title}")
74
- @log.outputters = Log4r::StdoutOutputter.new('log_stdout')
75
- end
76
-
77
- def <<(code)
78
- @sourcecode << code
79
- @sourcecode << "\n"
80
- end
81
- #
82
- #Analyse sourcecode and fill @elements
83
- def analyse_sourcecode( code = @sourcecode )
84
- stack = [ @elements ]
85
- lastcmd = nil
86
- code.each_line{|l|
87
- l.strip!
88
- case l
89
- when /\A\s*#~/ #comment
90
- when /\A%/
91
- stack.last << l
92
- when /ENDIF\s*(.*)/, /ENDCASE\s*(.*)/,
93
- /ENDWHILE\s*(.*)/, /ENDFOREVER\s*(.*)/,
94
- /ENDSELECT\s*(.*)/
95
- #~ @elements << "\\ifend"
96
- stack.pop #close actual IF
97
- lastcmd = nil
98
- when /IF\s*(.*)/
99
- #~ @elements << "\\ifthenelse{3}{3}{#{$1}}{\\pTrue}{\\pFalse}"
100
- struct = Structogramm_IF.new(inline($1))
101
- stack.last << struct
102
- stack << struct
103
- lastcmd = nil
104
- when /THEN\s*(\d)?\s*(.*)/
105
- stack.last.thensize = $1 if $1
106
- stack.last.thentext = inline($2) if $2 and ! $2.empty?
107
- lastcmd = nil
108
- when /ELSE\s*(\d)?\s*(.*)/
109
- stack.last.elsesize = $1 if $1
110
- stack.last.elsetext = inline($2) if $2 and ! $2.empty?
111
- #~ @elements << "\\change"
112
- stack.last.else
113
- lastcmd = nil
114
- when /CASE\s*(\d)?\s*(.*)/
115
- struct = Structogramm_CASE.new( inline($2), $1, @log)
116
- stack.last << struct
117
- stack << struct
118
- lastcmd = nil
119
- when /(?:SWITCH|WHEN)(?:\[([crl])\])?\s*(.*)/
120
- stack.last.switch(inline($2), $1)
121
- lastcmd = nil
122
- when /WHILE\s*(.*)/, /SELECT\s*(.*)/
123
- struct = Structogramm_WHILE.new(inline($1))
124
- stack.last << struct
125
- stack << struct
126
- lastcmd = nil
127
- when /REPEAT\s*(.*)/
128
- struct = Structogramm_REPEAT.new(inline($1))
129
- stack.last << struct
130
- stack << struct
131
- lastcmd = nil
132
- when /UNTIL\s*(.*)/
133
- stack.last.condition = $1
134
- stack.pop #close actual IF
135
- lastcmd = nil
136
- when /FOREVER\s*(.*)/
137
- struct = Structogramm_FOREVER.new()
138
- stack.last << struct
139
- stack << struct
140
- lastcmd = nil
141
- when /<=\s*(.*)/
142
- stack.last << lastcmd = Structogramm_CMD.new( "exit", inline($1) )
143
- when /=>\s*(.*)/
144
- stack.last << lastcmd = Structogramm_CMD.new( "sub", inline($1) )
145
- when /<>\s*(.*)/
146
- stack.last << lastcmd = Structogramm_CMD.new( "return", inline($1) )
147
- when /(<->|<-|->)\s*(\S+)\s*(.*)/
148
- if ! lastcmd
149
- @log.warn("description #{l} without command") if @log.warn?
150
- else
151
- lastcmd.par << PARSTRUCT.new($1, inline($2), $3 )
152
- end
153
- else
154
- stack.last << lastcmd = Structogramm_CMD.new( "assign", inline(l) )
155
- end
156
- }
157
- end
158
- def inline( inp )
159
- #~ return inp.gsub(/'(.*?)'/, '\\pKey{\1}')
160
- return Document.texify(inp).gsub(/'(.*?)'/, '\\pKey{\1}').gsub(/->/, '$\to$')
161
- end
162
- def to_s()
163
- @sourcecode
164
- end
165
- #Print the source code in a verbatim environmet
166
- def verbatim()
167
- return element(:verbatim,{},@sourcecode.gsub(/\t/, ' ')).cR
168
- end
169
- #
170
- #Option:
171
- #-:centernss Flag if the structogramm should be entered in an environment.
172
- def to_latex( options = {} )
173
- options = options.merge( :centernss => true )
174
- analyse_sourcecode()
175
- tex = [nil]
176
- tex << '\begin{centernss}' if options[:centernss]
177
- tex << "\\begin{struktogramm}(#{@x},#{@y})[#{@title}]"
178
- tex << @elements.to_structex.map{|e|
179
- #~ "\t#{e}"
180
- "#{e}"
181
- }
182
- tex << '\end{struktogramm}'
183
- tex << '\end{centernss}' if options[:centernss]
184
- tex << nil
185
- #Gsub notwendig, da \pVar entgegen der Doku keine _ mag
186
- if REPL_UNDERSCORE
187
- return tex.join("\n").gsub(/_/, '\_')
188
- else
189
- return tex.join("\n")
190
- end
191
- end
192
- #Return for wiki2docgenerator
193
- def to_wiki( options = {} )
194
- return <<xx
66
+ def initialize( title, x, y, code = String.new )
67
+ @title = title
68
+ @sourcecode = code
69
+ @x = x
70
+ @y = y
71
+ @elements = []
72
+
73
+ @log = Log4r::Logger.new("Structogramm #{title}")
74
+ @log.outputters = Log4r::StdoutOutputter.new('log_stdout')
75
+ end
76
+
77
+ def <<(code)
78
+ @sourcecode << code
79
+ @sourcecode << "\n"
80
+ end
81
+ =begin rdoc
82
+ Analyse sourcecode and fill @elements
83
+
84
+ Supported elements:
85
+ * cmd
86
+ * IF ... THEN ... ELSE ... ENDIF
87
+ * CASE ... (SWITCH|WHEN) ... ENDCASE
88
+ * WHILE ... ENDWHILE
89
+ * SELECT ... ENDSELECT
90
+ * REPEAT ... UNTIL
91
+ * FOREVER ... ENDFOREVER
92
+ * <=: exit-command
93
+ * =>: sub-command
94
+ * <>: return-command
95
+ * (<->|<-|->) Define parameter for previous command
96
+
97
+ Usage see unit test.
98
+ =end
99
+ def analyse_sourcecode( code = @sourcecode )
100
+ stack = [ @elements ]
101
+ lastcmd = nil
102
+ code.each_line{|l|
103
+ l.strip!
104
+ case l
105
+ when /\A\s*#~/ #comment
106
+ when /\A%/
107
+ stack.last << l
108
+ when /ENDIF\s*(.*)/, /ENDCASE\s*(.*)/,
109
+ /ENDWHILE\s*(.*)/, /ENDFOREVER\s*(.*)/,
110
+ /ENDSELECT\s*(.*)/
111
+ #~ @elements << "\\ifend"
112
+ stack.pop #close actual IF
113
+ lastcmd = nil
114
+ when /IF\s*(.*)/
115
+ #~ @elements << "\\ifthenelse{3}{3}{#{$1}}{\\pTrue}{\\pFalse}"
116
+ struct = Structogramm_IF.new(inline($1))
117
+ stack.last << struct
118
+ stack << struct
119
+ lastcmd = nil
120
+ when /THEN\s*(\d)?\s*(.*)/
121
+ stack.last.thensize = $1 if $1
122
+ stack.last.thentext = inline($2) if $2 and ! $2.empty?
123
+ lastcmd = nil
124
+ when /ELSE\s*(\d)?\s*(.*)/
125
+ stack.last.elsesize = $1 if $1
126
+ stack.last.elsetext = inline($2) if $2 and ! $2.empty?
127
+ #~ @elements << "\\change"
128
+ stack.last.else
129
+ lastcmd = nil
130
+ when /CASE\s*(\d)?\s*(.*)/
131
+ struct = Structogramm_CASE.new( inline($2), $1, @log)
132
+ stack.last << struct
133
+ stack << struct
134
+ lastcmd = nil
135
+ when /(?:SWITCH|WHEN)(?:\[([crl])\])?\s*(.*)/
136
+ stack.last.switch(inline($2), $1)
137
+ lastcmd = nil
138
+ when /WHILE\s*(.*)/, /SELECT\s*(.*)/
139
+ struct = Structogramm_WHILE.new(inline($1))
140
+ stack.last << struct
141
+ stack << struct
142
+ lastcmd = nil
143
+ when /REPEAT\s*(.*)/
144
+ struct = Structogramm_REPEAT.new(inline($1))
145
+ stack.last << struct
146
+ stack << struct
147
+ lastcmd = nil
148
+ when /UNTIL\s*(.*)/
149
+ stack.last.condition = $1
150
+ stack.pop #close actual IF
151
+ lastcmd = nil
152
+ when /FOREVER\s*(.*)/
153
+ struct = Structogramm_FOREVER.new()
154
+ stack.last << struct
155
+ stack << struct
156
+ lastcmd = nil
157
+ when /<=\s*(.*)/
158
+ stack.last << lastcmd = Structogramm_CMD.new( "exit", inline($1) )
159
+ when /=>\s*(.*)/
160
+ stack.last << lastcmd = Structogramm_CMD.new( "sub", inline($1) )
161
+ when /<>\s*(.*)/
162
+ stack.last << lastcmd = Structogramm_CMD.new( "return", inline($1) )
163
+ when /(<->|<-|->)\s*(\S+)\s*(.*)/
164
+ if ! lastcmd
165
+ @log.warn("description #{l} without command") if @log.warn?
166
+ else
167
+ lastcmd.par << PARSTRUCT.new($1, inline($2), $3 )
168
+ end
169
+ else
170
+ stack.last << lastcmd = Structogramm_CMD.new( "assign", inline(l) )
171
+ end
172
+ }
173
+ end
174
+ def inline( inp )
175
+ #~ return inp.gsub(/'(.*?)'/, '\\pKey{\1}')
176
+ return Document.texify(inp).gsub(/'(.*?)'/, '\\pKey{\1}').gsub(/->/, '$\to$')
177
+ end
178
+ def to_s()
179
+ @sourcecode
180
+ end
181
+ #Print the source code in a verbatim environmet
182
+ def verbatim()
183
+ return element(:verbatim,{},@sourcecode.gsub(/\t/, ' ')).cR
184
+ end
185
+ #
186
+ #Option:
187
+ #-:centernss Flag if the structogramm should be entered in an environment.
188
+ def to_latex( options = {} )
189
+ options = options.merge( :centernss => true )
190
+ analyse_sourcecode()
191
+ tex = [nil]
192
+ tex << '\begin{centernss}' if options[:centernss]
193
+ tex << "\\begin{struktogramm}(#{@x},#{@y})[#{@title}]"
194
+ tex << @elements.to_structex.map{|e|
195
+ #~ "\t#{e}"
196
+ "#{e}"
197
+ }
198
+ tex << '\end{struktogramm}'
199
+ tex << '\end{centernss}' if options[:centernss]
200
+ tex << nil
201
+ #Gsub notwendig, da \pVar entgegen der Doku keine _ mag
202
+ if REPL_UNDERSCORE
203
+ return tex.join("\n").gsub(/_/, '\_')
204
+ else
205
+ return tex.join("\n")
206
+ end
207
+ end
208
+ #Return for wiki2docgenerator
209
+ def to_wiki( options = {} )
210
+ return <<xx
195
211
  >>>structogramm{#{@title};#{@x};#{@y}}
196
212
  #{@sourcecode}
197
213
  <<<
198
214
  xx
199
- end #to_wiki
200
- #Return for creole2doc
201
- def to_creole( options = {} )
202
- return <<xx
215
+ end #to_wiki
216
+ #Return for creole2doc
217
+ def to_creole( options = {} )
218
+ return <<xx
203
219
  <<<structogramm|#{@title};#{@x};#{@y}
204
220
  #{@sourcecode}
205
221
  >>>
206
222
  xx
207
- end #to_creole
208
-
209
-
210
- #Save TEX-code
211
- def save( filename, overwrite = false )
212
-
213
- old = nil
214
- File.open( filename ){|f| old = f.readlines.to_s } if File.exists?(filename)
215
-
216
- if /\.nss/ =~ filename
217
- new = self.to_latex(:centernss => false)
218
- else
219
- new = self.to_latex()
220
- end
221
- if old != new
222
- if overwrite or old == nil
223
- File.open( filename, 'w'){|f|
224
- f << new
225
- }
226
- @log.INFO("Save changed #{filename}") if @log.INFO?
227
- else
228
- @log.info("Changed #{filename}")
229
- end
230
- else
231
- @log.INFO("Unchanged #{filename}") if @log.INFO?
232
- end
233
- #~ doc = Document.new(:include)
234
- #~ doc.body << self.to_tex()
235
- #~ doc.save( filename, overwrite )
236
- end
237
- end #Structogramm
223
+ end #to_creole
224
+
225
+
226
+ #Save TEX-code
227
+ def save( filename, overwrite = false )
228
+
229
+ old = nil
230
+ File.open( filename ){|f| old = f.readlines.to_s } if File.exists?(filename)
231
+
232
+ if /\.nss/ =~ filename
233
+ new = self.to_latex(:centernss => false)
234
+ else
235
+ new = self.to_latex()
236
+ end
237
+ if old != new
238
+ if overwrite or old == nil
239
+ File.open( filename, 'w'){|f|
240
+ f << new
241
+ }
242
+ @log.INFO("Save changed #{filename}") if @log.INFO?
243
+ else
244
+ @log.info("Changed #{filename}")
245
+ end
246
+ else
247
+ @log.INFO("Unchanged #{filename}") if @log.INFO?
248
+ end
249
+ #~ doc = Document.new(:include)
250
+ #~ doc.body << self.to_tex()
251
+ #~ doc.save( filename, overwrite )
252
+ end
253
+ end #Structogramm
238
254
 
239
255
 
240
- class Structogramm_CMD
241
- def initialize( type, cmd )
242
- @type = type
243
- @cmd = [ cmd ]
244
- @par = []
245
- end
246
- #Interface definition of command.
247
- attr_reader :par
248
- #Add command... into if or else-branch
249
- #~ def << (add)
250
- #~ @cmd << add
251
- #~ end
252
- def to_structex()
253
- tex = []
254
- tex << "\\#{@type}{#{@cmd.join}"
255
- if ! @par.empty?
256
- #~ tex << "\\\\\\\\\n"
257
- tex << "\\\\\n"
258
- tex << interface(@par, nil)
259
- #~ tex << interface(@par, 'Interface')
260
- end
261
- tex << "}"
262
- return tex.join()
263
- end
264
- def interface( list, text )
265
- return nil if list.empty?
266
- interface = [ "\\begin{declaration}[#{text}]" ]
267
- list.each{|par|
268
- dir = nil
269
- case par.dir
270
- when '->'; dir = '$\\Rightarrow$'
271
- when '<-'; dir = '$\\Leftarrow$'
272
- when '<->'; dir = '$\\Leftrightarrow$'
273
- end
274
- #par.name may contain _
275
- interface << "\\description{#{dir}\t#{par.name}}{#{par.text}}"
276
- }
277
- interface << "\\end{declaration}\n"
278
- return interface.join("\n")
279
- end
280
- def inspect()
281
- return "#<Structogramm_CMD: #{@type}>"
282
- #~ return "#<IF: #{@ifstatement}>"
283
- end
284
- end
256
+ class Structogramm_CMD
257
+ def initialize( type, cmd )
258
+ @type = type
259
+ @cmd = [ cmd ]
260
+ @par = []
261
+ end
262
+ #Interface definition of command.
263
+ attr_reader :par
264
+ #Add command... into if or else-branch
265
+ #~ def << (add)
266
+ #~ @cmd << add
267
+ #~ end
268
+ def to_structex()
269
+ tex = []
270
+ tex << "\\#{@type}{#{@cmd.join}"
271
+ if ! @par.empty?
272
+ #~ tex << "\\\\\\\\\n"
273
+ tex << "\\\\\n"
274
+ tex << interface(@par, nil)
275
+ #~ tex << interface(@par, 'Interface')
276
+ end
277
+ tex << "}"
278
+ return tex.join()
279
+ end
280
+ def interface( list, text )
281
+ return nil if list.empty?
282
+ interface = [ "\\begin{declaration}[#{text}]" ]
283
+ list.each{|par|
284
+ dir = nil
285
+ case par.dir
286
+ when '->'; dir = '$\\Rightarrow$'
287
+ when '<-'; dir = '$\\Leftarrow$'
288
+ when '<->'; dir = '$\\Leftrightarrow$'
289
+ end
290
+ #par.name may contain _
291
+ interface << "\\description{#{dir}\t#{par.name}}{#{par.text}}"
292
+ }
293
+ interface << "\\end{declaration}\n"
294
+ return interface.join("\n")
295
+ end
296
+ def inspect()
297
+ return "#<Structogramm_CMD: #{@type}>"
298
+ #~ return "#<IF: #{@ifstatement}>"
299
+ end
300
+ end
285
301
 
286
- class Structogramm_WHILE
287
- def initialize( whilestatement )
288
- @whilestatement = whilestatement
289
- @cmd = []
290
- end
291
- #Add command... into if or else-branch
292
- def << (add)
293
- @cmd << add
294
- end
295
- def to_structex()
296
- tex = []
297
- tex << "\\while{#{@whilestatement}}"
298
- tex << @cmd.to_structex
299
- tex << "\\whileend"
300
- return tex.join("\n")
301
- end
302
- def inspect()
303
- return "#<Structogramm_WHILE: #{@whilestatement}>"
304
- #~ return "#<IF: #{@ifstatement}>"
305
- end
306
- end
302
+ class Structogramm_WHILE
303
+ def initialize( whilestatement )
304
+ @whilestatement = whilestatement
305
+ @cmd = []
306
+ end
307
+ #Add command... into if or else-branch
308
+ def << (add)
309
+ @cmd << add
310
+ end
311
+ def to_structex()
312
+ tex = []
313
+ tex << "\\while{#{@whilestatement}}"
314
+ tex << @cmd.to_structex
315
+ tex << "\\whileend"
316
+ return tex.join("\n")
317
+ end
318
+ def inspect()
319
+ return "#<Structogramm_WHILE: #{@whilestatement}>"
320
+ #~ return "#<IF: #{@ifstatement}>"
321
+ end
322
+ end
307
323
 
308
- class Structogramm_REPEAT
309
- def initialize( repeatstatement )
310
- @condition = repeatstatement
311
- @cmd = []
312
- end
313
- attr_accessor :condition
314
- #Add command... into if or else-branch
315
- def << (add)
316
- @cmd << add
317
- end
318
- def to_structex()
319
- tex = []
320
- tex << "\\until{#{@condition}}"
321
- tex << @cmd.to_structex
322
- tex << "\\untilend"
323
- return tex.join("\n")
324
- end
325
- def inspect()
326
- return "#<Structogramm_REPEAT: #{@condition}>"
327
- #~ return "#<IF: #{@ifstatement}>"
328
- end
329
- end
324
+ class Structogramm_REPEAT
325
+ def initialize( repeatstatement )
326
+ @condition = repeatstatement
327
+ @cmd = []
328
+ end
329
+ attr_accessor :condition
330
+ #Add command... into if or else-branch
331
+ def << (add)
332
+ @cmd << add
333
+ end
334
+ def to_structex()
335
+ tex = []
336
+ tex << "\\until{#{@condition}}"
337
+ tex << @cmd.to_structex
338
+ tex << "\\untilend"
339
+ return tex.join("\n")
340
+ end
341
+ def inspect()
342
+ return "#<Structogramm_REPEAT: #{@condition}>"
343
+ #~ return "#<IF: #{@ifstatement}>"
344
+ end
345
+ end
330
346
 
331
- class Structogramm_FOREVER
332
- def initialize()
333
- @cmd = []
334
- end
335
- #Add command... into if or else-branch
336
- def << (add)
337
- @cmd << add
338
- end
339
- def to_structex()
340
- tex = []
341
- tex << "\\forever"
342
- tex << @cmd.to_structex
343
- tex << "\\foreverend"
344
- return tex.join("\n")
345
- end
346
- def inspect()
347
- return "#<Structogramm_FOREVER>"
348
- #~ return "#<IF: #{@ifstatement}>"
349
- end
350
- end
347
+ class Structogramm_FOREVER
348
+ def initialize()
349
+ @cmd = []
350
+ end
351
+ #Add command... into if or else-branch
352
+ def << (add)
353
+ @cmd << add
354
+ end
355
+ def to_structex()
356
+ tex = []
357
+ tex << "\\forever"
358
+ tex << @cmd.to_structex
359
+ tex << "\\foreverend"
360
+ return tex.join("\n")
361
+ end
362
+ def inspect()
363
+ return "#<Structogramm_FOREVER>"
364
+ #~ return "#<IF: #{@ifstatement}>"
365
+ end
366
+ end
351
367
 
352
- class Structogramm_IF
353
- def initialize( ifstatement )
354
- @ifstatement = ifstatement
355
- @then = []
356
- @else = nil #keep it empty, until method 'else' is called
357
- @thentext = '\\pTrue'
358
- @elsetext = '\\pFalse'
359
- @thensize = 3
360
- @elsesize = 3
361
- end
362
- #Text for 'then'-Branch. default: \pTrue
363
- attr_writer :thentext
364
- #Text for 'else'-Branch
365
- attr_writer :elsetext
366
- #Textwidth for 'then'-Branch
367
- attr_writer :thensize
368
- #Textwidth for 'else'-Branch
369
- attr_writer :elsesize
370
- #Add command... into if or else-branch
371
- def << (add)
372
- @else ? @else << add : @then << add
373
- end
374
- #Change from then-branch to else-branch
375
- def else()
376
- @else = []
377
- end
378
- def to_structex()
379
- tex = []
380
- tex << "\\ifthenelse{#{@thensize}}{#{@elsesize}}{#{@ifstatement}}{#{@thentext}}{#{@elsetext}}"
381
- tex << @then.to_structex
382
- tex << "\\change"
383
- tex << @else.to_structex
384
- tex << "\\ifend"
385
- return tex.join("\n")
386
- end
387
- def inspect()
388
- return "#<Structogramm_IF: #{@ifstatement}>"
389
- #~ return "#<IF: #{@ifstatement}>"
390
- end
391
- end
368
+ class Structogramm_IF
369
+ def initialize( ifstatement )
370
+ @ifstatement = ifstatement
371
+ @then = []
372
+ @else = nil #keep it empty, until method 'else' is called
373
+ @thentext = '\\pTrue'
374
+ @elsetext = '\\pFalse'
375
+ @thensize = 3
376
+ @elsesize = 3
377
+ end
378
+ #Text for 'then'-Branch. default: \pTrue
379
+ attr_writer :thentext
380
+ #Text for 'else'-Branch
381
+ attr_writer :elsetext
382
+ #Textwidth for 'then'-Branch
383
+ attr_writer :thensize
384
+ #Textwidth for 'else'-Branch
385
+ attr_writer :elsesize
386
+ #Add command... into if or else-branch
387
+ def << (add)
388
+ @else ? @else << add : @then << add
389
+ end
390
+ #Change from then-branch to else-branch
391
+ def else()
392
+ @else = []
393
+ end
394
+ def to_structex()
395
+ tex = []
396
+ tex << "\\ifthenelse{#{@thensize}}{#{@elsesize}}{#{@ifstatement}}{#{@thentext}}{#{@elsetext}}"
397
+ tex << @then.to_structex
398
+ tex << "\\change"
399
+ tex << @else.to_structex
400
+ tex << "\\ifend"
401
+ return tex.join("\n")
402
+ end
403
+ def inspect()
404
+ return "#<Structogramm_IF: #{@ifstatement}>"
405
+ #~ return "#<IF: #{@ifstatement}>"
406
+ end
407
+ end
392
408
 
393
- class Structogramm_CASE
394
- def initialize( casevar, degree = 4, log = Log4r::Logger.new('log') )
395
- @casevar = casevar
396
- @degree = degree.to_i
397
- if @degree == 0
398
- @log.warn("CASE #{casevar} mit degree 0") if @log.warn?
399
- end
400
- @cmd = []
401
- @switches = [] #List of branches.
402
- end
403
- def << (add)
404
- @cmd << add
405
- end
406
- #Change branch.
407
- def switch( condition, option = nil )
408
- switch = Structogramm_SWITCH.new( condition, option )
409
- #The first branch is part of the \case-statement
410
- @cmd << switch if ! @switches.empty?
411
- @switches << switch
412
- end
413
- def to_structex()
414
- tex = []
415
- tex << "\\case{#{@degree}}{#{@switches.size}}{#{@casevar}}{#{@switches.first.value}}"
416
- tex << @cmd.to_structex
417
- tex << "\\caseend"
418
- return tex.join("\n")
419
- end
420
- def inspect()
421
- return "#<Structogramm_CASE: #{@casestatement}>"
422
- #~ return "#<IF: #{@ifstatement}>"
423
- end
424
- end
409
+ class Structogramm_CASE
410
+ def initialize( casevar, degree = 4, log = Log4r::Logger.new('log') )
411
+ @casevar = casevar
412
+ @degree = degree.to_i
413
+ if @degree == 0
414
+ @log.warn("CASE #{casevar} mit degree 0") if @log.warn?
415
+ end
416
+ @cmd = []
417
+ @switches = [] #List of branches.
418
+ end
419
+ def << (add)
420
+ @cmd << add
421
+ end
422
+ #Change branch.
423
+ def switch( condition, option = nil )
424
+ switch = Structogramm_SWITCH.new( condition, option )
425
+ #The first branch is part of the \case-statement
426
+ @cmd << switch if ! @switches.empty?
427
+ @switches << switch
428
+ end
429
+ def to_structex()
430
+ tex = []
431
+ tex << "\\case{#{@degree}}{#{@switches.size}}{#{@casevar}}{#{@switches.first.value}}"
432
+ tex << @cmd.to_structex
433
+ tex << "\\caseend"
434
+ return tex.join("\n")
435
+ end
436
+ def inspect()
437
+ return "#<Structogramm_CASE: #{@casestatement}>"
438
+ #~ return "#<IF: #{@ifstatement}>"
439
+ end
440
+ end
425
441
 
426
- class Structogramm_SWITCH
427
- def initialize( value, option )
428
- @value = value
429
- @option = option
430
- end
431
- attr_reader :value
432
- def to_structex()
433
- tex = []
434
- tex << "\\switch"
435
- tex << "[#{@option}]" if @option
436
- tex << "{#{@value}}"
437
- return tex.join()
438
- end
439
- def inspect()
440
- return "#<Structogramm_SWITCH: #{@value}>"
441
- #~ return "#<IF: #{@ifstatement}>"
442
- end
443
- end
442
+ class Structogramm_SWITCH
443
+ def initialize( value, option )
444
+ @value = value
445
+ @option = option
446
+ end
447
+ attr_reader :value
448
+ def to_structex()
449
+ tex = []
450
+ tex << "\\switch"
451
+ tex << "[#{@option}]" if @option
452
+ tex << "{#{@value}}"
453
+ return tex.join()
454
+ end
455
+ def inspect()
456
+ return "#<Structogramm_SWITCH: #{@value}>"
457
+ #~ return "#<IF: #{@ifstatement}>"
458
+ end
459
+ end
444
460
 
445
- end #module Struktex
446
- end #module Packages
461
+ end #module Struktex
462
+ end #module Packages
447
463
  end #module Docgenerator