docgenerator 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docgenerator.rb +18 -18
- data/lib/docgenerator/characters.rb +1 -0
- data/lib/docgenerator/css.rb +5 -0
- data/lib/docgenerator/document.rb +7 -2
- data/lib/docgenerator/element.rb +2 -2
- data/lib/docgenerator/elements.rb +69 -2
- data/lib/docgenerator/index.rb +1 -1
- data/lib/docgenerator/packages/listings.rb +94 -94
- data/lib/docgenerator/packages/multicol.rb +1 -1
- data/lib/docgenerator/packages/pdfpages.rb +2 -1
- data/lib/docgenerator/packages/rubycode4doc.rb +173 -172
- data/lib/docgenerator/packages/struktex.rb +395 -379
- data/lib/docgenerator/packages/todonotes.rb +2 -2
- data/lib/docgenerator/packages/url.rb +4 -0
- data/lib/docgenerator/sections.rb +24 -2
- data/lib/docgenerator/tabular.rb +59 -14
- data/lib/docgenerator/templates/docgenerator_template.rb +1 -0
- data/lib/docgenerator/templates/docgenerator_template.yaml +30 -1
- data/lib/docgenerator/version.rb +13 -1
- data/meta_test_and_doc/build__meta.rb +3 -10
- data/meta_test_and_doc/build_doc.rb +4 -2
- data/meta_test_and_doc/build_test.rb +21 -17
- data/meta_test_and_doc/manpages/images.rb +152 -0
- data/unittest/expected/test_document_toc_article.latex +6 -6
- data/unittest/expected_struktex/test_struktex_krug.creole +5 -5
- data/unittest/expected_struktex/test_struktex_krug.wiki +5 -5
- data/unittest/expected_struktex/test_struktex_statement.creole +4 -4
- data/unittest/expected_struktex/test_struktex_statement.wiki +4 -4
- data/unittest/expected_templates/test_report_utf8.tex +34 -0
- data/unittest/expected_templates/test_standalone.tex +2 -1
- data/unittest/unittest_docgenerator.rb +37 -30
- data/unittest/unittest_docgenerator_characters.rb +113 -60
- data/unittest/unittest_docgenerator_runtex.rb +16 -12
- data/unittest/unittest_packages_multicol.rb +4 -9
- data/unittest/unittest_packages_struktex.rb +66 -90
- data/unittest/unittest_rubycode4doc.rb +38 -241
- data/unittest/unittest_templates.rb +4 -8
- metadata +23 -560
- data/examples/creole_example.rb +0 -81
- data/examples/creole_example_footnote.rb +0 -67
- data/examples/creole_example_new_plugin.rb +0 -51
- data/examples/creole_example_placeholder.rb +0 -77
- data/examples/creole_example_rail.rb +0 -154
- data/examples/creole_example_rubycode.rb +0 -144
- data/examples/creole_example_struktex.rb +0 -169
- data/examples/creole_example_tabular.rb +0 -97
- data/examples/wiki2docgenerator_example.rb +0 -299
- data/lib/creole/creole2doc.rb +0 -954
- data/lib/creole/creole_characters.rb +0 -120
- data/lib/creole/creole_inclusion_and_plugins.rb +0 -96
- data/lib/creole/creole_inclusions.rb +0 -154
- data/lib/creole/creole_placeholder.rb +0 -171
- data/lib/creole/creole_plugins.rb +0 -230
- data/lib/creole/creole_tabular.rb +0 -401
- data/lib/creole/plugins/rail.rb +0 -181
- data/lib/creole/plugins/rubycode4creole.rb +0 -136
- data/lib/creole/plugins/struktex.rb +0 -59
- data/lib/creole/plugins/todonotes.rb +0 -77
- data/lib/wiki2doc/plugins/rubycode4wiki.rb +0 -53
- data/lib/wiki2doc/plugins/struktex.rb +0 -12
- data/lib/wiki2doc/wiki2docgenerator.rb +0 -1276
- data/lib/wiki2doc/wikimedia_document.rb +0 -24
- data/meta_test_and_doc/manpages/packages.rb +0 -13
- data/unittest/Red_Flower.jpg +0 -0
- data/unittest/creole1.0test.txt +0 -128
- data/unittest/creole_testtext.creole +0 -11
- data/unittest/expected_creole/test_creole.html +0 -3
- data/unittest/expected_creole/test_creole_characters_all.creole +0 -28
- data/unittest/expected_creole/test_creole_characters_all.html +0 -18
- data/unittest/expected_creole/test_creole_characters_all.latex +0 -36
- data/unittest/expected_creole/test_creole_characters_special.html +0 -10
- data/unittest/expected_creole/test_creole_characters_special.latex +0 -18
- data/unittest/expected_creole/test_creole_comment.context +0 -11
- data/unittest/expected_creole/test_creole_comment.creole +0 -12
- data/unittest/expected_creole/test_creole_comment.html +0 -9
- data/unittest/expected_creole/test_creole_comment.latex +0 -11
- data/unittest/expected_creole/test_creole_countdown.html +0 -3
- data/unittest/expected_creole/test_creole_countdown.latex +0 -4
- data/unittest/expected_creole/test_creole_creole1.0test.html +0 -182
- data/unittest/expected_creole/test_creole_creole1.0test.latex +0 -253
- data/unittest/expected_creole/test_creole_creole1.0test.text +0 -160
- data/unittest/expected_creole/test_creole_footnotes.html +0 -9
- data/unittest/expected_creole/test_creole_footnotes.latex +0 -14
- data/unittest/expected_creole/test_creole_footnotes_groupid.html +0 -15
- data/unittest/expected_creole/test_creole_footnotes_label.html +0 -9
- data/unittest/expected_creole/test_creole_headings.html +0 -17
- data/unittest/expected_creole/test_creole_headings.latex +0 -19
- data/unittest/expected_creole/test_creole_headings.text +0 -48
- data/unittest/expected_creole/test_creole_headings.wiki +0 -37
- data/unittest/expected_creole/test_creole_hr.html +0 -7
- data/unittest/expected_creole/test_creole_hr.latex +0 -9
- data/unittest/expected_creole/test_creole_hr.text +0 -4
- data/unittest/expected_creole/test_creole_ignore.html +0 -3
- data/unittest/expected_creole/test_creole_ignore.latex +0 -4
- data/unittest/expected_creole/test_creole_ignore.text +0 -2
- data/unittest/expected_creole/test_creole_inline.html +0 -3
- data/unittest/expected_creole/test_creole_inline.latex +0 -4
- data/unittest/expected_creole/test_creole_inline.text +0 -2
- data/unittest/expected_creole/test_creole_inline_apostroph.html +0 -6
- data/unittest/expected_creole/test_creole_inline_apostroph.latex +0 -8
- data/unittest/expected_creole/test_creole_inline_apostroph.text +0 -4
- data/unittest/expected_creole/test_creole_inline_ruby.html +0 -12
- data/unittest/expected_creole/test_creole_inline_ruby.latex +0 -20
- data/unittest/expected_creole/test_creole_inline_ruby_raw.html +0 -6
- data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +0 -8
- data/unittest/expected_creole/test_creole_input.normsource +0 -25
- data/unittest/expected_creole/test_creole_input.normsource_1.8 +0 -23
- data/unittest/expected_creole/test_creole_input_file_simple.html +0 -15
- data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +0 -15
- data/unittest/expected_creole/test_creole_label.html +0 -12
- data/unittest/expected_creole/test_creole_label.latex +0 -15
- data/unittest/expected_creole/test_creole_line_break.html +0 -6
- data/unittest/expected_creole/test_creole_line_break.latex +0 -8
- data/unittest/expected_creole/test_creole_links_explicit_internal.html +0 -6
- data/unittest/expected_creole/test_creole_links_explicit_internal.text +0 -4
- data/unittest/expected_creole/test_creole_links_explicit_with_em.html +0 -3
- data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +0 -4
- data/unittest/expected_creole/test_creole_links_explicit_with_em.text +0 -2
- data/unittest/expected_creole/test_creole_links_external.html +0 -6
- data/unittest/expected_creole/test_creole_links_external.latex +0 -8
- data/unittest/expected_creole/test_creole_links_external.text +0 -4
- data/unittest/expected_creole/test_creole_links_external_implicit.html +0 -9
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +0 -12
- data/unittest/expected_creole/test_creole_links_external_implicit.text +0 -6
- data/unittest/expected_creole/test_creole_links_file.html +0 -6
- data/unittest/expected_creole/test_creole_links_file.latex +0 -8
- data/unittest/expected_creole/test_creole_links_file.text +0 -4
- data/unittest/expected_creole/test_creole_links_implicit_end.creole +0 -4
- data/unittest/expected_creole/test_creole_links_implicit_end.html +0 -3
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +0 -4
- data/unittest/expected_creole/test_creole_list_ol.html +0 -12
- data/unittest/expected_creole/test_creole_list_ol.latex +0 -22
- data/unittest/expected_creole/test_creole_list_ol_after_ul.html +0 -12
- data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +0 -20
- data/unittest/expected_creole/test_creole_list_ol_after_ul.text +0 -6
- data/unittest/expected_creole/test_creole_list_ol_ul.html +0 -15
- data/unittest/expected_creole/test_creole_list_ol_ul.latex +0 -26
- data/unittest/expected_creole/test_creole_list_ul.html +0 -22
- data/unittest/expected_creole/test_creole_list_ul.latex +0 -40
- data/unittest/expected_creole/test_creole_list_ul.normsource +0 -89
- data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +0 -83
- data/unittest/expected_creole/test_creole_list_ul_too_much.html +0 -24
- data/unittest/expected_creole/test_creole_list_ul_too_much.latex +0 -44
- data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +0 -6
- data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +0 -12
- data/unittest/expected_creole/test_creole_mix_titles_list.html +0 -10
- data/unittest/expected_creole/test_creole_mix_titles_list.latex +0 -18
- data/unittest/expected_creole/test_creole_mix_titles_list.text +0 -12
- data/unittest/expected_creole/test_creole_newline.html +0 -9
- data/unittest/expected_creole/test_creole_newline.latex +0 -11
- data/unittest/expected_creole/test_creole_newline.text +0 -7
- data/unittest/expected_creole/test_creole_paragraphs.html +0 -6
- data/unittest/expected_creole/test_creole_paragraphs.latex +0 -8
- data/unittest/expected_creole/test_creole_paragraphs.normsource +0 -29
- data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +0 -27
- data/unittest/expected_creole/test_creole_paragraphs.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs.wiki +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap.html +0 -5
- data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +0 -6
- data/unittest/expected_creole/test_creole_paragraphs_wrap.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +0 -9
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +0 -11
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +0 -7
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +0 -7
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +0 -5
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +0 -6
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +0 -4
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +0 -4
- data/unittest/expected_creole/test_creole_picture_link.html +0 -6
- data/unittest/expected_creole/test_creole_pictures.html +0 -10
- data/unittest/expected_creole/test_creole_pictures.latex +0 -13
- data/unittest/expected_creole/test_creole_pictures_css.html +0 -6
- data/unittest/expected_creole/test_creole_pictures_css.latex +0 -8
- data/unittest/expected_creole/test_creole_pictures_imgclass.html +0 -6
- data/unittest/expected_creole/test_creole_pictures_imgclass.latex +0 -8
- data/unittest/expected_creole/test_creole_pictures_longdesc.html +0 -3
- data/unittest/expected_creole/test_creole_pictures_width.html +0 -3
- data/unittest/expected_creole/test_creole_pictures_width.latex +0 -4
- data/unittest/expected_creole/test_creole_placeholders_html.html +0 -7
- data/unittest/expected_creole/test_creole_placeholders_html.latex +0 -8
- data/unittest/expected_creole/test_creole_placeholders_html.text +0 -4
- data/unittest/expected_creole/test_creole_placeholders_latex.html +0 -6
- data/unittest/expected_creole/test_creole_placeholders_latex.latex +0 -9
- data/unittest/expected_creole/test_creole_placeholders_latex.text +0 -4
- data/unittest/expected_creole/test_creole_short_html.html +0 -3
- data/unittest/expected_creole/test_creole_short_html.latex +0 -4
- data/unittest/expected_creole/test_creole_short_html.text +0 -2
- data/unittest/expected_creole/test_creole_shy.creole +0 -6
- data/unittest/expected_creole/test_creole_shy.html +0 -6
- data/unittest/expected_creole/test_creole_shy.latex +0 -8
- data/unittest/expected_creole/test_creole_shy.text +0 -4
- data/unittest/expected_creole/test_creole_tabular.creole +0 -22
- data/unittest/expected_creole/test_creole_tabular.html +0 -20
- data/unittest/expected_creole/test_creole_tabular.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_creole.creole +0 -19
- data/unittest/expected_creole/test_creole_tabular_creole.html +0 -18
- data/unittest/expected_creole/test_creole_tabular_creole.latex +0 -19
- data/unittest/expected_creole/test_creole_tabular_css.creole +0 -24
- data/unittest/expected_creole/test_creole_tabular_css.html +0 -20
- data/unittest/expected_creole/test_creole_tabular_css.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_multicols.creole +0 -16
- data/unittest/expected_creole/test_creole_tabular_multicols.html +0 -14
- data/unittest/expected_creole/test_creole_tabular_multicols.latex +0 -16
- data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +0 -22
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +0 -21
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +0 -20
- data/unittest/expected_creole/test_creole_toc.html +0 -13
- data/unittest/expected_creole/test_creole_toc.latex +0 -22
- data/unittest/expected_creole/test_creole_toc.text +0 -4
- data/unittest/expected_creole/test_creole_toc_level.html +0 -7
- data/unittest/expected_creole/test_creole_toc_level.latex +0 -10
- data/unittest/expected_creole/test_creole_toc_level.text +0 -3
- data/unittest/expected_creole/test_creole_toc_level_text.html +0 -8
- data/unittest/expected_creole/test_creole_toc_level_text.latex +0 -9
- data/unittest/expected_creole/test_creole_toc_text.html +0 -5
- data/unittest/expected_creole/test_creole_toc_text.latex +0 -5
- data/unittest/expected_creole/test_creole_ul_multiple_line.html +0 -7
- data/unittest/expected_creole/test_creole_ul_multiple_line.latex +0 -14
- data/unittest/expected_creole/test_creole_ul_with_blank.html +0 -11
- data/unittest/expected_creole/test_creole_ul_with_blank.latex +0 -20
- data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.html +0 -11
- data/unittest/expected_creole/test_creole_ul_with_bold.latex +0 -18
- data/unittest/expected_creole/test_creole_ul_with_bold.text +0 -7
- data/unittest/expected_creole/test_creole_verbatim.html +0 -25
- data/unittest/expected_creole/test_creole_verbatim.latex +0 -33
- data/unittest/expected_creole/test_creole_verbatim.text +0 -17
- data/unittest/expected_creole/test_creole_verbatim_inline.html +0 -6
- data/unittest/expected_creole/test_creole_verbatim_inline.latex +0 -8
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +0 -6
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +0 -8
- data/unittest/expected_creole_rail/test_rail_creole_object.tex +0 -33
- data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +0 -40
- data/unittest/expected_rubycode4doc/creole_complete.html +0 -26
- data/unittest/expected_rubycode4doc/creole_complete.tex +0 -40
- data/unittest/expected_rubycode4doc/creole_in_tab.html +0 -4
- data/unittest/expected_rubycode4doc/creole_in_tab.tex +0 -6
- data/unittest/expected_rubycode4doc/creole_inline_ruby.html +0 -7
- data/unittest/expected_rubycode4doc/creole_output.html +0 -2
- data/unittest/expected_rubycode4doc/creole_output.tex +0 -4
- data/unittest/expected_rubycode4doc/creole_rubycode.html +0 -1
- data/unittest/expected_rubycode4doc/creole_rubycode.tex +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +0 -1
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +0 -3
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +0 -5
- data/unittest/expected_rubycode4doc/wiki_1.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_2.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_3.html +0 -9
- data/unittest/expected_rubycode4doc/wiki_immediate_1.html +0 -5
- data/unittest/expected_rubycode4doc/wiki_immediate_2.html +0 -5
- data/unittest/expected_rubycode4doc/wiki_immediate_3.html +0 -8
- data/unittest/expected_rubycode4doc/wiki_immediate_full.html +0 -21
- data/unittest/expected_wikimedia/test_wiki.html +0 -6
- data/unittest/expected_wikimedia/test_wiki.latex +0 -12
- data/unittest/expected_wikimedia/test_wiki.text +0 -14
- data/unittest/expected_wikimedia/test_wiki.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_description.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_description.latex +0 -11
- data/unittest/expected_wikimedia/test_wiki_description.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_description.wiki +0 -6
- data/unittest/expected_wikimedia/test_wiki_footnote.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_footnote.latex +0 -17
- data/unittest/expected_wikimedia/test_wiki_footnote.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_footnote.wiki +0 -10
- data/unittest/expected_wikimedia/test_wiki_footnote_2.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_footnote_groupid.html +0 -21
- data/unittest/expected_wikimedia/test_wiki_html_code.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_html_code.latex +0 -10
- data/unittest/expected_wikimedia/test_wiki_html_code.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_html_code.wiki +0 -6
- data/unittest/expected_wikimedia/test_wiki_inline.html +0 -6
- data/unittest/expected_wikimedia/test_wiki_inline.latex +0 -12
- data/unittest/expected_wikimedia/test_wiki_inline.text +0 -8
- data/unittest/expected_wikimedia/test_wiki_inline.wiki +0 -8
- data/unittest/expected_wikimedia/test_wiki_label.html +0 -6
- data/unittest/expected_wikimedia/test_wiki_link.html +0 -8
- data/unittest/expected_wikimedia/test_wiki_link.latex +0 -17
- data/unittest/expected_wikimedia/test_wiki_link.wiki +0 -11
- data/unittest/expected_wikimedia/test_wiki_list_ol.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ol.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.html +0 -16
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.latex +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.text +0 -8
- data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.wiki +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ol_ul.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ul.html +0 -24
- data/unittest/expected_wikimedia/test_wiki_list_ul.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_list_ul.text +0 -10
- data/unittest/expected_wikimedia/test_wiki_list_ul.wiki +0 -12
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.html +0 -39
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.latex +0 -51
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.text +0 -11
- data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.wiki +0 -15
- data/unittest/expected_wikimedia/test_wiki_picture.html +0 -55
- data/unittest/expected_wikimedia/test_wiki_picture.latex +0 -76
- data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +0 -5
- data/unittest/expected_wikimedia/test_wiki_tab1.html +0 -30
- data/unittest/expected_wikimedia/test_wiki_tab1.latex +0 -30
- data/unittest/expected_wikimedia/test_wiki_tab1.wiki +0 -29
- data/unittest/expected_wikimedia/test_wiki_textformatting.html +0 -7
- data/unittest/expected_wikimedia/test_wiki_textformatting.latex +0 -16
- data/unittest/expected_wikimedia/test_wiki_textformatting.text +0 -11
- data/unittest/expected_wikimedia/test_wiki_textformatting.wiki +0 -9
- data/unittest/expected_wikimedia/test_wiki_toc.html +0 -9
- data/unittest/expected_wikimedia/test_wiki_toc.latex +0 -18
- data/unittest/expected_wikimedia/test_wiki_toc.text +0 -21
- data/unittest/expected_wikimedia/test_wiki_toc.wiki +0 -18
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.html +0 -18
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.latex +0 -19
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.text +0 -6
- data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.wiki +0 -7
- data/unittest/unittest_creole.rb +0 -1361
- data/unittest/unittest_creole_placeholders.rb +0 -150
- data/unittest/unittest_creole_plugin_rail.rb +0 -147
- data/unittest/unittest_creole_tabular.rb +0 -207
- 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], [
|
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
|
-
|
9
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
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
|
-
|
150
|
-
|
151
|
-
#~ puts 'tabularx mag kein verbatim'
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
|
185
|
-
|
186
|
-
|
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
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
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',
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
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
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
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
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
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
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
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
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
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
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
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
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
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
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
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
|