docgenerator 1.2.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/build_test_and_doc.rb +505 -0
- data/examples/creole_example.rb +82 -0
- data/examples/creole_example_footnote.rb +67 -0
- data/examples/creole_example_placeholder.rb +77 -0
- data/examples/creole_example_rail.rb +154 -0
- data/examples/creole_example_rubycode.rb +144 -0
- data/examples/creole_example_struktex.rb +169 -0
- data/examples/docgenerator_example.rb +1 -1
- data/examples/docgenerator_example_footnote.rb +1 -0
- data/examples/docgenerator_example_list.rb +3 -0
- data/examples/docgenerator_example_restrictions.rb +1 -1
- data/examples/docgenerator_example_tabular.rb +1 -1
- data/examples/docgenerator_example_tripfalls.rb +2 -2
- data/examples/results/readme +2 -1
- data/examples/wiki2docgenerator_example.rb +61 -32
- data/lib/creole/creole2doc.rb +57 -58
- data/lib/creole/creole_characters.rb +56 -0
- data/lib/creole/creole_inclusion_and_plugins.rb +59 -284
- data/lib/creole/creole_inclusions.rb +142 -0
- data/lib/creole/creole_placeholder.rb +57 -23
- data/lib/creole/creole_plugins.rb +198 -0
- data/lib/creole/creole_tabular.rb +16 -8
- data/lib/creole/plugins/rail.rb +182 -0
- data/lib/creole/plugins/rubycode4creole.rb +136 -0
- data/lib/creole/plugins/struktex.rb +59 -0
- data/lib/creole/plugins/todonotes.rb +70 -0
- data/lib/docgenerator.rb +161 -71
- data/lib/docgenerator/attribute.rb +189 -156
- data/lib/docgenerator/characters.rb +824 -267
- data/lib/docgenerator/compatibility_v1.rb +249 -0
- data/lib/docgenerator/css.rb +53 -32
- data/lib/docgenerator/document.rb +119 -56
- data/lib/docgenerator/element.rb +304 -351
- data/lib/docgenerator/element_meta.rb +303 -0
- data/lib/docgenerator/elements.rb +1112 -481
- data/lib/docgenerator/environments.rb +153 -62
- data/lib/docgenerator/footnote.rb +30 -9
- data/lib/docgenerator/lists.rb +71 -47
- data/lib/docgenerator/packages/attachfile.rb +136 -0
- data/lib/{packages/docgenerator_caption.rb → docgenerator/packages/caption.rb} +28 -19
- data/lib/docgenerator/packages/hyperref.rb +194 -0
- data/lib/docgenerator/packages/listings.rb +179 -0
- data/lib/docgenerator/packages/pdfpages.rb +43 -0
- data/lib/docgenerator/packages/rubycode4doc.rb +227 -0
- data/lib/{packages/docgenerator_scrlettr2.rb → docgenerator/packages/scrlettr2.rb} +25 -16
- data/lib/docgenerator/packages/scrpage2.rb +410 -0
- data/lib/docgenerator/packages/struktex.rb +447 -0
- data/lib/docgenerator/packages/todonotes.rb +85 -0
- data/lib/{packages/docgenerator_url.rb → docgenerator/packages/url.rb} +7 -6
- data/lib/docgenerator/sections.rb +257 -83
- data/lib/docgenerator/standard.rb +19 -11
- data/lib/docgenerator/tabular.rb +234 -118
- data/lib/{templates → docgenerator/templates}/docgenerator_template.rb +52 -44
- data/lib/{templates → docgenerator/templates}/docgenerator_template.yaml +0 -0
- data/lib/{templates → docgenerator/templates}/docgenerator_template_css.rb +22 -16
- data/lib/wiki2doc/plugins/rubycode4wiki.rb +53 -0
- data/lib/wiki2doc/plugins/struktex.rb +12 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +39 -38
- data/lib/wiki2doc/wikimedia_document.rb +24 -0
- data/manpage_elements.rb +10411 -0
- data/readme.rd +34 -24
- data/unittest/creole_testtext.creole +11 -0
- data/unittest/expected/test_document_usepackage_undefined.log +2 -2
- data/unittest/expected/test_runtex.stdout +0 -1
- data/unittest/expected/test_runtex_2.stdout +0 -1
- data/unittest/expected/toc_css.css +3 -2
- data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
- data/unittest/expected_creole/test_creole_characters_all.html +15 -15
- data/unittest/expected_creole/test_creole_characters_all.latex +15 -15
- data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
- data/unittest/expected_creole/test_creole_links_file.html +2 -2
- data/unittest/expected_creole/test_creole_links_file.latex +2 -2
- data/unittest/expected_creole/test_creole_links_file.text +2 -2
- data/unittest/expected_creole/test_creole_picture_link.html +1 -1
- data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
- data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
- data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
- data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
- data/unittest/expected_rubycode4doc/creole_output.html +2 -0
- data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
- data/unittest/expected_rubycode4doc/wiki_1.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_2.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_3.html +9 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_1.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_2.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_3.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_full.html +21 -0
- data/unittest/expected_struktex/test_struktex_krug.creole +15 -0
- data/unittest/expected_struktex/test_struktex_krug.tex +19 -0
- data/unittest/expected_struktex/test_struktex_krug.wiki +15 -0
- data/unittest/expected_struktex/test_struktex_statement.creole +7 -0
- data/unittest/expected_struktex/test_struktex_statement.tex +9 -0
- data/unittest/expected_struktex/test_struktex_statement.wiki +7 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.html +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.latex +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.text +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.wiki +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_2.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_groupid.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_label.html +0 -0
- data/unittest/expected_wikimedia/test_wiki_link.html +8 -0
- data/unittest/expected_wikimedia/test_wiki_link.latex +17 -0
- data/unittest/expected_wikimedia/test_wiki_link.wiki +11 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.wiki +0 -0
- data/unittest/expected_wikimedia/test_wiki_picture.html +55 -0
- data/unittest/expected_wikimedia/test_wiki_picture.latex +76 -0
- data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +5 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.wiki +0 -0
- data/unittest/{unittest_creole2doc.rb → unittest_creole.rb} +385 -476
- data/unittest/unittest_creole_placeholders.rb +272 -0
- data/unittest/unittest_creole_plugin_rail.rb +147 -0
- data/unittest/unittest_docgenerator.rb +206 -332
- data/unittest/unittest_docgenerator_characters.rb +650 -0
- data/unittest/unittest_docgenerator_runtex.rb +48 -20
- data/unittest/unittest_packages_struktex.rb +187 -0
- data/unittest/unittest_rubycode4doc.rb +275 -0
- data/unittest/unittest_wikimedia.rb +479 -0
- metadata +245 -172
- data/examples/results_expected/docgenerator_example.html +0 -39
- data/examples/results_expected/docgenerator_example.pdf +0 -0
- data/examples/results_expected/docgenerator_example.tex +0 -56
- data/examples/results_expected/docgenerator_example_footnote.html +0 -40
- data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
- data/examples/results_expected/docgenerator_example_footnote.tex +0 -50
- data/examples/results_expected/docgenerator_example_list.html +0 -18
- data/examples/results_expected/docgenerator_example_list.pdf +0 -0
- data/examples/results_expected/docgenerator_example_list.tex +0 -46
- data/examples/results_expected/docgenerator_example_restrictions.html +0 -22
- data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
- data/examples/results_expected/docgenerator_example_restrictions.tex +0 -31
- data/examples/results_expected/docgenerator_example_tabular.html +0 -37
- data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tabular.tex +0 -41
- data/examples/results_expected/docgenerator_example_tripfalls.html +0 -27
- data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tripfalls.tex +0 -31
- data/lib/packages/docgenerator_attachfile.rb +0 -71
- data/lib/packages/docgenerator_hyperref.rb +0 -109
- data/lib/packages/docgenerator_listings.rb +0 -103
- data/lib/packages/docgenerator_pdfpages.rb +0 -24
- data/lib/packages/docgenerator_scrpage2.rb +0 -172
- data/self_docgenerator.rb +0 -163
- data/unittest/expected_wiki/test_wiki_link.html +0 -8
- data/unittest/expected_wiki/test_wiki_link.latex +0 -17
- data/unittest/expected_wiki/test_wiki_link.wiki +0 -11
- data/unittest/expected_wiki/test_wiki_picture.html +0 -55
- data/unittest/expected_wiki/test_wiki_picture.latex +0 -76
- data/unittest/expected_wiki/test_wiki_picture_thumb.html +0 -5
- data/unittest/test_rakefile_docgenerator.rb +0 -43
- data/unittest/unittest_versions.rb +0 -44
- data/unittest/unittest_wiki2doc.rb +0 -464
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
=begin rdoc
|
|
2
|
+
Code-generator for structex, a TeX-package to create Nassi-Shneidermann diagramms.
|
|
3
|
+
|
|
4
|
+
See examples a demonstration.
|
|
5
|
+
|
|
6
|
+
This plugin is defined for Creole and Wikitext.
|
|
7
|
+
Depending which classes are already defined, they are added as plugins.
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
require 'docgenerator'
|
|
11
|
+
|
|
12
|
+
=begin rdoc
|
|
13
|
+
Extend Array class to build structogramms.
|
|
14
|
+
=end
|
|
15
|
+
class Array
|
|
16
|
+
=begin rdoc
|
|
17
|
+
Recursive extension for all structogramm elements.
|
|
18
|
+
So we can avoid a check, if the method is available.
|
|
19
|
+
=end
|
|
20
|
+
def to_structex
|
|
21
|
+
return self.map{|e|
|
|
22
|
+
if e.respond_to?( :to_structex )
|
|
23
|
+
e.to_structex
|
|
24
|
+
else
|
|
25
|
+
e
|
|
26
|
+
end
|
|
27
|
+
}.flatten
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
module Docgenerator
|
|
33
|
+
module Packages
|
|
34
|
+
=begin rdoc
|
|
35
|
+
Classes to provide support for the LaTeX-class struktex.
|
|
36
|
+
|
|
37
|
+
* http://www.ctan.org/tex-archive/macros/latex/contrib/struktex/
|
|
38
|
+
=end
|
|
39
|
+
module Struktex
|
|
40
|
+
USEPACKAGE_STRUKTEX = element(:usepackage,{}, 'struktex').cr
|
|
41
|
+
USEPACKAGE_STRUKTEX_PROOF = '\sProofOn '
|
|
42
|
+
|
|
43
|
+
#Bug: \pVar mag entgegen der Doku keine _ mag
|
|
44
|
+
REPL_UNDERSCORE = false
|
|
45
|
+
|
|
46
|
+
=begin rdoc
|
|
47
|
+
Code-generator for structex, a TeX-package to create Nassi-Shneidermann diagramms.
|
|
48
|
+
|
|
49
|
+
This is no subclass of Element, the initialize-method should get it's own
|
|
50
|
+
parameters.
|
|
51
|
+
|
|
52
|
+
To define define ele Element-methods, module Element_methods is included.
|
|
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
|
|
63
|
+
=begin rdoc
|
|
64
|
+
Define a structogramm.
|
|
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
|
|
195
|
+
>>>structogramm{#{@title};#{@x};#{@y}}
|
|
196
|
+
#{@sourcecode}
|
|
197
|
+
<<<
|
|
198
|
+
xx
|
|
199
|
+
end #to_wiki
|
|
200
|
+
#Return for creole2doc
|
|
201
|
+
def to_creole( options = {} )
|
|
202
|
+
return <<xx
|
|
203
|
+
<<<structogramm|#{@title};#{@x};#{@y}
|
|
204
|
+
#{@sourcecode}
|
|
205
|
+
>>>
|
|
206
|
+
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
|
|
238
|
+
|
|
239
|
+
|
|
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
|
|
285
|
+
|
|
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
|
|
307
|
+
|
|
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
|
|
330
|
+
|
|
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
|
|
351
|
+
|
|
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
|
|
392
|
+
|
|
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
|
|
425
|
+
|
|
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
|
|
444
|
+
|
|
445
|
+
end #module Struktex
|
|
446
|
+
end #module Packages
|
|
447
|
+
end #module Docgenerator
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Docgenerator
|
|
2
|
+
module Packages
|
|
3
|
+
=begin rdoc
|
|
4
|
+
Support of the LaTeX-package todonotes.
|
|
5
|
+
|
|
6
|
+
* http://ctan.org/pkg/todonotes
|
|
7
|
+
=end
|
|
8
|
+
module Todonotes
|
|
9
|
+
=begin rdoc
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
...
|
|
13
|
+
\usepackage{todonotes}
|
|
14
|
+
...
|
|
15
|
+
\newcommand{\addref}{\todo[color=red!40]{Addreference.}}
|
|
16
|
+
\newcommand{\rewrite}[1]{\todo[color=green!40]{#1}}
|
|
17
|
+
...
|
|
18
|
+
% ----------------------------------------------------------------
|
|
19
|
+
\begin{document}
|
|
20
|
+
\blindtext\todo{AAA}\todo{BBB}\todo{CCC}\blindtext
|
|
21
|
+
|
|
22
|
+
\blindtext\todo{AAA}\todo[color=yellow]{BBB}\todo[color=green]{CCC}\blindtext
|
|
23
|
+
|
|
24
|
+
\blindtext\todo[inline]{AAA}\blindtext
|
|
25
|
+
=end
|
|
26
|
+
class Todo < Element
|
|
27
|
+
|
|
28
|
+
add_attributes( {
|
|
29
|
+
#~ disable The disable option can be given directly to the todo command. If given the command has no effect.
|
|
30
|
+
:color => Attribute.create( [ :texkeyval], [ String ] ),
|
|
31
|
+
:backgroundcolor => Attribute.create( [ :texkeyval], [ String ] ),
|
|
32
|
+
:linecolor => Attribute.create( [ :texkeyval], [ String ] ),
|
|
33
|
+
:bordercolor => Attribute.create( [ :texkeyval], [ String ] ),
|
|
34
|
+
:inline => Attribute.create( [ :texkeyval], [ true, false ] ),
|
|
35
|
+
=begin
|
|
36
|
+
more options:
|
|
37
|
+
line / noline
|
|
38
|
+
inline / noinline
|
|
39
|
+
size
|
|
40
|
+
list / nolist When the option nolist is given, the todo item will not appear in the list of todos.
|
|
41
|
+
caption For listoftodos
|
|
42
|
+
=end
|
|
43
|
+
}#.update(HTML_ATTR_ALL)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
add_output( :latex, '#{linebreak(@crbefore)}\todo[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}')
|
|
47
|
+
|
|
48
|
+
def self.head()
|
|
49
|
+
element(:usepackage, {}, 'todonotes').cr
|
|
50
|
+
end
|
|
51
|
+
end #Todonotes::Todo
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
=begin rdoc
|
|
55
|
+
Define Element :missingfigure
|
|
56
|
+
|
|
57
|
+
Create an instance with
|
|
58
|
+
element( :missingfigure, [ attributes, [content]] )
|
|
59
|
+
or
|
|
60
|
+
Missingfigure.new( [ attributes, [content]] )
|
|
61
|
+
Attributes may be:
|
|
62
|
+
* :figwidth:
|
|
63
|
+
=end
|
|
64
|
+
class Missingfigure < Element
|
|
65
|
+
add_attribute :figwidth, Attribute.create([:texkeyval], [Integer, String] ) #String for \textwidth... for HTML use CSS
|
|
66
|
+
add_latex_output '\missingfigure{#{@content}}'
|
|
67
|
+
end #Missingfigure
|
|
68
|
+
|
|
69
|
+
=begin rdoc
|
|
70
|
+
Define Element :listoftodos
|
|
71
|
+
|
|
72
|
+
Create an instance with
|
|
73
|
+
element( :listoftodos, [ attributes, [content]] )
|
|
74
|
+
or
|
|
75
|
+
Listoftodos.new( [ attributes, [content]] )
|
|
76
|
+
Attributes are not defined for this element.
|
|
77
|
+
=end
|
|
78
|
+
class Listoftodos < Element
|
|
79
|
+
has_no_content false
|
|
80
|
+
add_latex_output '\listoftodos'
|
|
81
|
+
end #Listoftodos
|
|
82
|
+
|
|
83
|
+
end #module Todonotes
|
|
84
|
+
end #module Packages
|
|
85
|
+
end #Docgenerator
|