docgenerator 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/examples/creole_example_tabular.rb +95 -0
  2. data/examples/docgenerator_example.rb +5 -5
  3. data/lib/creole/creole2doc.rb +28 -18
  4. data/lib/creole/creole_inclusions.rb +4 -4
  5. data/lib/creole/creole_placeholder.rb +4 -1
  6. data/lib/creole/creole_tabular.rb +173 -155
  7. data/lib/creole/plugins/rail.rb +118 -119
  8. data/lib/creole/plugins/struktex.rb +35 -35
  9. data/lib/creole/plugins/todonotes.rb +8 -1
  10. data/lib/docgenerator/attribute.rb +160 -160
  11. data/lib/docgenerator/characters.rb +343 -311
  12. data/lib/docgenerator/css.rb +167 -167
  13. data/lib/docgenerator/document.rb +525 -511
  14. data/lib/docgenerator/element.rb +316 -316
  15. data/lib/docgenerator/element_meta.rb +114 -114
  16. data/lib/docgenerator/elements.rb +19 -9
  17. data/lib/docgenerator/environments.rb +3 -1
  18. data/lib/docgenerator/lists.rb +177 -174
  19. data/lib/docgenerator/packages/hyperref.rb +74 -70
  20. data/lib/docgenerator/packages/multicol.rb +33 -0
  21. data/lib/docgenerator/packages/scrlettr2.rb +152 -151
  22. data/lib/docgenerator/packages/todonotes.rb +1 -1
  23. data/lib/docgenerator/tabular.rb +463 -400
  24. data/lib/docgenerator/templates/docgenerator_template.rb +94 -84
  25. data/lib/docgenerator/templates/docgenerator_template.yaml +75 -15
  26. data/lib/docgenerator.rb +1 -1
  27. data/lib/wiki2doc/wiki2docgenerator.rb +1 -1
  28. data/meta_test_and_doc/build__meta.rb +125 -0
  29. data/meta_test_and_doc/build_doc.rb +333 -0
  30. data/meta_test_and_doc/build_test.rb +251 -0
  31. data/meta_test_and_doc/manpages/attachfile.rb +389 -0
  32. data/meta_test_and_doc/manpages/caption.rb +133 -0
  33. data/meta_test_and_doc/manpages/characters.rb +3738 -0
  34. data/meta_test_and_doc/manpages/elements.rb +6851 -0
  35. data/meta_test_and_doc/manpages/environments.rb +985 -0
  36. data/meta_test_and_doc/manpages/footnote.rb +439 -0
  37. data/meta_test_and_doc/manpages/hyperref.rb +605 -0
  38. data/meta_test_and_doc/manpages/listings.rb +988 -0
  39. data/meta_test_and_doc/manpages/lists.rb +1463 -0
  40. data/meta_test_and_doc/manpages/others.rb +129 -0
  41. data/meta_test_and_doc/manpages/packages.rb +13 -0
  42. data/meta_test_and_doc/manpages/pdfpages.rb +108 -0
  43. data/meta_test_and_doc/manpages/readme.rdoc +9 -0
  44. data/meta_test_and_doc/manpages/scrlettr2.rb +362 -0
  45. data/meta_test_and_doc/manpages/scrpage2.rb +2028 -0
  46. data/meta_test_and_doc/manpages/sectioning.rb +2467 -0
  47. data/meta_test_and_doc/manpages/tables.rb +2088 -0
  48. data/meta_test_and_doc/manpages/todonotes.rb +235 -0
  49. data/meta_test_and_doc/manpages/wiki2docgenerator.rb +64 -0
  50. data/{readme.rd → readme.rdoc} +18 -1
  51. data/unittest/expected/test_tabular.creole +33 -0
  52. data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
  53. data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
  54. data/unittest/expected_creole/test_creole_creole1.0test.text +3 -3
  55. data/unittest/expected_creole/test_creole_inline_apostroph.html +6 -0
  56. data/unittest/expected_creole/test_creole_inline_apostroph.latex +8 -0
  57. data/unittest/expected_creole/test_creole_inline_apostroph.text +4 -0
  58. data/unittest/expected_creole/test_creole_input.normsource +12 -12
  59. data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
  60. data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
  61. data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
  62. data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
  63. data/unittest/expected_creole/test_creole_links_implicit_end.html +1 -1
  64. data/unittest/expected_creole/test_creole_links_implicit_end.latex +1 -1
  65. data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
  66. data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +83 -0
  67. data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
  68. data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +27 -0
  69. data/unittest/expected_creole/test_creole_tabular.creole +22 -0
  70. data/unittest/expected_creole/test_creole_tabular_creole.creole +19 -0
  71. data/unittest/expected_creole/test_creole_tabular_css.creole +24 -0
  72. data/unittest/expected_creole/test_creole_tabular_multicols.creole +16 -0
  73. data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
  74. data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
  75. data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
  76. data/unittest/expected_creole/test_creole_toc_level_text.html +2 -2
  77. data/unittest/expected_creole/test_creole_toc_level_text.latex +2 -2
  78. data/unittest/expected_packages/test_multicol_3.tex +2 -0
  79. data/unittest/expected_packages/test_multicol_3_titleline.tex +2 -0
  80. data/unittest/expected_templates/test_article.tex +23 -0
  81. data/unittest/expected_templates/test_article_utf8.tex +34 -0
  82. data/unittest/expected_templates/test_context.miv +18 -0
  83. data/unittest/expected_templates/test_creole.creole +8 -0
  84. data/unittest/expected_templates/test_html.html +12 -0
  85. data/unittest/expected_templates/test_html401_strict.html +14 -0
  86. data/unittest/expected_templates/test_html401_trans.html +14 -0
  87. data/unittest/expected_templates/test_html_utf8.html +14 -0
  88. data/unittest/expected_templates/test_include.tex +17 -0
  89. data/unittest/expected_templates/test_include_utf8.tex +17 -0
  90. data/unittest/expected_templates/test_text.txt +6 -0
  91. data/unittest/expected_templates/test_wiki.wiki +6 -0
  92. data/unittest/expected_templates/test_xhtml_strict.html +14 -0
  93. data/unittest/expected_templates/test_xhtml_trans.html +14 -0
  94. data/unittest/unittest_creole.rb +27 -6
  95. data/unittest/unittest_creole_placeholders.rb +1 -123
  96. data/unittest/unittest_creole_tabular.rb +174 -0
  97. data/unittest/unittest_docgenerator.rb +4 -3
  98. data/unittest/unittest_docgenerator_characters.rb +4769 -615
  99. data/unittest/unittest_packages_multicol.rb +84 -0
  100. data/unittest/unittest_rubycode4doc.rb +0 -1
  101. data/unittest/unittest_templates.rb +64 -0
  102. metadata +163 -77
  103. data/build_test_and_doc.rb +0 -505
  104. 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
- @@settings = {}
20
- @@values = {}
21
- @@sortkey = 99 #Just a counter to get identic positions between different program runs.
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
- 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}"
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
- 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
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
- #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
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
- 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
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
- if content?
155
- @element << value
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
- :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'] )
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
- 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 ] )
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