summaryrefslogtreecommitdiff
path: root/lib/rdoc/rdoc.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-11 01:34:28 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-11 01:34:28 +0000
commitff5366a7053a2d420139e32fb3936ee85a2839fe (patch)
tree4d499b33305a640e0d054a5018b6416477a10580 /lib/rdoc/rdoc.rb
parent48a68756f5813a078d3c69a4180a9102208f953b (diff)
Update to RDoc 2.5.3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/rdoc.rb')
-rw-r--r--lib/rdoc/rdoc.rb67
1 files changed, 38 insertions, 29 deletions
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index ed25d4c796..bdc4fa0205 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -38,6 +38,11 @@ class RDoc::RDoc
attr_accessor :generator
##
+ # Hash of files and their last modified times.
+
+ attr_reader :last_modified
+
+ ##
# RDoc options
attr_accessor :options
@@ -75,13 +80,13 @@ class RDoc::RDoc
end
def initialize
- @current = nil
- @exclude = nil
- @generator = nil
- @last_created = {}
- @old_siginfo = nil
- @options = nil
- @stats = nil
+ @current = nil
+ @exclude = nil
+ @generator = nil
+ @last_modified = {}
+ @old_siginfo = nil
+ @options = nil
+ @stats = nil
end
##
@@ -132,35 +137,39 @@ class RDoc::RDoc
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as
# we may clobber some manually generated documentation
- def setup_output_dir(op_dir, force)
- flag_file = output_flag_file op_dir
+ def setup_output_dir(dir, force)
+ flag_file = output_flag_file dir
last = {}
- if File.exist? op_dir then
- unless File.directory? op_dir then
- error "'#{op_dir}' exists, and is not a directory"
- end
+ if File.exist? dir then
+ error "#{dir} exists and is not a directory" unless File.directory? dir
+
begin
open flag_file do |io|
- unless force
+ unless force then
Time.parse io.gets
+
io.each do |line|
- file, time = line.split(/\t/, 2)
+ file, time = line.split "\t", 2
time = Time.parse(time) rescue next
last[file] = time
end
end
end
- rescue
- error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
- "isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
- "destroying any of your existing files, you'll need to\n" +
- "specify a different output directory name (using the\n" +
- "--op <dir> option).\n\n"
+ rescue SystemCallError, TypeError
+ error <<-ERROR
+
+Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
+
+Because RDoc doesn't want to risk destroying any of your existing files,
+you'll need to specify a different output directory name (using the --op <dir>
+option)
+
+ ERROR
end
else
- FileUtils.mkdir_p(op_dir)
+ FileUtils.mkdir_p dir
end
last
@@ -170,7 +179,7 @@ class RDoc::RDoc
# Update the flag file in an output directory.
def update_output_dir(op_dir, time, last = {})
- File.open(output_flag_file(op_dir), "w") do |f|
+ open output_flag_file(op_dir), "w" do |f|
f.puts time.rfc2822
last.each do |n, t|
f.puts "#{n}\t#{t.rfc2822}"
@@ -226,12 +235,12 @@ class RDoc::RDoc
case type = stat.ftype
when "file" then
- next if last_created = @last_created[rel_file_name] and
- stat.mtime.to_i <= last_created.to_i
+ next if last_modified = @last_modified[rel_file_name] and
+ stat.mtime.to_i <= last_modified.to_i
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
file_list << rel_file_name.sub(/^\.\//, '')
- @last_created[rel_file_name] = stat.mtime
+ @last_modified[rel_file_name] = stat.mtime
end
when "directory" then
next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -356,7 +365,7 @@ The internal error was:
@exclude = @options.exclude
- @last_created = setup_output_dir @options.op_dir, @options.force_update
+ @last_modified = setup_output_dir @options.op_dir, @options.force_update
start_time = Time.now
@@ -382,7 +391,7 @@ The internal error was:
self.class.current = self
@generator.generate file_info
- update_output_dir ".", start_time, @last_created
+ update_output_dir ".", start_time, @last_modified
ensure
self.class.current = nil
end
@@ -396,7 +405,7 @@ The internal error was:
end
def read_file_contents(filename)
- content = File.open(filename, "rb") { |f| f.read }
+ content = open filename, "rb" do |f| f.read end
if defined? Encoding then
if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]