docgenerator 2.0.0 → 2.1.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/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
|
@@ -15,10 +15,10 @@ Attributes are the first parameters of element:
|
|
|
15
15
|
element( :type, {}, 'content' )
|
|
16
16
|
Element.new( {} )
|
|
17
17
|
=end
|
|
18
|
-
class Attribute
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
class Attribute
|
|
19
|
+
@@settings = {}
|
|
20
|
+
@@values = {}
|
|
21
|
+
@@sortkey = 99 #Just a counter to get identic positions between different program runs.
|
|
22
22
|
=begin rdoc
|
|
23
23
|
Generic creation of a new class to define a new Atttribute.
|
|
24
24
|
Settings is a hash with generell settings.
|
|
@@ -33,169 +33,169 @@ Supported parameters:
|
|
|
33
33
|
|
|
34
34
|
The sortkey is used for a sort-sequence of attributes inside an element
|
|
35
35
|
=end
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
#Generic class creation
|
|
42
|
-
attributeclass = Class.new( Attribute )
|
|
43
|
-
#Set the flags.
|
|
44
|
-
settings.each{|setting|
|
|
45
|
-
case setting
|
|
46
|
-
when :required
|
|
47
|
-
attributeclass.class_eval('def required?(); true; end')
|
|
48
|
-
when :content
|
|
49
|
-
attributeclass.class_eval('def content?(); true; end')
|
|
50
|
-
when :unique
|
|
51
|
-
attributeclass.class_eval('def unique?(); true; end')
|
|
52
|
-
when :html
|
|
53
|
-
attributeclass.class_eval('def html?(); true; end')
|
|
54
|
-
when :latex
|
|
55
|
-
attributeclass.class_eval('def latex?(); true; end')
|
|
56
|
-
when :texkeyval
|
|
57
|
-
attributeclass.class_eval('def texkeyval?(); true; end')
|
|
58
|
-
when :text
|
|
59
|
-
attributeclass.class_eval('def text?(); true; end')
|
|
60
|
-
when :wiki
|
|
61
|
-
attributeclass.class_eval('def wiki?(); true; end')
|
|
62
|
-
when :creole
|
|
63
|
-
attributeclass.class_eval('def creole?(); true; end')
|
|
64
|
-
else
|
|
65
|
-
DOCGENERATOR_LOGGER.error("Attribute: Unknown setting <#{setting.inspect}>") if DOCGENERATOR_LOGGER.error?
|
|
36
|
+
def self.create( settings = [], values = nil, sortkey = (@@sortkey += 1 ) )
|
|
37
|
+
#First some checks
|
|
38
|
+
if ! settings.kind_of?( Array )
|
|
39
|
+
raise "Type error Attribute.create: Expected Array, get #{attr.class}"
|
|
66
40
|
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
#Generic class creation
|
|
42
|
+
attributeclass = Class.new( Attribute )
|
|
43
|
+
#Set the flags.
|
|
44
|
+
settings.each{|setting|
|
|
45
|
+
case setting
|
|
46
|
+
when :required
|
|
47
|
+
attributeclass.class_eval('def required?(); true; end')
|
|
48
|
+
when :content
|
|
49
|
+
attributeclass.class_eval('def content?(); true; end')
|
|
50
|
+
when :unique
|
|
51
|
+
attributeclass.class_eval('def unique?(); true; end')
|
|
52
|
+
when :html
|
|
53
|
+
attributeclass.class_eval('def html?(); true; end')
|
|
54
|
+
when :latex
|
|
55
|
+
attributeclass.class_eval('def latex?(); true; end')
|
|
56
|
+
when :texkeyval
|
|
57
|
+
attributeclass.class_eval('def texkeyval?(); true; end')
|
|
58
|
+
when :text
|
|
59
|
+
attributeclass.class_eval('def text?(); true; end')
|
|
60
|
+
when :wiki
|
|
61
|
+
attributeclass.class_eval('def wiki?(); true; end')
|
|
62
|
+
when :creole
|
|
63
|
+
attributeclass.class_eval('def creole?(); true; end')
|
|
64
|
+
else
|
|
65
|
+
DOCGENERATOR_LOGGER.error("Attribute: Unknown setting <#{setting.inspect}>") if DOCGENERATOR_LOGGER.error?
|
|
66
|
+
end
|
|
67
|
+
}
|
|
68
|
+
if values
|
|
69
|
+
attributeclass.class_eval("def allowed_values(); return #{values.inspect}; end")
|
|
70
|
+
end
|
|
71
|
+
attributeclass.class_eval("def sortkey(); return #{sortkey}; end")
|
|
72
|
+
return attributeclass
|
|
73
|
+
end
|
|
74
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
|
-
|
|
75
|
+
#Each attribute is assigned to an element.
|
|
76
|
+
def initialize( name, element )
|
|
77
|
+
@name = name
|
|
78
|
+
@element = element
|
|
79
|
+
@attr_content = []
|
|
80
|
+
@part_of = [element] #list of elements, where this element is part of (normaly only one element)
|
|
81
|
+
@part_of_doc = [] #list of documents, where this element is part of (normaly only one document)
|
|
82
|
+
#@part_of_doc = element.part_of_doc May not work - is empty to generation time
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
#Key of the attribute
|
|
86
|
+
attr_reader :name
|
|
87
|
+
#Return class settings. Can be used for some checks.
|
|
88
|
+
def settings()
|
|
89
|
+
@@settings
|
|
90
|
+
end
|
|
91
|
+
#Check if the attribute is required.
|
|
92
|
+
#Redefined by Attribute.create and used in Element.to_s.
|
|
93
|
+
def required?(); false; end
|
|
94
|
+
#Check if the attribute can contain a "content".
|
|
95
|
+
#Redefined by Attribute.create.
|
|
96
|
+
def content?(); false; end
|
|
97
|
+
#Sometimes the content of an attribute is needed directly.
|
|
98
|
+
def content(); @attr_content; end
|
|
99
|
+
#Values may be added only once.
|
|
100
|
+
def unique?(); false; end
|
|
101
|
+
#Check if content was added
|
|
102
|
+
def filled?(); return @attr_content.compact.size > 0; end
|
|
103
|
+
#Attribut is used for HTML.
|
|
104
|
+
def html?(); false; end
|
|
105
|
+
#Attribut is used for Text.
|
|
106
|
+
def text?(); false; end
|
|
107
|
+
#Attribut is used for Wiki.
|
|
108
|
+
def wiki?(); false; end
|
|
109
|
+
#Attribut is used for Creole.
|
|
110
|
+
def creole?(); false; end
|
|
111
|
+
#Attribute is used for latex.
|
|
112
|
+
#Only for informational reasons.
|
|
113
|
+
def latex?(); false; end
|
|
114
|
+
#Attribute is used for conTeXt.
|
|
115
|
+
#Only for informational reasons.
|
|
116
|
+
def context?(); false; end
|
|
117
|
+
#Attribute is used as a keyval-option.
|
|
118
|
+
#See also Element#texkeyval
|
|
119
|
+
def texkeyval?(); false; end
|
|
120
|
+
#Return all allowed values.
|
|
121
|
+
#Redefined by Attribute.create and used in Attributes.<<
|
|
122
|
+
#By default everything is allowed.
|
|
123
|
+
#
|
|
124
|
+
#This method must return an Array with the allowed values or classes.
|
|
125
|
+
def allowed_values()
|
|
126
|
+
return nil
|
|
127
|
+
end
|
|
128
|
+
#Check if the given value is allowed.
|
|
129
|
+
def allowed?( value )
|
|
130
|
+
return true if allowed_values() == nil
|
|
131
|
+
allowed_values().each{|v|
|
|
132
|
+
if value == v #same value
|
|
133
|
+
return true
|
|
134
|
+
elsif v.is_a?(Regexp) and value =~ v
|
|
135
|
+
return true
|
|
136
|
+
elsif v.class == Class and value.is_a?( v ) #same class
|
|
137
|
+
return true
|
|
138
|
+
end
|
|
139
|
+
#Check next allowed value.
|
|
140
|
+
}
|
|
141
|
+
#No allowed value is set.
|
|
142
|
+
return false
|
|
143
|
+
#~ return allowed_values().include?( value )
|
|
144
|
+
end
|
|
145
|
+
#Add a value to the attribute content.
|
|
146
|
+
def << ( value )
|
|
147
|
+
if ! self.allowed?( value )
|
|
148
|
+
@element.log.warn("Attribute '#{@name}': Incorrect value '#{value.inspect}' for #{@element.inspect}") if @element.log.warn?
|
|
149
|
+
end
|
|
150
|
+
if unique? and @attr_content.size > 0
|
|
151
|
+
@element.log.warn("Attribute #{@name}: More then one value added to #{@element.inspect} (#{value.inspect})") if @element.log.warn?
|
|
152
|
+
return self
|
|
153
|
+
end
|
|
154
|
+
if content?
|
|
155
|
+
@element << value
|
|
156
|
+
else
|
|
157
|
+
@attr_content << value
|
|
138
158
|
end
|
|
139
|
-
#Check next allowed value.
|
|
140
|
-
}
|
|
141
|
-
#No allowed value is set.
|
|
142
|
-
return false
|
|
143
|
-
#~ return allowed_values().include?( value )
|
|
144
|
-
end
|
|
145
|
-
#Add a value to the attribute content.
|
|
146
|
-
def << ( value )
|
|
147
|
-
if ! self.allowed?( value )
|
|
148
|
-
@element.log.warn("Attribute '#{@name}': Incorrect value '#{value.inspect}' for #{@element.inspect}") if @element.log.warn?
|
|
149
159
|
end
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
#Return the content.
|
|
161
|
+
def to_s()
|
|
162
|
+
#~ @attr_content.to_s() #Ruby 1.8
|
|
163
|
+
@attr_content.join() #since Ruby 1.9
|
|
153
164
|
end
|
|
154
|
-
|
|
155
|
-
@element
|
|
156
|
-
else
|
|
157
|
-
@attr_content << value
|
|
165
|
+
def inspect()
|
|
166
|
+
return "<#Attribute #{@name} #{@attr_content.inspect} (in #{@element.inspect}) >"
|
|
158
167
|
end
|
|
159
|
-
end
|
|
160
|
-
#Return the content.
|
|
161
|
-
def to_s()
|
|
162
|
-
#~ @attr_content.to_s() #Ruby 1.8
|
|
163
|
-
@attr_content.join() #since Ruby 1.9
|
|
164
|
-
end
|
|
165
|
-
def inspect()
|
|
166
|
-
return "<#Attribute #{@name} #{@attr_content.inspect} (in #{@element.inspect}) >"
|
|
167
|
-
end
|
|
168
|
-
end #Attribute
|
|
168
|
+
end #Attribute
|
|
169
169
|
|
|
170
|
-
#Definition of HTML-Tags (Sublasses of Element).
|
|
171
|
-
ATTR_LANG = Attribute.create( [ :html ], ['en', 'de'] )
|
|
172
|
-
#
|
|
173
|
-
HTML_ATTR_CORE = {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
HTML_ATTR_I18N = {
|
|
180
|
-
|
|
181
|
-
|
|
170
|
+
#Definition of HTML-Tags (Sublasses of Element).
|
|
171
|
+
ATTR_LANG = Attribute.create( [ :html ], ['en', 'de'] )
|
|
172
|
+
#
|
|
173
|
+
HTML_ATTR_CORE = {
|
|
174
|
+
:id => Attribute.create( [ :html ] ),
|
|
175
|
+
:class => Attribute.create( [ :html ] ),
|
|
176
|
+
:style => Attribute.create( [ :html ], [CSS, String]), #fixme string raus
|
|
177
|
+
#~ :name => Attribute.create( [ :html ] ),
|
|
178
|
+
:title => Attribute.create( [ :html ] ) }
|
|
179
|
+
HTML_ATTR_I18N = {
|
|
180
|
+
:lang => ATTR_LANG,
|
|
181
|
+
:dir => Attribute.create( [ :html ], ['ltr', 'rtl'] )
|
|
182
|
+
}
|
|
183
|
+
HTML_ATTR_EVENTS = { :onclick => Attribute.create( [ :html ] ),
|
|
184
|
+
:ondblclick => Attribute.create( [ :html ] ),
|
|
185
|
+
:onmousedown => Attribute.create( [ :html ] ),
|
|
186
|
+
:onmouseup => Attribute.create( [ :html ] ),
|
|
187
|
+
:onmouseover => Attribute.create( [ :html ] ),
|
|
188
|
+
:onmousemove => Attribute.create( [ :html ] ),
|
|
189
|
+
:onmouseout => Attribute.create( [ :html ] ),
|
|
190
|
+
:onkeypress => Attribute.create( [ :html ] ),
|
|
191
|
+
:onkeyup => Attribute.create( [ :html ] ),
|
|
192
|
+
:onkeydown => Attribute.create( [ :html ] )
|
|
182
193
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
:onmouseover => Attribute.create( [ :html ] ),
|
|
188
|
-
:onmousemove => Attribute.create( [ :html ] ),
|
|
189
|
-
:onmouseout => Attribute.create( [ :html ] ),
|
|
190
|
-
:onkeypress => Attribute.create( [ :html ] ),
|
|
191
|
-
:onkeyup => Attribute.create( [ :html ] ),
|
|
192
|
-
:onkeydown => Attribute.create( [ :html ] )
|
|
193
|
-
}
|
|
194
|
-
HTML_ATTR_ALL = {}
|
|
195
|
-
HTML_ATTR_ALL.update(HTML_ATTR_I18N)
|
|
196
|
-
HTML_ATTR_ALL.update(HTML_ATTR_EVENTS)
|
|
197
|
-
HTML_ATTR_ALL.update(HTML_ATTR_CORE)
|
|
194
|
+
HTML_ATTR_ALL = {}
|
|
195
|
+
HTML_ATTR_ALL.update(HTML_ATTR_I18N)
|
|
196
|
+
HTML_ATTR_ALL.update(HTML_ATTR_EVENTS)
|
|
197
|
+
HTML_ATTR_ALL.update(HTML_ATTR_CORE)
|
|
198
198
|
|
|
199
|
-
HTML_ATTR_ALIGN = Attribute.create( [ :html ], ['left', 'center', 'right', 'justify', 'char'] )
|
|
200
|
-
HTML_ATTR_VALIGN = Attribute.create( [ :html ], ['bottom', 'top', 'middle', 'baseline'] )
|
|
199
|
+
HTML_ATTR_ALIGN = Attribute.create( [ :html ], ['left', 'center', 'right', 'justify', 'char'] )
|
|
200
|
+
HTML_ATTR_VALIGN = Attribute.create( [ :html ], ['bottom', 'top', 'middle', 'baseline'] )
|
|
201
201
|
end #module Docgenerator
|