bitclust-dev 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/tools/bc-tochm.rb ADDED
@@ -0,0 +1,301 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'pathname'
4
+ def srcdir_root
5
+ (Pathname.new(__FILE__).realpath.dirname + '..').cleanpath
6
+ end
7
+
8
+ $LOAD_PATH.unshift srcdir_root() + 'lib'
9
+
10
+ #def srcdir_root
11
+ # #Pathname.new(__FILE__).realpath.dirname.parent.cleanpath
12
+ # Pathname.new(__FILE__).dirname.parent.cleanpath
13
+ #end
14
+ #$LOAD_PATH.unshift srcdir_root + 'lib'
15
+
16
+ require 'bitclust'
17
+ require 'erb'
18
+ require 'fileutils'
19
+ require 'kconv'
20
+ require 'optparse'
21
+ begin
22
+ require 'progressbar'
23
+ rescue LoadError
24
+ class ProgressBar
25
+ def initialize(title, total, out = STDERR)
26
+ @title, @total, @out = title, total, out
27
+ end
28
+ attr_reader :title
29
+
30
+ def inc(step = 1)
31
+ end
32
+
33
+ def finish
34
+ end
35
+ end
36
+ end
37
+
38
+ HHP_SKEL = <<EOS
39
+ [OPTIONS]
40
+ Compatibility=1.1 or later
41
+ Compiled file=refm.chm
42
+ Contents file=refm.hhc
43
+ Default Window=titlewindow
44
+ Default topic=doc/index.html
45
+ Display compile progress=No
46
+ Error log file=refm.log
47
+ Full-text search=Yes
48
+ Index file=refm.hhk
49
+ Language=0x411 日本語 (日本)
50
+ Title=Rubyリファレンスマニュアル
51
+
52
+ [WINDOWS]
53
+ titlewindow="Rubyリファレンスマニュアル","refm.hhc","refm.hhk","doc/index.html","doc/index.html",,,,,0x21420,,0x387e,,,,,,,,0
54
+
55
+ [FILES]
56
+ <%= @html_files.join("\n") %>
57
+ EOS
58
+
59
+ HHC_SKEL = <<EOS
60
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
61
+ <HTML>
62
+ <HEAD>
63
+ </HEAD>
64
+ <BODY>
65
+ <UL><% [:library].each do |k| %>
66
+ <%= @sitemap[k].to_html %>
67
+ <% end %></UL>
68
+ </BODY>
69
+ </HTML>
70
+ EOS
71
+
72
+ HHK_SKEL = <<EOS
73
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
74
+ <HTML>
75
+ <HEAD>
76
+ </HEAD>
77
+ <BODY>
78
+ <UL><% @index_contents.sort.each do |content| %>
79
+ <%= content.to_html %>
80
+ <% end %></UL>
81
+ </BODY>
82
+ </HTML>
83
+ EOS
84
+
85
+ class Sitemap
86
+ def initialize(name, local = nil)
87
+ @name = name
88
+ @contents = Content.new(name, local)
89
+ end
90
+
91
+ def method_missing(name, *args, &block)
92
+ @contents.send(name, *args, &block)
93
+ end
94
+
95
+ class Content
96
+ include Enumerable
97
+ include ERB::Util
98
+
99
+ def initialize(name, local = nil)
100
+ @name = name
101
+ @local = local
102
+ @contents = []
103
+ end
104
+ attr_reader :name, :local, :contents
105
+
106
+ def [](index)
107
+ @contents[index]
108
+ end
109
+
110
+ def <<(content)
111
+ @contents << content
112
+ end
113
+
114
+ def <=>(other)
115
+ @name <=> other.name
116
+ end
117
+
118
+ def each
119
+ @contents.each do |content|
120
+ yield content
121
+ end
122
+ end
123
+
124
+ def to_html
125
+ str = "<LI> <OBJECT type=\"text/sitemap\">\n"
126
+ str << " <param name=\"Name\" value=\"<%=h @name%>\">\n"
127
+ if @local
128
+ str << " <param name=\"Local\" value=\"<%=@local%>\">\n"
129
+ end
130
+ str << " </OBJECT>\n"
131
+ unless contents.empty?
132
+ str << "<UL>\n"
133
+ @contents.each do |content|
134
+ str << content.to_html
135
+ end
136
+ str << "</UL>\n"
137
+ end
138
+ ERB.new(str).result(binding)
139
+ end
140
+ end
141
+ end
142
+
143
+ module BitClust
144
+
145
+ class URLMapperEx < URLMapper
146
+ def library_url(name)
147
+ if name == '/'
148
+ "/library/index.html"
149
+ else
150
+ "/library/#{encodename_fs(name)}.html"
151
+ end
152
+ end
153
+
154
+ def class_url(name)
155
+ "/class/#{encodename_fs(name)}.html"
156
+ end
157
+
158
+ def method_url(spec)
159
+ cname, tmark, mname = *split_method_spec(spec)
160
+ "/method/#{encodename_fs(cname)}/#{typemark2char(tmark)}/#{encodename_fs(mname)}.html"
161
+ end
162
+
163
+ def document_url(name)
164
+ "/doc/#{encodename_fs(name)}.html"
165
+ end
166
+ end
167
+ end
168
+
169
+ def main
170
+ @sitemap = {
171
+ :library => Sitemap.new('ライブラリ', 'library/index.html'),
172
+ }
173
+ @sitemap[:library] << Sitemap::Content.new('標準ライブラリ', 'library/_builtin.html')
174
+ @sitemap[:library] << Sitemap::Content.new('添付ライブラリ')
175
+ @stdlibs = {}
176
+ @index_contents = []
177
+ prefix = Pathname.new('./db')
178
+ outputdir = Pathname.new('./chm')
179
+ manager_config = {
180
+ :baseurl => 'http://example.com/',
181
+ :suffix => '.html',
182
+ :templatedir => srcdir_root + 'data'+ 'bitclust' + 'template',
183
+ :themedir => srcdir_root + 'theme' + 'default',
184
+ :css_url => 'style.css',
185
+ :cgi_url => '',
186
+ :tochm_mode => true
187
+ }
188
+ manager_config[:urlmapper] = BitClust::URLMapperEx.new(manager_config)
189
+
190
+ parser = OptionParser.new
191
+ parser.on('-d', '--database=PATH', 'Database prefix') do |path|
192
+ prefix = Pathname.new(path).realpath
193
+ end
194
+ parser.on('-o', '--outputdir=PATH', 'Output directory') do |path|
195
+ begin
196
+ outputdir = Pathname.new(path).realpath
197
+ rescue Errno::ENOENT
198
+ FileUtils.mkdir_p(path, :verbose => true)
199
+ retry
200
+ end
201
+ end
202
+ parser.on('--help', 'Prints this message and quit') do
203
+ puts(parser.help)
204
+ exit(0)
205
+ end
206
+ begin
207
+ parser.parse!
208
+ rescue OptionParser::ParseError => err
209
+ STDERR.puts(err.message)
210
+ STDERR.puts(parser.help)
211
+ exit(1)
212
+ end
213
+
214
+ db = BitClust::MethodDatabase.new(prefix.to_s)
215
+ manager = BitClust::ScreenManager.new(manager_config)
216
+ @html_files = []
217
+ db.transaction do
218
+ methods = {}
219
+ pb = ProgressBar.new('method', db.methods.size)
220
+ db.methods.each_with_index do |entry, i|
221
+ method_name = entry.klass.name + entry.typemark + entry.name
222
+ (methods[method_name] ||= []) << entry
223
+ pb.inc
224
+ end
225
+ pb.finish
226
+ entries = db.docs + db.libraries.sort + db.classes.sort + methods.values.sort
227
+ pb = ProgressBar.new('entry', entries.size)
228
+ entries.each_with_index do |c, i|
229
+ filename = create_html_file(c, manager, outputdir, db)
230
+ @html_files << filename
231
+ e = c.is_a?(Array) ? c.sort.first : c
232
+ case e.type_id
233
+ when :library
234
+ content = Sitemap::Content.new(e.name.to_s, filename)
235
+ if e.name.to_s != '_builtin'
236
+ @sitemap[:library][1] << content
237
+ @stdlibs[e.name.to_s] = content
238
+ end
239
+ @index_contents << Sitemap::Content.new(e.name.to_s, filename)
240
+ when :class
241
+ content = Sitemap::Content.new(e.name.to_s, filename)
242
+ if e.library.name.to_s == '_builtin'
243
+ @sitemap[:library][0] << content
244
+ else
245
+ @stdlibs[e.library.name.to_s] << content
246
+ end
247
+ @index_contents << Sitemap::Content.new("#{e.name} (#{e.library.name})", filename)
248
+ when :method
249
+ e.names.each do |e_name|
250
+ name = e.typename == :special_variable ? "$#{e_name}" : e_name
251
+ @index_contents <<
252
+ Sitemap::Content.new("#{name} (#{e.library.name} - #{e.klass.name})", filename)
253
+ @index_contents <<
254
+ Sitemap::Content.new("#{e.klass.name}#{e.typemark}#{name} (#{e.library.name})", filename)
255
+ end
256
+ end
257
+ pb.title.replace(e.name)
258
+ pb.inc
259
+ end
260
+ pb.finish
261
+ end
262
+ @html_files.sort!
263
+ create_file(outputdir + 'refm.hhp', HHP_SKEL, true)
264
+ create_file(outputdir + 'refm.hhc', HHC_SKEL, true)
265
+ create_file(outputdir + 'refm.hhk', HHK_SKEL, true)
266
+ create_file(outputdir + 'library/index.html', manager.library_index_screen(db.libraries.sort, {:database => db}).body)
267
+ create_file(outputdir + 'class/index.html', manager.class_index_screen(db.classes.sort, {:database => db}).body)
268
+ FileUtils.cp(manager_config[:themedir] + manager_config[:css_url],
269
+ outputdir.to_s, {:verbose => true, :preserve => true})
270
+ end
271
+
272
+ def create_html_file(entry, manager, outputdir, db)
273
+ html = manager.entry_screen(entry, {:database => db}).body
274
+ e = entry.is_a?(Array) ? entry.sort.first : entry
275
+ path = case e.type_id
276
+ when :library, :class, :doc
277
+ outputdir + e.type_id.to_s + (BitClust::NameUtils.encodename_fs(e.name) + '.html')
278
+ when :method
279
+ outputdir + e.type_id.to_s + BitClust::NameUtils.encodename_fs(e.klass.name) +
280
+ e.typechar + (BitClust::NameUtils.encodename_fs(e.name) + '.html')
281
+ else
282
+ raise
283
+ end
284
+ FileUtils.mkdir_p(path.dirname) unless path.dirname.directory?
285
+ path.open('w') do |f|
286
+ f.write(html)
287
+ end
288
+ path.relative_path_from(outputdir).to_s
289
+ end
290
+
291
+ def create_file(path, skel, sjis_flag = false)
292
+ STDERR.print("creating #{path} ...")
293
+ str = ERB.new(skel).result(binding)
294
+ str = str.tosjis if sjis_flag
295
+ path.open('w') do |f|
296
+ f.write(str)
297
+ end
298
+ STDERR.puts(" done.")
299
+ end
300
+
301
+ main
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # bc-tohtml.rb
4
+ #
5
+ # Copyright (c) 2006-2007 Minero Aoki
6
+ #
7
+ # This program is free software.
8
+ # You can distribute/modify this program under the Ruby License.
9
+ #
10
+
11
+ require 'pathname'
12
+
13
+ def srcdir_root
14
+ (Pathname.new(__FILE__).realpath.dirname + '..').cleanpath
15
+ end
16
+
17
+ $LOAD_PATH.unshift srcdir_root() + 'lib'
18
+
19
+ $KCODE = 'UTF-8' unless Object.const_defined?(:Encoding)
20
+
21
+ require 'bitclust'
22
+ require 'optparse'
23
+
24
+ def main
25
+ templatedir = srcdir_root() + 'data' + 'bitclust' + 'template.offline'
26
+ target = nil
27
+ baseurl = 'file://' + srcdir_root.to_s
28
+ parser = OptionParser.new
29
+ ver = '1.9.0'
30
+ parser.banner = "Usage: #{File.basename($0, '.*')} rdfile"
31
+ parser.on('--target=NAME', 'Compile NAME to HTML.') {|name|
32
+ target = name
33
+ }
34
+ parser.on('--force', '-f', 'Force to use rd_file template.') {|name|
35
+ @rd_file = true
36
+ }
37
+ parser.on('--ruby_version=VER', '--ruby=VER', 'Set Ruby version') {|v|
38
+ ver = v
39
+ }
40
+ parser.on('--db=DB', '--database=DB', 'Set database path') {|path|
41
+ db = BitClust::Database.new(path)
42
+ }
43
+ parser.on('--baseurl=URL', 'Base URL of generated HTML') {|url|
44
+ baseurl = url
45
+ }
46
+ parser.on('--templatedir=PATH', 'Template directory') {|path|
47
+ templatedir = path
48
+ }
49
+ parser.on('--help', 'Prints this message and quit.') {
50
+ puts parser.help
51
+ exit 0
52
+ }
53
+ parser.on('--capi', 'C API mode.') {
54
+ @capi = true
55
+ }
56
+ begin
57
+ parser.parse!
58
+ rescue OptionParser::ParseError => err
59
+ $stderr.puts err.message
60
+ $stderr.puts parser.help
61
+ exit 1
62
+ end
63
+ if ARGV.size > 1
64
+ $stderr.puts "too many arguments (expected 1)"
65
+ exit 1
66
+ end
67
+
68
+ db ||= BitClust::Database.dummy({'version' => ver})
69
+ manager = BitClust::ScreenManager.new(
70
+ :templatedir => templatedir,
71
+ :base_url => baseurl,
72
+ :cgi_url => baseurl,
73
+ :default_encoding => 'utf-8')
74
+ unless @rd_file
75
+ begin
76
+ if @capi
77
+ lib = BitClust::FunctionReferenceParser.parse_file(ARGV[0], {'version' => ver})
78
+ unless target
79
+ raise NotImplementedError, "generating a C API html without --target=NAME is not implemented yet."
80
+ end
81
+ else
82
+ lib = BitClust::RRDParser.parse_stdlib_file(ARGV[0], {'version' => ver})
83
+ end
84
+ entry = target ? lookup(lib, target) : lib
85
+ puts manager.entry_screen(entry, {:database => db}).body
86
+ return
87
+ rescue BitClust::ParseError => ex
88
+ $stderr.puts ex.message
89
+ $stderr.puts ex.backtrace[0], ex.backtrace[1..-1].map{|s| "\tfrom " + s}
90
+ end
91
+ end
92
+
93
+ ent = BitClust::DocEntry.new(db, ARGV[0])
94
+ ret = BitClust::Preprocessor.read(ARGV[0], {'version' => ver})
95
+ ent.source = ret
96
+ puts manager.doc_screen(ent, {:database => db} ).body
97
+ return
98
+ rescue BitClust::WriterError => err
99
+ $stderr.puts err.message
100
+ exit 1
101
+ end
102
+
103
+ def lookup(lib, key)
104
+ case
105
+ when @capi && BitClust::NameUtils.functionname?(key)
106
+ lib.find {|func| func.name == key}
107
+ when BitClust::NameUtils.method_spec?(key)
108
+ spec = BitClust::MethodSpec.parse(key)
109
+ if spec.constant?
110
+ begin
111
+ lib.fetch_class(key)
112
+ rescue BitClust::UserError
113
+ lib.fetch_methods(spec)
114
+ end
115
+ else
116
+ lib.fetch_methods(spec)
117
+ end
118
+ when BitClust::NameUtils.classname?(key)
119
+ lib.fetch_class(key)
120
+ else
121
+ raise BitClust::InvalidKey, "wrong search key: #{key.inspect}"
122
+ end
123
+ end
124
+
125
+ main
@@ -0,0 +1,241 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'pathname'
4
+
5
+ def srcdir_root
6
+ (Pathname.new(__FILE__).realpath.dirname + '..').cleanpath
7
+ end
8
+ $LOAD_PATH.unshift srcdir_root() + 'lib'
9
+
10
+ require 'bitclust'
11
+ require 'fileutils'
12
+ require 'optparse'
13
+
14
+ if Object.const_defined?(:Encoding)
15
+ Encoding.default_external = 'utf-8'
16
+ end
17
+
18
+ module BitClust
19
+
20
+ class URLMapperEx < URLMapper
21
+ def library_url(name)
22
+ if name == '/'
23
+ $bitclust_html_base + "/library/index.html"
24
+ else
25
+ $bitclust_html_base + "/library/#{encodename_package(name)}.html"
26
+ end
27
+ end
28
+
29
+ def class_url(name)
30
+ $bitclust_html_base + "/class/#{encodename_package(name)}.html"
31
+ end
32
+
33
+ def method_url(spec)
34
+ cname, tmark, mname = *split_method_spec(spec)
35
+ $bitclust_html_base +
36
+ "/method/#{encodename_package(cname)}/#{typemark2char(tmark)}/#{encodename_package(mname)}.html"
37
+ end
38
+
39
+ def function_url(name)
40
+ $bitclust_html_base + "/function/#{name.empty? ? 'index' : name}.html"
41
+ end
42
+
43
+ def document_url(name)
44
+ $bitclust_html_base + "/doc/#{encodename_package(name)}.html"
45
+ end
46
+
47
+ def css_url
48
+ $bitclust_html_base + "/" + @css_url
49
+ end
50
+
51
+ def favicon_url
52
+ $bitclust_html_base + "/" + @favicon_url
53
+ end
54
+
55
+ def library_index_url
56
+ $bitclust_html_base + "/library/index.html"
57
+ end
58
+
59
+ def function_index_url
60
+ $bitclust_html_base + "/function/index.html"
61
+ end
62
+
63
+ end
64
+ end
65
+
66
+ def main
67
+ prefix = Pathname.new('./db')
68
+ outputdir = Pathname.new('./doc')
69
+ templatedir = srcdir_root + 'data'+ 'bitclust' + 'template'
70
+ catalogdir = nil
71
+ verbose = true
72
+ parser = OptionParser.new
73
+ parser.on('-d', '--database=PATH', 'Database prefix') do |path|
74
+ prefix = Pathname.new(path).realpath
75
+ end
76
+ parser.on('-o', '--outputdir=PATH', 'Output directory') do |path|
77
+ begin
78
+ outputdir = Pathname.new(path).realpath
79
+ rescue Errno::ENOENT
80
+ FileUtils.mkdir_p(path, :verbose => verbose)
81
+ retry
82
+ end
83
+ end
84
+ parser.on('--catalog=PATH', 'Catalog directory') do |path|
85
+ catalogdir = Pathname.new(path).realpath
86
+ end
87
+ parser.on('--templatedir=PATH', 'Template directory') do |path|
88
+ templatedir = Pathname.new(path).realpath
89
+ end
90
+ parser.on('--fs-casesensitive', 'Filesystem is case-sensitive') do
91
+ $fs_casesensitive = true
92
+ end
93
+ parser.on('--[no-]quiet', 'Be quiet') do |quiet|
94
+ verbose = !quiet
95
+ end
96
+ parser.on('--help', 'Prints this message and quit') do
97
+ puts(parser.help)
98
+ exit(0)
99
+ end
100
+ begin
101
+ parser.parse!
102
+ rescue OptionParser::ParseError => err
103
+ STDERR.puts(err.message)
104
+ STDERR.puts(parser.help)
105
+ exit(1)
106
+ end
107
+
108
+ manager_config = {
109
+ :catalogdir => catalogdir,
110
+ :suffix => '.html',
111
+ :templatedir => templatedir,
112
+ :themedir => srcdir_root + 'theme' + 'default',
113
+ :css_url => 'style.css',
114
+ :favicon_url => 'rurema.png',
115
+ :cgi_url => '',
116
+ :tochm_mode => true
117
+ }
118
+ manager_config[:urlmapper] = BitClust::URLMapperEx.new(manager_config)
119
+
120
+ db = BitClust::MethodDatabase.new(prefix.to_s)
121
+ fdb = BitClust::FunctionDatabase.new(prefix.to_s)
122
+ manager = BitClust::ScreenManager.new(manager_config)
123
+ db.transaction do
124
+ methods = {}
125
+ db.methods.each_with_index do |entry, i|
126
+ method_name = entry.klass.name + entry.typemark + entry.name
127
+ (methods[method_name] ||= []) << entry
128
+ end
129
+ entries = db.docs + db.libraries.sort + db.classes.sort + methods.values
130
+ entries.each_with_index do |c, i|
131
+ create_html_file(c, manager, outputdir, db)
132
+ $stderr.puts("#{i}/#{entries.size} done") if i % 100 == 0 and verbose
133
+ end
134
+ end
135
+ fdb.transaction do
136
+ functions = {}
137
+ fdb.functions.each_with_index do |entry, i|
138
+ create_html_file(entry, manager, outputdir, fdb)
139
+ $stderr.puts("#{i} done") if i % 100 == 0 and verbose
140
+ end
141
+ end
142
+ $bitclust_html_base = '..'
143
+ create_file(outputdir + 'library/index.html',
144
+ manager.library_index_screen(db.libraries.sort, {:database => db}).body,
145
+ :verbose => verbose)
146
+ create_file(outputdir + 'class/index.html',
147
+ manager.class_index_screen(db.classes.sort, {:database => db}).body,
148
+ :verbose => verbose)
149
+ create_file(outputdir + 'function/index.html',
150
+ manager.function_index_screen(fdb.functions.sort, { :database => fdb }).body,
151
+ :verbose => verbose)
152
+ create_index_html(outputdir)
153
+ FileUtils.cp(manager_config[:themedir] + manager_config[:css_url],
154
+ outputdir.to_s, {:verbose => verbose, :preserve => true})
155
+ FileUtils.cp(manager_config[:themedir] + manager_config[:favicon_url],
156
+ outputdir.to_s, {:verbose => verbose, :preserve => true})
157
+ Dir.mktmpdir do |tmpdir|
158
+ FileUtils.cp_r(manager_config[:themedir] + 'images', tmpdir,
159
+ {:verbose => verbose, :preserve => true})
160
+ Dir.glob(File.join(tmpdir, 'images', '/**/.svn')).each do |d|
161
+ FileUtils.rm_r(d, {:verbose => verbose})
162
+ end
163
+ FileUtils.cp_r(File.join(tmpdir, 'images'), outputdir.to_s,
164
+ {:verbose => verbose, :preserve => true})
165
+ end
166
+ end
167
+
168
+ def encodename_package(str)
169
+ if $fs_casesensitive
170
+ BitClust::NameUtils.encodename_url(str)
171
+ else
172
+ BitClust::NameUtils.encodename_fs(str)
173
+ end
174
+ end
175
+
176
+ def create_index_html(outputdir)
177
+ path = outputdir + 'index.html'
178
+ File.open(path, 'w'){|io|
179
+ io.write <<HERE
180
+ <meta http-equiv="refresh" content="0; URL=doc/index.html">
181
+ <a href="doc/index.html">Go</a>
182
+ HERE
183
+ }
184
+ end
185
+
186
+ def create_html_file(entry, manager, outputdir, db)
187
+ e = entry.is_a?(Array) ? entry.sort.first : entry
188
+ case e.type_id
189
+ when :library, :class, :doc
190
+ $bitclust_html_base = '..'
191
+ path = outputdir + e.type_id.to_s + (encodename_package(e.name) + '.html')
192
+ create_html_file_p(entry, manager, path, db)
193
+ path.relative_path_from(outputdir).to_s
194
+ when :method
195
+ create_html_method_file(entry, manager, outputdir, db)
196
+ when :function
197
+ create_html_function_file(entry, manager, outputdir, db)
198
+ else
199
+ raise
200
+ end
201
+ e.unload
202
+ end
203
+
204
+ def create_html_method_file(entry, manager, outputdir, db)
205
+ path = nil
206
+ $bitclust_html_base = '../../..'
207
+ e = entry.is_a?(Array) ? entry.sort.first : entry
208
+ e.names.each{|name|
209
+ path = outputdir + e.type_id.to_s + encodename_package(e.klass.name) +
210
+ e.typechar + (encodename_package(name) + '.html')
211
+ create_html_file_p(entry, manager, path, db)
212
+ }
213
+ path.relative_path_from(outputdir).to_s
214
+ end
215
+
216
+ def create_html_function_file(entry, manager, outputdir, db)
217
+ path = nil
218
+ $bitclust_html_base = '..'
219
+ path = outputdir + entry.type_id.to_s + (entry.name + '.html')
220
+ create_html_file_p(entry, manager, path, db)
221
+ path.relative_path_from(outputdir).to_s
222
+ end
223
+
224
+ def create_html_file_p(entry, manager, path, db)
225
+ FileUtils.mkdir_p(path.dirname) unless path.dirname.directory?
226
+ html = manager.entry_screen(entry, {:database => db}).body
227
+ path.open('w') do |f|
228
+ f.write(html)
229
+ end
230
+ end
231
+
232
+ def create_file(path, str, options={})
233
+ verbose = options[:verbose]
234
+ STDERR.print("creating #{path} ...") if verbose
235
+ path.open('w') do |f|
236
+ f.write(str)
237
+ end
238
+ STDERR.puts(" done.") if verbose
239
+ end
240
+
241
+ main