rbplusplus 0.1

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/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+ require 'rake/gempackagetask'
2
+ require 'rake/rdoctask'
3
+ require 'rake/contrib/sshpublisher'
4
+
5
+ PROJECT_NAME = "rb++"
6
+ RBPLUSPLUS_VERSION = "0.1"
7
+
8
+ task :default => :test
9
+
10
+ # We test this way because of what this library does.
11
+ # The tests wrap and load C++ wrapper code constantly.
12
+ # When running all the tests at once, we very quickly run
13
+ # into problems where Rice crashes because
14
+ # a given C++ class is already wrapped. So we need to run the
15
+ # tests individually
16
+ desc "Run the tests"
17
+ task :test do
18
+ FileList["test/*_test.rb"].each do |file|
19
+ ruby file
20
+ end
21
+ end
22
+
23
+ Rake::RDocTask.new do |rd|
24
+ rd.main = "README"
25
+ rd.rdoc_files.include("README", "lib/**/*.rb")
26
+ rd.rdoc_files.exclude("**/jamis.rb")
27
+ rd.template = File.expand_path(File.dirname(__FILE__) + "/lib/jamis.rb")
28
+ rd.options << '--line-numbers' << '--inline-source'
29
+ end
30
+
31
+ RUBYFORGE_USERNAME = "jameskilton"
32
+ PROJECT_WEB_PATH = "/var/www/gforge-projects/rbplusplus"
33
+
34
+ desc "Update the website"
35
+ task :upload_web => :rdoc do |t|
36
+ unless File.directory?("publish")
37
+ mkdir "publish"
38
+ mkdir "publish/rbplusplus"
39
+ end
40
+ sh "cp -r website publish/"
41
+ sh "cp -r html/* publish/rbplusplus/"
42
+ Rake::SshDirPublisher.new("#{RUBYFORGE_USERNAME}@rubyforge.org", PROJECT_WEB_PATH, "publish").upload
43
+ rm_rf "publish"
44
+ end
45
+
46
+ spec = Gem::Specification.new do |s|
47
+ s.name = "rbplusplus"
48
+ s.version = RBPLUSPLUS_VERSION
49
+ s.summary = 'Ruby library to generate Rice wrapper code'
50
+ s.homepage = 'http://rbplusplus.rubyforge.org/rbplusplus'
51
+ s.rubyforge_project = "rbplusplus"
52
+ s.author = 'Jason Roelofs'
53
+ s.email = 'jameskilton@gmail.com'
54
+
55
+ s.description = <<-END
56
+ Rb++ combines the powerful query interface of rbgccxml and the Rice library to
57
+ make Ruby wrapping extensions easier to write than ever.
58
+ END
59
+
60
+ s.add_dependency "rbgccxml", "=0.1"
61
+
62
+ patterns = [
63
+ 'TODO',
64
+ 'Rakefile',
65
+ 'lib/**/*.rb',
66
+ ]
67
+
68
+ s.files = patterns.map {|p| Dir.glob(p) }.flatten
69
+
70
+ s.test_files = [Dir.glob('test/**/*.rb'), Dir.glob('test/headers/**/*')].flatten
71
+
72
+ s.require_paths = ['lib']
73
+ end
74
+
75
+ Rake::GemPackageTask.new(spec) do |pkg|
76
+ pkg.need_zip = true
77
+ pkg.need_tar = true
78
+ end
data/TODO ADDED
@@ -0,0 +1,25 @@
1
+ TODO
2
+ * Figure out how to fix the error when running rake test
3
+ * Allowing use of "have_library"
4
+ * Other mkmf functions?
5
+
6
+ STARTED
7
+ * Adding constructor
8
+ - Test constructor arguments
9
+
10
+ DONE
11
+ * Adding -I entries
12
+ * Adding -L and -l entries
13
+ * Adding classes to global (define_class)
14
+ * Adding modules
15
+ * Adding methods to modules (define_module_function)
16
+ * Adding classes to modules / other classes (define_class_under)
17
+ * Adding methods to classes (.define_method)
18
+ * Adding classes to classes (ad infinitum)
19
+ * Look into file naming when dealing with Modules
20
+ * Nested Modules
21
+
22
+ No longer waiting on rice - just building a wrapper myself now.
23
+ * Adding global methods (Kernel-level methods)
24
+ * Adding class-level methods (define_singleton_method)
25
+
@@ -0,0 +1,53 @@
1
+ Inflector.inflections do |inflect|
2
+ inflect.plural(/$/, 's')
3
+ inflect.plural(/s$/i, 's')
4
+ inflect.plural(/(ax|test)is$/i, '\1es')
5
+ inflect.plural(/(octop|vir)us$/i, '\1i')
6
+ inflect.plural(/(alias|status)$/i, '\1es')
7
+ inflect.plural(/(bu)s$/i, '\1ses')
8
+ inflect.plural(/(buffal|tomat)o$/i, '\1oes')
9
+ inflect.plural(/([ti])um$/i, '\1a')
10
+ inflect.plural(/sis$/i, 'ses')
11
+ inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
12
+ inflect.plural(/(hive)$/i, '\1s')
13
+ inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
14
+ inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
15
+ inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
16
+ inflect.plural(/([m|l])ouse$/i, '\1ice')
17
+ inflect.plural(/^(ox)$/i, '\1en')
18
+ inflect.plural(/(quiz)$/i, '\1zes')
19
+
20
+ inflect.singular(/s$/i, '')
21
+ inflect.singular(/(n)ews$/i, '\1ews')
22
+ inflect.singular(/([ti])a$/i, '\1um')
23
+ inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
24
+ inflect.singular(/(^analy)ses$/i, '\1sis')
25
+ inflect.singular(/([^f])ves$/i, '\1fe')
26
+ inflect.singular(/(hive)s$/i, '\1')
27
+ inflect.singular(/(tive)s$/i, '\1')
28
+ inflect.singular(/([lr])ves$/i, '\1f')
29
+ inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y')
30
+ inflect.singular(/(s)eries$/i, '\1eries')
31
+ inflect.singular(/(m)ovies$/i, '\1ovie')
32
+ inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
33
+ inflect.singular(/([m|l])ice$/i, '\1ouse')
34
+ inflect.singular(/(bus)es$/i, '\1')
35
+ inflect.singular(/(o)es$/i, '\1')
36
+ inflect.singular(/(shoe)s$/i, '\1')
37
+ inflect.singular(/(cris|ax|test)es$/i, '\1is')
38
+ inflect.singular(/(octop|vir)i$/i, '\1us')
39
+ inflect.singular(/(alias|status)es$/i, '\1')
40
+ inflect.singular(/^(ox)en/i, '\1')
41
+ inflect.singular(/(vert|ind)ices$/i, '\1ex')
42
+ inflect.singular(/(matr)ices$/i, '\1ix')
43
+ inflect.singular(/(quiz)zes$/i, '\1')
44
+
45
+ inflect.irregular('person', 'people')
46
+ inflect.irregular('man', 'men')
47
+ inflect.irregular('child', 'children')
48
+ inflect.irregular('sex', 'sexes')
49
+ inflect.irregular('move', 'moves')
50
+ inflect.irregular('cow', 'kine')
51
+
52
+ inflect.uncountable(%w(equipment information rice money species series fish sheep))
53
+ end
data/lib/inflector.rb ADDED
@@ -0,0 +1,285 @@
1
+ require 'singleton'
2
+
3
+ # The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
4
+ # and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable words are kept
5
+ # in inflections.rb.
6
+ module Inflector
7
+ # A singleton instance of this class is yielded by Inflector.inflections, which can then be used to specify additional
8
+ # inflection rules. Examples:
9
+ #
10
+ # Inflector.inflections do |inflect|
11
+ # inflect.plural /^(ox)$/i, '\1\2en'
12
+ # inflect.singular /^(ox)en/i, '\1'
13
+ #
14
+ # inflect.irregular 'octopus', 'octopi'
15
+ #
16
+ # inflect.uncountable "equipment"
17
+ # end
18
+ #
19
+ # New rules are added at the top. So in the example above, the irregular rule for octopus will now be the first of the
20
+ # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
21
+ # already have been loaded.
22
+ class Inflections
23
+ include Singleton
24
+
25
+ attr_reader :plurals, :singulars, :uncountables
26
+
27
+ def initialize
28
+ @plurals, @singulars, @uncountables = [], [], []
29
+ end
30
+
31
+ # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
32
+ # The replacement should always be a string that may include references to the matched data from the rule.
33
+ def plural(rule, replacement)
34
+ @plurals.insert(0, [rule, replacement])
35
+ end
36
+
37
+ # Specifies a new singularization rule and its replacement. The rule can either be a string or a regular expression.
38
+ # The replacement should always be a string that may include references to the matched data from the rule.
39
+ def singular(rule, replacement)
40
+ @singulars.insert(0, [rule, replacement])
41
+ end
42
+
43
+ # Specifies a new irregular that applies to both pluralization and singularization at the same time. This can only be used
44
+ # for strings, not regular expressions. You simply pass the irregular in singular and plural form.
45
+ #
46
+ # Examples:
47
+ # irregular 'octopus', 'octopi'
48
+ # irregular 'person', 'people'
49
+ def irregular(singular, plural)
50
+ if singular[0,1].upcase == plural[0,1].upcase
51
+ plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
52
+ singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
53
+ else
54
+ plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
55
+ plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
56
+ singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
57
+ singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
58
+ end
59
+ end
60
+
61
+ # Add uncountable words that shouldn't be attempted inflected.
62
+ #
63
+ # Examples:
64
+ # uncountable "money"
65
+ # uncountable "money", "information"
66
+ # uncountable %w( money information rice )
67
+ def uncountable(*words)
68
+ (@uncountables << words).flatten!
69
+ end
70
+
71
+ # Clears the loaded inflections within a given scope (default is :all). Give the scope as a symbol of the inflection type,
72
+ # the options are: :plurals, :singulars, :uncountables
73
+ #
74
+ # Examples:
75
+ # clear :all
76
+ # clear :plurals
77
+ def clear(scope = :all)
78
+ case scope
79
+ when :all
80
+ @plurals, @singulars, @uncountables = [], [], []
81
+ else
82
+ instance_variable_set "@#{scope}", []
83
+ end
84
+ end
85
+ end
86
+
87
+ extend self
88
+
89
+ def inflections
90
+ if block_given?
91
+ yield Inflections.instance
92
+ else
93
+ Inflections.instance
94
+ end
95
+ end
96
+
97
+ # Returns the plural form of the word in the string.
98
+ #
99
+ # Examples
100
+ # "post".pluralize #=> "posts"
101
+ # "octopus".pluralize #=> "octopi"
102
+ # "sheep".pluralize #=> "sheep"
103
+ # "words".pluralize #=> "words"
104
+ # "the blue mailman".pluralize #=> "the blue mailmen"
105
+ # "CamelOctopus".pluralize #=> "CamelOctopi"
106
+ def pluralize(word)
107
+ result = word.to_s.dup
108
+
109
+ if word.empty? || inflections.uncountables.include?(result.downcase)
110
+ result
111
+ else
112
+ inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
113
+ result
114
+ end
115
+ end
116
+
117
+ # The reverse of pluralize, returns the singular form of a word in a string.
118
+ #
119
+ # Examples
120
+ # "posts".singularize #=> "post"
121
+ # "octopi".singularize #=> "octopus"
122
+ # "sheep".singluarize #=> "sheep"
123
+ # "word".singluarize #=> "word"
124
+ # "the blue mailmen".singularize #=> "the blue mailman"
125
+ # "CamelOctopi".singularize #=> "CamelOctopus"
126
+ def singularize(word)
127
+ result = word.to_s.dup
128
+
129
+ if inflections.uncountables.include?(result.downcase)
130
+ result
131
+ else
132
+ inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
133
+ result
134
+ end
135
+ end
136
+
137
+ # By default, camelize converts strings to UpperCamelCase. If the argument to camelize
138
+ # is set to ":lower" then camelize produces lowerCamelCase.
139
+ #
140
+ # camelize will also convert '/' to '::' which is useful for converting paths to namespaces
141
+ #
142
+ # Examples
143
+ # "active_record".camelize #=> "ActiveRecord"
144
+ # "active_record".camelize(:lower) #=> "activeRecord"
145
+ # "active_record/errors".camelize #=> "ActiveRecord::Errors"
146
+ # "active_record/errors".camelize(:lower) #=> "activeRecord::Errors"
147
+ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
148
+ if first_letter_in_uppercase
149
+ lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
150
+ else
151
+ lower_case_and_underscored_word.first + camelize(lower_case_and_underscored_word)[1..-1]
152
+ end
153
+ end
154
+
155
+ # Capitalizes all the words and replaces some characters in the string to create
156
+ # a nicer looking title. Titleize is meant for creating pretty output. It is not
157
+ # used in the Rails internals.
158
+ #
159
+ # titleize is also aliased as as titlecase
160
+ #
161
+ # Examples
162
+ # "man from the boondocks".titleize #=> "Man From The Boondocks"
163
+ # "x-men: the last stand".titleize #=> "X Men: The Last Stand"
164
+ def titleize(word)
165
+ humanize(underscore(word)).gsub(/\b('?[a-z])/) { $1.capitalize }
166
+ end
167
+
168
+ # The reverse of +camelize+. Makes an underscored form from the expression in the string.
169
+ #
170
+ # Changes '::' to '/' to convert namespaces to paths.
171
+ #
172
+ # Examples
173
+ # "ActiveRecord".underscore #=> "active_record"
174
+ # "ActiveRecord::Errors".underscore #=> active_record/errors
175
+ def underscore(camel_cased_word)
176
+ camel_cased_word.to_s.gsub(/::/, '/').
177
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
178
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
179
+ tr("-", "_").
180
+ downcase
181
+ end
182
+
183
+ # Replaces underscores with dashes in the string.
184
+ #
185
+ # Example
186
+ # "puni_puni" #=> "puni-puni"
187
+ def dasherize(underscored_word)
188
+ underscored_word.gsub(/_/, '-')
189
+ end
190
+
191
+ # Capitalizes the first word and turns underscores into spaces and strips _id.
192
+ # Like titleize, this is meant for creating pretty output.
193
+ #
194
+ # Examples
195
+ # "employee_salary" #=> "Employee salary"
196
+ # "author_id" #=> "Author"
197
+ def humanize(lower_case_and_underscored_word)
198
+ lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
199
+ end
200
+
201
+ # Removes the module part from the expression in the string
202
+ #
203
+ # Examples
204
+ # "ActiveRecord::CoreExtensions::String::Inflections".demodulize #=> "Inflections"
205
+ # "Inflections".demodulize #=> "Inflections"
206
+ def demodulize(class_name_in_module)
207
+ class_name_in_module.to_s.gsub(/^.*::/, '')
208
+ end
209
+
210
+ # Create the name of a table like Rails does for models to table names. This method
211
+ # uses the pluralize method on the last word in the string.
212
+ #
213
+ # Examples
214
+ # "RawScaledScorer".tableize #=> "raw_scaled_scorers"
215
+ # "egg_and_ham".tableize #=> "egg_and_hams"
216
+ # "fancyCategory".tableize #=> "fancy_categories"
217
+ def tableize(class_name)
218
+ pluralize(underscore(class_name))
219
+ end
220
+
221
+ # Create a class name from a plural table name like Rails does for table names to models.
222
+ # Note that this returns a string and not a Class. (To convert to an actual class
223
+ # follow classify with constantize.)
224
+ #
225
+ # Examples
226
+ # "egg_and_hams".classify #=> "EggAndHam"
227
+ # "posts".classify #=> "Post"
228
+ #
229
+ # Singular names are not handled correctly
230
+ # "business".classify #=> "Busines"
231
+ def classify(table_name)
232
+ # strip out any leading schema name
233
+ camelize(singularize(table_name.to_s.sub(/.*\./, '')))
234
+ end
235
+
236
+ # Creates a foreign key name from a class name.
237
+ # +separate_class_name_and_id_with_underscore+ sets whether
238
+ # the method should put '_' between the name and 'id'.
239
+ #
240
+ # Examples
241
+ # "Message".foreign_key #=> "message_id"
242
+ # "Message".foreign_key(false) #=> "messageid"
243
+ # "Admin::Post".foreign_key #=> "post_id"
244
+ def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
245
+ underscore(demodulize(class_name)) + (separate_class_name_and_id_with_underscore ? "_id" : "id")
246
+ end
247
+
248
+ # Constantize tries to find a declared constant with the name specified
249
+ # in the string. It raises a NameError when the name is not in CamelCase
250
+ # or is not initialized.
251
+ #
252
+ # Examples
253
+ # "Module".constantize #=> Module
254
+ # "Class".constantize #=> Class
255
+ def constantize(camel_cased_word)
256
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
257
+ raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
258
+ end
259
+
260
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
261
+ end
262
+
263
+ # Ordinalize turns a number into an ordinal string used to denote the
264
+ # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
265
+ #
266
+ # Examples
267
+ # ordinalize(1) # => "1st"
268
+ # ordinalize(2) # => "2nd"
269
+ # ordinalize(1002) # => "1002nd"
270
+ # ordinalize(1003) # => "1003rd"
271
+ def ordinalize(number)
272
+ if (11..13).include?(number.to_i % 100)
273
+ "#{number}th"
274
+ else
275
+ case number.to_i % 10
276
+ when 1; "#{number}st"
277
+ when 2; "#{number}nd"
278
+ when 3; "#{number}rd"
279
+ else "#{number}th"
280
+ end
281
+ end
282
+ end
283
+ end
284
+
285
+ require File.dirname(__FILE__) + '/inflections'
data/lib/jamis.rb ADDED
@@ -0,0 +1,589 @@
1
+ module RDoc
2
+ module Page
3
+
4
+ FONTS = "\"Bitstream Vera Sans\", Verdana, Arial, Helvetica, sans-serif"
5
+
6
+ STYLE = <<CSS
7
+ a {
8
+ color: #00F;
9
+ text-decoration: none;
10
+ }
11
+
12
+ a:hover {
13
+ color: #77F;
14
+ text-decoration: underline;
15
+ }
16
+
17
+ body, td, p {
18
+ font-family: %fonts%;
19
+ background: #FFF;
20
+ color: #000;
21
+ margin: 0px;
22
+ font-size: small;
23
+ }
24
+
25
+ #content {
26
+ margin: 2em;
27
+ }
28
+
29
+ #description p {
30
+ margin-bottom: 0.5em;
31
+ }
32
+
33
+ .sectiontitle {
34
+ margin-top: 1em;
35
+ margin-bottom: 1em;
36
+ padding: 0.5em;
37
+ padding-left: 2em;
38
+ background: #005;
39
+ color: #FFF;
40
+ font-weight: bold;
41
+ border: 1px dotted black;
42
+ }
43
+
44
+ .attr-rw {
45
+ padding-left: 1em;
46
+ padding-right: 1em;
47
+ text-align: center;
48
+ color: #055;
49
+ }
50
+
51
+ .attr-name {
52
+ font-weight: bold;
53
+ }
54
+
55
+ .attr-desc {
56
+ }
57
+
58
+ .attr-value {
59
+ font-family: monospace;
60
+ }
61
+
62
+ .file-title-prefix {
63
+ font-size: large;
64
+ }
65
+
66
+ .file-title {
67
+ font-size: large;
68
+ font-weight: bold;
69
+ background: #005;
70
+ color: #FFF;
71
+ }
72
+
73
+ .banner {
74
+ background: #005;
75
+ color: #FFF;
76
+ border: 1px solid black;
77
+ padding: 1em;
78
+ }
79
+
80
+ .banner td {
81
+ background: transparent;
82
+ color: #FFF;
83
+ }
84
+
85
+ h1 a, h2 a, .sectiontitle a, .banner a {
86
+ color: #FF0;
87
+ }
88
+
89
+ h1 a:hover, h2 a:hover, .sectiontitle a:hover, .banner a:hover {
90
+ color: #FF7;
91
+ }
92
+
93
+ .dyn-source {
94
+ display: none;
95
+ background: #FFE;
96
+ color: #000;
97
+ border: 1px dotted black;
98
+ margin: 0.5em 2em 0.5em 2em;
99
+ padding: 0.5em;
100
+ }
101
+
102
+ .dyn-source .cmt {
103
+ color: #00F;
104
+ font-style: italic;
105
+ }
106
+
107
+ .dyn-source .kw {
108
+ color: #070;
109
+ font-weight: bold;
110
+ }
111
+
112
+ .method {
113
+ margin-left: 1em;
114
+ margin-right: 1em;
115
+ margin-bottom: 1em;
116
+ }
117
+
118
+ .description pre {
119
+ padding: 0.5em;
120
+ border: 1px dotted black;
121
+ background: #FFE;
122
+ }
123
+
124
+ .method .title {
125
+ font-family: monospace;
126
+ font-size: large;
127
+ border-bottom: 1px dashed black;
128
+ margin-bottom: 0.3em;
129
+ padding-bottom: 0.1em;
130
+ }
131
+
132
+ .method .description, .method .sourcecode {
133
+ margin-left: 1em;
134
+ }
135
+
136
+ .description p, .sourcecode p {
137
+ margin-bottom: 0.5em;
138
+ }
139
+
140
+ .method .sourcecode p.source-link {
141
+ text-indent: 0em;
142
+ margin-top: 0.5em;
143
+ }
144
+
145
+ .method .aka {
146
+ margin-top: 0.3em;
147
+ margin-left: 1em;
148
+ font-style: italic;
149
+ text-indent: 2em;
150
+ }
151
+
152
+ h1 {
153
+ padding: 1em;
154
+ border: 1px solid black;
155
+ font-size: x-large;
156
+ font-weight: bold;
157
+ color: #FFF;
158
+ background: #007;
159
+ }
160
+
161
+ h2 {
162
+ padding: 0.5em 1em 0.5em 1em;
163
+ border: 1px solid black;
164
+ font-size: large;
165
+ font-weight: bold;
166
+ color: #FFF;
167
+ background: #009;
168
+ }
169
+
170
+ h3, h4, h5, h6 {
171
+ padding: 0.2em 1em 0.2em 1em;
172
+ border: 1px dashed black;
173
+ color: #000;
174
+ background: #AAF;
175
+ }
176
+
177
+ .sourcecode > pre {
178
+ padding: 0.5em;
179
+ border: 1px dotted black;
180
+ background: #FFE;
181
+ }
182
+
183
+ CSS
184
+
185
+ XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
186
+ <!DOCTYPE html
187
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
188
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
189
+ }
190
+
191
+ XHTML_FRAMESET_PREAMBLE = %{
192
+ <!DOCTYPE html
193
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
194
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
195
+ }
196
+
197
+ HEADER = XHTML_PREAMBLE + <<ENDHEADER
198
+ <html>
199
+ <head>
200
+ <title>%title%</title>
201
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
202
+ <link rel="stylesheet" href="%style_url%" type="text/css" media="screen" />
203
+
204
+ <script language="JavaScript" type="text/javascript">
205
+ // <![CDATA[
206
+
207
+ function toggleSource( id )
208
+ {
209
+ var elem
210
+ var link
211
+
212
+ if( document.getElementById )
213
+ {
214
+ elem = document.getElementById( id )
215
+ link = document.getElementById( "l_" + id )
216
+ }
217
+ else if ( document.all )
218
+ {
219
+ elem = eval( "document.all." + id )
220
+ link = eval( "document.all.l_" + id )
221
+ }
222
+ else
223
+ return false;
224
+
225
+ if( elem.style.display == "block" )
226
+ {
227
+ elem.style.display = "none"
228
+ link.innerHTML = "show source"
229
+ }
230
+ else
231
+ {
232
+ elem.style.display = "block"
233
+ link.innerHTML = "hide source"
234
+ }
235
+ }
236
+
237
+ function openCode( url )
238
+ {
239
+ window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
240
+ }
241
+ // ]]>
242
+ </script>
243
+ </head>
244
+
245
+ <body>
246
+ ENDHEADER
247
+
248
+ FILE_PAGE = <<HTML
249
+ <table border='0' cellpadding='0' cellspacing='0' width="100%" class='banner'>
250
+ <tr><td>
251
+ <table width="100%" border='0' cellpadding='0' cellspacing='0'><tr>
252
+ <td class="file-title" colspan="2"><span class="file-title-prefix">File</span><br />%short_name%</td>
253
+ <td align="right">
254
+ <table border='0' cellspacing="0" cellpadding="2">
255
+ <tr>
256
+ <td>Path:</td>
257
+ <td>%full_path%
258
+ IF:cvsurl
259
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
260
+ ENDIF:cvsurl
261
+ </td>
262
+ </tr>
263
+ <tr>
264
+ <td>Modified:</td>
265
+ <td>%dtm_modified%</td>
266
+ </tr>
267
+ </table>
268
+ </td></tr>
269
+ </table>
270
+ </td></tr>
271
+ </table><br />
272
+ HTML
273
+
274
+ ###################################################################
275
+
276
+ CLASS_PAGE = <<HTML
277
+ <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
278
+ <td class="file-title"><span class="file-title-prefix">%classmod%</span><br />%full_name%</td>
279
+ <td align="right">
280
+ <table cellspacing="0" cellpadding="2">
281
+ <tr valign="top">
282
+ <td>In:</td>
283
+ <td>
284
+ START:infiles
285
+ HREF:full_path_url:full_path:
286
+ IF:cvsurl
287
+ &nbsp;(<a href="%cvsurl%">CVS</a>)
288
+ ENDIF:cvsurl
289
+ END:infiles
290
+ </td>
291
+ </tr>
292
+ IF:parent
293
+ <tr>
294
+ <td>Parent:</td>
295
+ <td>
296
+ IF:par_url
297
+ <a href="%par_url%">
298
+ ENDIF:par_url
299
+ %parent%
300
+ IF:par_url
301
+ </a>
302
+ ENDIF:par_url
303
+ </td>
304
+ </tr>
305
+ ENDIF:parent
306
+ </table>
307
+ </td>
308
+ </tr>
309
+ </table>
310
+ HTML
311
+
312
+ ###################################################################
313
+
314
+ METHOD_LIST = <<HTML
315
+ <div id="content">
316
+ IF:diagram
317
+ <table cellpadding='0' cellspacing='0' border='0' width="100%"><tr><td align="center">
318
+ %diagram%
319
+ </td></tr></table>
320
+ ENDIF:diagram
321
+
322
+ IF:description
323
+ <div class="description">%description%</div>
324
+ ENDIF:description
325
+
326
+ IF:requires
327
+ <div class="sectiontitle">Required Files</div>
328
+ <ul>
329
+ START:requires
330
+ <li>HREF:aref:name:</li>
331
+ END:requires
332
+ </ul>
333
+ ENDIF:requires
334
+
335
+ IF:toc
336
+ <div class="sectiontitle">Contents</div>
337
+ <ul>
338
+ START:toc
339
+ <li><a href="#%href%">%secname%</a></li>
340
+ END:toc
341
+ </ul>
342
+ ENDIF:toc
343
+
344
+ IF:methods
345
+ <div class="sectiontitle">Methods</div>
346
+ <ul>
347
+ START:methods
348
+ <li>HREF:aref:name:</li>
349
+ END:methods
350
+ </ul>
351
+ ENDIF:methods
352
+
353
+ IF:includes
354
+ <div class="sectiontitle">Included Modules</div>
355
+ <ul>
356
+ START:includes
357
+ <li>HREF:aref:name:</li>
358
+ END:includes
359
+ </ul>
360
+ ENDIF:includes
361
+
362
+ START:sections
363
+ IF:sectitle
364
+ <div class="sectiontitle"><a name="%secsequence%">%sectitle%</a></div>
365
+ IF:seccomment
366
+ <div class="description">
367
+ %seccomment%
368
+ </div>
369
+ ENDIF:seccomment
370
+ ENDIF:sectitle
371
+
372
+ IF:classlist
373
+ <div class="sectiontitle">Classes and Modules</div>
374
+ %classlist%
375
+ ENDIF:classlist
376
+
377
+ IF:constants
378
+ <div class="sectiontitle">Constants</div>
379
+ <table border='0' cellpadding='5'>
380
+ START:constants
381
+ <tr valign='top'>
382
+ <td class="attr-name">%name%</td>
383
+ <td>=</td>
384
+ <td class="attr-value">%value%</td>
385
+ </tr>
386
+ IF:desc
387
+ <tr valign='top'>
388
+ <td>&nbsp;</td>
389
+ <td colspan="2" class="attr-desc">%desc%</td>
390
+ </tr>
391
+ ENDIF:desc
392
+ END:constants
393
+ </table>
394
+ ENDIF:constants
395
+
396
+ IF:attributes
397
+ <div class="sectiontitle">Attributes</div>
398
+ <table border='0' cellpadding='5'>
399
+ START:attributes
400
+ <tr valign='top'>
401
+ <td class='attr-rw'>
402
+ IF:rw
403
+ [%rw%]
404
+ ENDIF:rw
405
+ </td>
406
+ <td class='attr-name'>%name%</td>
407
+ <td class='attr-desc'>%a_desc%</td>
408
+ </tr>
409
+ END:attributes
410
+ </table>
411
+ ENDIF:attributes
412
+
413
+ IF:method_list
414
+ START:method_list
415
+ IF:methods
416
+ <div class="sectiontitle">%type% %category% methods</div>
417
+ START:methods
418
+ <div class="method">
419
+ <div class="title">
420
+ IF:callseq
421
+ <a name="%aref%"></a><b>%callseq%</b>
422
+ ENDIF:callseq
423
+ IFNOT:callseq
424
+ <a name="%aref%"></a><b>%name%</b>%params%
425
+ ENDIF:callseq
426
+ IF:codeurl
427
+ [&nbsp;<a href="%codeurl%" target="SOURCE_CODE" onclick="javascript:openCode('%codeurl%'); return false;">source</a>&nbsp;]
428
+ ENDIF:codeurl
429
+ </div>
430
+ IF:m_desc
431
+ <div class="description">
432
+ %m_desc%
433
+ </div>
434
+ ENDIF:m_desc
435
+ IF:aka
436
+ <div class="aka">
437
+ This method is also aliased as
438
+ START:aka
439
+ <a href="%aref%">%name%</a>
440
+ END:aka
441
+ </div>
442
+ ENDIF:aka
443
+ IF:sourcecode
444
+ <div class="sourcecode">
445
+ <p class="source-link">[ <a href="javascript:toggleSource('%aref%_source')" id="l_%aref%_source">show source</a> ]</p>
446
+ <div id="%aref%_source" class="dyn-source">
447
+ <pre>
448
+ %sourcecode%
449
+ </pre>
450
+ </div>
451
+ </div>
452
+ ENDIF:sourcecode
453
+ </div>
454
+ END:methods
455
+ ENDIF:methods
456
+ END:method_list
457
+ ENDIF:method_list
458
+ END:sections
459
+ </div>
460
+ HTML
461
+
462
+ FOOTER = <<ENDFOOTER
463
+ </body>
464
+ </html>
465
+ ENDFOOTER
466
+
467
+ BODY = HEADER + <<ENDBODY
468
+ !INCLUDE! <!-- banner header -->
469
+
470
+ <div id="bodyContent">
471
+ #{METHOD_LIST}
472
+ </div>
473
+
474
+ #{FOOTER}
475
+ ENDBODY
476
+
477
+ ########################## Source code ##########################
478
+
479
+ SRC_PAGE = XHTML_PREAMBLE + <<HTML
480
+ <html>
481
+ <head><title>%title%</title>
482
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
483
+ <style type="text/css">
484
+ .ruby-comment { color: green; font-style: italic }
485
+ .ruby-constant { color: #4433aa; font-weight: bold; }
486
+ .ruby-identifier { color: #222222; }
487
+ .ruby-ivar { color: #2233dd; }
488
+ .ruby-keyword { color: #3333FF; font-weight: bold }
489
+ .ruby-node { color: #777777; }
490
+ .ruby-operator { color: #111111; }
491
+ .ruby-regexp { color: #662222; }
492
+ .ruby-value { color: #662222; font-style: italic }
493
+ .kw { color: #3333FF; font-weight: bold }
494
+ .cmt { color: green; font-style: italic }
495
+ .str { color: #662222; font-style: italic }
496
+ .re { color: #662222; }
497
+ </style>
498
+ </head>
499
+ <body bgcolor="white">
500
+ <pre>%code%</pre>
501
+ </body>
502
+ </html>
503
+ HTML
504
+
505
+ ########################## Index ################################
506
+
507
+ FR_INDEX_BODY = <<HTML
508
+ !INCLUDE!
509
+ HTML
510
+
511
+ FILE_INDEX = XHTML_PREAMBLE + <<HTML
512
+ <html>
513
+ <head>
514
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
515
+ <title>Index</title>
516
+ <style type="text/css">
517
+ <!--
518
+ body {
519
+ background-color: #EEE;
520
+ font-family: #{FONTS};
521
+ color: #000;
522
+ margin: 0px;
523
+ }
524
+ .banner {
525
+ background: #005;
526
+ color: #FFF;
527
+ padding: 0.2em;
528
+ font-size: small;
529
+ font-weight: bold;
530
+ text-align: center;
531
+ }
532
+ .entries {
533
+ margin: 0.25em 1em 0 1em;
534
+ font-size: x-small;
535
+ }
536
+ a {
537
+ color: #00F;
538
+ text-decoration: none;
539
+ white-space: nowrap;
540
+ }
541
+ a:hover {
542
+ color: #77F;
543
+ text-decoration: underline;
544
+ }
545
+ -->
546
+ </style>
547
+ <base target="docwin" />
548
+ </head>
549
+ <body>
550
+ <div class="banner">%list_title%</div>
551
+ <div class="entries">
552
+ START:entries
553
+ <a href="%href%">%name%</a><br />
554
+ END:entries
555
+ </div>
556
+ </body></html>
557
+ HTML
558
+
559
+ CLASS_INDEX = FILE_INDEX
560
+ METHOD_INDEX = FILE_INDEX
561
+
562
+ INDEX = XHTML_FRAMESET_PREAMBLE + <<HTML
563
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
564
+ <head>
565
+ <title>%title%</title>
566
+ <meta http-equiv="Content-Type" content="text/html; charset=%charset%" />
567
+ </head>
568
+
569
+ <frameset cols="20%,*">
570
+ <frameset rows="15%,35%,50%">
571
+ <frame src="fr_file_index.html" title="Files" name="Files" />
572
+ <frame src="fr_class_index.html" name="Classes" />
573
+ <frame src="fr_method_index.html" name="Methods" />
574
+ </frameset>
575
+ <frame src="%initial_page%" name="docwin" />
576
+ <noframes>
577
+ <body bgcolor="white">
578
+ Click <a href="html/index.html">here</a> for a non-frames
579
+ version of this page.
580
+ </body>
581
+ </noframes>
582
+ </frameset>
583
+
584
+ </html>
585
+ HTML
586
+
587
+ end
588
+ end
589
+