-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_doc.rb
executable file
·94 lines (79 loc) · 2.47 KB
/
build_doc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
#!/usr/bin/env ruby
#--
# ===============================================================================
# Copyright (c) 2005,2006,2007 Christopher Kleckner
# All rights reserved
#
# This file is part of the Rio library for ruby.
#
# Rio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Rio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rio; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ===============================================================================
#
# To create the documentation for Rio run the command
# ruby build_doc.rb
# from the distribution directory.
#++
$:.unshift 'lib'
require 'rio'
require 'rio/prompt'
require 'doc/pkg_def'
module DFLT
RDOC_DIR = rio('doc/rdoc')
end
#puts "Rio interactive RDoc installer."
def doc_dir?(d)
have_dirs = ['classes','files'].inject(true) {|isdir,f| isdir and rio(d,f).dir?}
have_files = ['created.rid','fr_class_index.html',
'fr_file_index.html','fr_method_index.html',
'index.html','rdoc-style.css'].inject(true) { |isfile,f| isfile && rio(d,f).file? }
have_dirs && have_files
end
rdoc_dir = RIO.promptr('Where shall I build the rdoc documentation',DFLT::RDOC_DIR)
if rdoc_dir.exist?
delit = 'y'
if rdoc_dir.dir?
unless doc_dir?(rdoc_dir)
delit = RIO.promptd("Directory '#{rdoc_dir}' exists. Would you like to delete it? ", 'n' )
end
else
delit = RIO.promptd("Non directory '#{rdoc_dir}' exists. Would you like to delete it? ", 'n' )
end
if delit =~ /^[yY]/
rio(rdoc_dir).delete!
else
exit(-1)
end
end
rdoc_dir = rio(rdoc_dir)
argv = []
argv << '--op' << rdoc_dir.to_s
argv += PKG::RDOC_OPTIONS
argv += PKG::FILES::DOC
require 'rdoc/rdoc'
begin
r = RDoc::RDoc.new
r.document(argv)
rescue RDoc::RDocError => e
$stderr.puts e.message
exit(1)
end
docindex = (rdoc_dir/'index.html').abs.to_url
msg = "Please point your browser at '#{docindex}'"
lin = ">" + ">" * (msg.length+2) + ">"
puts
puts lin
puts "> " + msg + " >"
puts lin
__END__