docgenerator 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/creole_example_tabular.rb +95 -0
- data/examples/docgenerator_example.rb +5 -5
- data/lib/creole/creole2doc.rb +28 -18
- data/lib/creole/creole_inclusions.rb +4 -4
- data/lib/creole/creole_placeholder.rb +4 -1
- data/lib/creole/creole_tabular.rb +173 -155
- data/lib/creole/plugins/rail.rb +118 -119
- data/lib/creole/plugins/struktex.rb +35 -35
- data/lib/creole/plugins/todonotes.rb +8 -1
- data/lib/docgenerator/attribute.rb +160 -160
- data/lib/docgenerator/characters.rb +343 -311
- data/lib/docgenerator/css.rb +167 -167
- data/lib/docgenerator/document.rb +525 -511
- data/lib/docgenerator/element.rb +316 -316
- data/lib/docgenerator/element_meta.rb +114 -114
- data/lib/docgenerator/elements.rb +19 -9
- data/lib/docgenerator/environments.rb +3 -1
- data/lib/docgenerator/lists.rb +177 -174
- data/lib/docgenerator/packages/hyperref.rb +74 -70
- data/lib/docgenerator/packages/multicol.rb +33 -0
- data/lib/docgenerator/packages/scrlettr2.rb +152 -151
- data/lib/docgenerator/packages/todonotes.rb +1 -1
- data/lib/docgenerator/tabular.rb +463 -400
- data/lib/docgenerator/templates/docgenerator_template.rb +94 -84
- data/lib/docgenerator/templates/docgenerator_template.yaml +75 -15
- data/lib/docgenerator.rb +1 -1
- data/lib/wiki2doc/wiki2docgenerator.rb +1 -1
- data/meta_test_and_doc/build__meta.rb +125 -0
- data/meta_test_and_doc/build_doc.rb +333 -0
- data/meta_test_and_doc/build_test.rb +251 -0
- data/meta_test_and_doc/manpages/attachfile.rb +389 -0
- data/meta_test_and_doc/manpages/caption.rb +133 -0
- data/meta_test_and_doc/manpages/characters.rb +3738 -0
- data/meta_test_and_doc/manpages/elements.rb +6851 -0
- data/meta_test_and_doc/manpages/environments.rb +985 -0
- data/meta_test_and_doc/manpages/footnote.rb +439 -0
- data/meta_test_and_doc/manpages/hyperref.rb +605 -0
- data/meta_test_and_doc/manpages/listings.rb +988 -0
- data/meta_test_and_doc/manpages/lists.rb +1463 -0
- data/meta_test_and_doc/manpages/others.rb +129 -0
- data/meta_test_and_doc/manpages/packages.rb +13 -0
- data/meta_test_and_doc/manpages/pdfpages.rb +108 -0
- data/meta_test_and_doc/manpages/readme.rdoc +9 -0
- data/meta_test_and_doc/manpages/scrlettr2.rb +362 -0
- data/meta_test_and_doc/manpages/scrpage2.rb +2028 -0
- data/meta_test_and_doc/manpages/sectioning.rb +2467 -0
- data/meta_test_and_doc/manpages/tables.rb +2088 -0
- data/meta_test_and_doc/manpages/todonotes.rb +235 -0
- data/meta_test_and_doc/manpages/wiki2docgenerator.rb +64 -0
- data/{readme.rd → readme.rdoc} +18 -1
- data/unittest/expected/test_tabular.creole +33 -0
- data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
- data/unittest/expected_creole/test_creole_creole1.0test.text +3 -3
- data/unittest/expected_creole/test_creole_inline_apostroph.html +6 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.latex +8 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.text +4 -0
- data/unittest/expected_creole/test_creole_input.normsource +12 -12
- data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
- data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
- data/unittest/expected_creole/test_creole_links_implicit_end.html +1 -1
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +1 -1
- data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
- data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +83 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
- data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +27 -0
- data/unittest/expected_creole/test_creole_tabular.creole +22 -0
- data/unittest/expected_creole/test_creole_tabular_creole.creole +19 -0
- data/unittest/expected_creole/test_creole_tabular_css.creole +24 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.creole +16 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
- data/unittest/expected_creole/test_creole_toc_level_text.html +2 -2
- data/unittest/expected_creole/test_creole_toc_level_text.latex +2 -2
- data/unittest/expected_packages/test_multicol_3.tex +2 -0
- data/unittest/expected_packages/test_multicol_3_titleline.tex +2 -0
- data/unittest/expected_templates/test_article.tex +23 -0
- data/unittest/expected_templates/test_article_utf8.tex +34 -0
- data/unittest/expected_templates/test_context.miv +18 -0
- data/unittest/expected_templates/test_creole.creole +8 -0
- data/unittest/expected_templates/test_html.html +12 -0
- data/unittest/expected_templates/test_html401_strict.html +14 -0
- data/unittest/expected_templates/test_html401_trans.html +14 -0
- data/unittest/expected_templates/test_html_utf8.html +14 -0
- data/unittest/expected_templates/test_include.tex +17 -0
- data/unittest/expected_templates/test_include_utf8.tex +17 -0
- data/unittest/expected_templates/test_text.txt +6 -0
- data/unittest/expected_templates/test_wiki.wiki +6 -0
- data/unittest/expected_templates/test_xhtml_strict.html +14 -0
- data/unittest/expected_templates/test_xhtml_trans.html +14 -0
- data/unittest/unittest_creole.rb +27 -6
- data/unittest/unittest_creole_placeholders.rb +1 -123
- data/unittest/unittest_creole_tabular.rb +174 -0
- data/unittest/unittest_docgenerator.rb +4 -3
- data/unittest/unittest_docgenerator_characters.rb +4769 -615
- data/unittest/unittest_packages_multicol.rb +84 -0
- data/unittest/unittest_rubycode4doc.rb +0 -1
- data/unittest/unittest_templates.rb +64 -0
- metadata +163 -77
- data/build_test_and_doc.rb +0 -505
- data/manpage_elements.rb +0 -10411
data/lib/docgenerator/css.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#encoding: utf-8
|
1
2
|
=begin rdoc
|
2
3
|
Define classes to use cascading style sheets (CSS) for HTML-documents.
|
3
4
|
=end
|
@@ -14,150 +15,150 @@ Create an instance with
|
|
14
15
|
|
15
16
|
Only for HTML.
|
16
17
|
=end
|
17
|
-
class Style < Element
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end #Style
|
18
|
+
class Style < Element
|
19
|
+
#~ add_attributes( HTML_ATTR_ALL )
|
20
|
+
add_latex_output ''
|
21
|
+
add_text_output ''
|
22
|
+
add_wiki_output ''
|
23
|
+
add_creole_output ''
|
24
|
+
#Prepare HTML-Output for Style-Tag.
|
25
|
+
#The values can be overwritten, if different CSS-Elements are inside.
|
26
|
+
def to_html( options = {} )
|
27
|
+
o = set_option_defaults(options)
|
28
|
+
o[:log].debug("Enter style.to_html") if o[:log].debug?
|
29
|
+
res = ""
|
30
|
+
res << "\n" if @crbefore
|
31
|
+
res << "<style type=\"text/css\">\n"
|
32
|
+
@content.each{|c|
|
33
|
+
res << c.to_html(options)
|
34
|
+
}
|
35
|
+
res << "</style>"
|
36
|
+
res << "\n" if @crafter
|
37
|
+
return res
|
38
|
+
end
|
39
|
+
end #Style
|
39
40
|
|
40
|
-
CSS_COLORS = [ /rgb\((\d+%?,?){3,3}\)/,
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
CSS_BORDER = [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ]
|
54
|
-
CSS_WIDTH = [ /\d*(cm|mm|px|em|%)/, 'thin', 'medium', 'thick' ]
|
41
|
+
CSS_COLORS = [ /rgb\((\d+%?,?){3,3}\)/,
|
42
|
+
#rgb(R,G,B), rgb(%,%,%) oder #XXXXXX
|
43
|
+
#/gray\d{1,3}/
|
44
|
+
'black','gray', 'grey', 'maroon','red', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'purple', 'fuchsia', 'teal', 'aqua', 'silver', 'white',
|
45
|
+
#Netscape-Farbnamen (120 additional colors)
|
46
|
+
#Falsche Darstellungen, siehe http://www.rzuser.uni-heidelberg.de/~x22/ht/farben2.html
|
47
|
+
'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen',
|
48
|
+
'lightgrey', 'lightgray', 'lightslategray', 'lightslategrey', #yes, both are defined
|
49
|
+
'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightsteelblue', 'lightyellow',
|
50
|
+
'greenyellow', 'palegreen', 'darkgreen',
|
51
|
+
'darkred', 'firebrick',
|
52
|
+
'salmon',
|
53
|
+
]
|
54
|
+
CSS_BORDER = [ 'none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset' ]
|
55
|
+
CSS_WIDTH = [ /\d*(cm|mm|px|em|%)/, 'thin', 'medium', 'thick' ]
|
55
56
|
|
56
57
|
=begin rdoc
|
57
58
|
Class to collect css-settings for a Element.
|
58
59
|
|
59
60
|
This values can be used inline (style-Attribute) and inside style>-Tags
|
60
61
|
=end
|
61
|
-
class CSS
|
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
|
-
|
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
|
-
|
62
|
+
class CSS
|
63
|
+
#List of all allowed values.
|
64
|
+
#The first value is a regular expression, coninued by fixed values.
|
65
|
+
@@values = {
|
66
|
+
'font-size' => [ 'xx-small', 'x-small', 'small', 'medium', 'large','x-large','xx-large','smaller','larger', /\A\d+(pt|px|em)/ ],
|
67
|
+
'font-style' => ['italic', 'oblique', 'normal'],
|
68
|
+
'font-weight' => ['bold', 'bolder', 'lighter', 'normal', /\A\d00\Z/ ],
|
69
|
+
'color' => CSS_COLORS,
|
70
|
+
'background-color' => CSS_COLORS,
|
71
|
+
'visibility' => ['hidden', 'visible' ],
|
72
|
+
'text-decoration' => ['underline', 'overline', 'line-through', 'blink', 'none'],
|
73
|
+
#Ausrichtung
|
74
|
+
'float' => ['left', 'right', 'none' ],
|
75
|
+
'display' => ['inline'],
|
76
|
+
'text-align' => ['left', 'center', 'right', 'justify', 'char'],
|
77
|
+
'vertical-align' => ['top', 'middle','bottom','baseline','sub','super','text-top','text-bottom'],
|
78
|
+
'clear' => ['left', 'right','both','none'], #Fortsetzung bei Textumfluss
|
79
|
+
'white-space' => [ 'normal', 'pre', 'nowrap' ], #Textumbruch innererhalb des tags
|
80
|
+
#Borders: CSS-Eigenschaften: Außenrand/Abstand
|
81
|
+
'margin' => CSS_WIDTH,
|
82
|
+
'margin-top' => CSS_WIDTH,
|
83
|
+
'margin-bottom' => CSS_WIDTH,
|
84
|
+
'margin-left' => CSS_WIDTH,
|
85
|
+
'margin-right' => CSS_WIDTH,
|
86
|
+
#Borders: CSS-Eigenschaften: Innenabstand
|
87
|
+
'padding' => CSS_WIDTH,
|
88
|
+
'padding-top' => CSS_WIDTH,
|
89
|
+
'padding-bottom' => CSS_WIDTH,
|
90
|
+
'padding-left' => CSS_WIDTH,
|
91
|
+
'padding-right' => CSS_WIDTH,
|
92
|
+
#Tabulars
|
93
|
+
'border-style' => CSS_BORDER,
|
94
|
+
'border-left-style' => CSS_BORDER,
|
95
|
+
'border-right-style' => CSS_BORDER,
|
96
|
+
'border-top-style' => CSS_BORDER,
|
97
|
+
'border-bottom-style' => CSS_BORDER,
|
98
|
+
'border-width' => CSS_WIDTH,
|
99
|
+
'border-left-width' => CSS_WIDTH,
|
100
|
+
'border-right-width' => CSS_WIDTH,
|
101
|
+
'border-top-width' => CSS_WIDTH,
|
102
|
+
'border-bottom-width' => CSS_WIDTH,
|
103
|
+
'border-color' => CSS_COLORS,
|
104
|
+
'border-left-color' => CSS_COLORS,
|
105
|
+
'border-right-color' => CSS_COLORS,
|
106
|
+
'border-top-color' => CSS_COLORS,
|
107
|
+
'border-bottom-color' => CSS_COLORS,
|
108
|
+
'table-layout' => ['auto', 'fixed'], #Not in Opera
|
109
|
+
'empty-cells' => ['show', 'hide'],
|
110
|
+
'border-collapse' => ['separate', 'collapse'],
|
111
|
+
#Positionierung und Anzeige von Elementen
|
112
|
+
'position' => ['absolute', 'fixed', 'relative', 'static'],
|
113
|
+
'top' => CSS_WIDTH,
|
114
|
+
'left' => CSS_WIDTH,
|
115
|
+
'bottom' => CSS_WIDTH,
|
116
|
+
'right' => CSS_WIDTH,
|
117
|
+
'width' => CSS_WIDTH,
|
118
|
+
'min-width' => CSS_WIDTH,
|
119
|
+
'max-width' => CSS_WIDTH,
|
120
|
+
'height' => CSS_WIDTH,
|
121
|
+
'min-height' => CSS_WIDTH,
|
122
|
+
'max-height' => CSS_WIDTH,
|
123
|
+
'overflow' => ['visible', 'hidden', 'scroll', 'auto' ],
|
124
|
+
#Lists
|
125
|
+
'list-style-type' => [
|
126
|
+
'decimal', 'lower-roman', 'upper-roman', 'lower-alpha', 'upper-alpha', 'lower-greek', 'hebrew', 'decimal-leading-zero',
|
127
|
+
'cjk-ideographic', 'hiragana', 'katakana', 'hiragana-iroha', 'katakana-iroha', #Japanese
|
128
|
+
'disc', 'circle', 'square', #ul
|
129
|
+
'none'],
|
130
|
+
'list-style-position' => [ 'inside', 'outside'],
|
131
|
+
'list-style-image' => String, #URI
|
132
|
+
#~ 'list-style' => @@values['list-style-type'] + @@values['list-style-position'],
|
133
|
+
#Generell settings
|
134
|
+
#~ ['bottom', 'top', 'middle', 'baseline'],
|
135
|
+
}
|
136
|
+
def initialize( values ={} )
|
137
|
+
@values = {}
|
138
|
+
#~ set_option_defaults(values) #guarantee :log
|
139
|
+
@log = values[:log] || DOCGENERATOR_DEFAULT_LOGGER
|
140
|
+
values.delete(:log)
|
141
|
+
|
142
|
+
values.each{|k,v|
|
143
|
+
self[k] = v
|
144
|
+
}
|
145
|
+
@cr = nil
|
146
|
+
end
|
146
147
|
=begin rdoc
|
147
148
|
Make key unique. convert symbol to String...
|
148
149
|
=end
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
def generalize_key( k )
|
151
|
+
key = nil
|
152
|
+
if k.is_a?(Symbol)
|
153
|
+
key = k.to_s.gsub('_','-')
|
154
|
+
else
|
155
|
+
key = k
|
156
|
+
end
|
157
|
+
return key
|
158
|
+
end
|
159
|
+
def []( k )
|
160
|
+
return @values[generalize_key( k )]
|
161
|
+
end
|
161
162
|
=begin rdoc
|
162
163
|
Add a setting.
|
163
164
|
|
@@ -165,45 +166,44 @@ If an existing value is overwritten, you get a warning.
|
|
165
166
|
To replace a value, use
|
166
167
|
css[key].replace( value ) (But the you have no check)
|
167
168
|
=end
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
169
|
+
def []=( k, v )
|
170
|
+
key = generalize_key( k )
|
171
|
+
if @values[key]
|
172
|
+
@log.warn("CSS: Overwrite #{k.inspect}") if @log.warn?
|
173
|
+
end
|
174
|
+
if ! @@values[key]
|
175
|
+
@log.error("CSS: Undefined key #{k.inspect}") if @log.error?
|
176
|
+
elsif @@values[key].include?(v) #Fine
|
177
|
+
elsif @@values[key][0].is_a?(Regexp) and @@values[key][0] =~ v.to_s
|
178
|
+
else
|
179
|
+
@log.error("CSS: #{v} not allowed for #{key}") if @log.error?
|
180
|
+
end
|
181
|
+
|
182
|
+
@values[key] = v
|
183
|
+
end
|
183
184
|
=begin rdoc
|
184
185
|
Returns the values for a direct css in the style-attribute for a HTML-tag.
|
185
186
|
=end
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
187
|
+
def to_html(options={})
|
188
|
+
o = {
|
189
|
+
:map => "%s;",
|
190
|
+
}.update(options)
|
191
|
+
return self.to_tab.map{|p| o[:map] % p}.join()
|
192
|
+
end
|
193
|
+
def to_s()
|
194
|
+
return self.to_html
|
195
|
+
end
|
195
196
|
=begin rdoc
|
196
197
|
Returns a tab with the textes for each characteristic.
|
197
198
|
=end
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
end #CSS
|
206
|
-
|
199
|
+
def to_tab()
|
200
|
+
s = []
|
201
|
+
@values.sort.each{|k,v|
|
202
|
+
s << "#{k}: #{v}"
|
203
|
+
}
|
204
|
+
return s
|
205
|
+
end
|
206
|
+
end #CSS
|
207
207
|
end #module Docgenerator
|
208
208
|
|
209
209
|
if __FILE__ == $0
|