summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-17 14:46:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-09-17 14:46:13 +0000
commit90884e98c6679ace9b84b5f260adfce49b0c41ba (patch)
tree4d0ec571851364e0326c5778e090605d319b0e1d /lib
parent695a862e032e12bfd364a18c8b00c96a63b538b8 (diff)
* lib/rdoc/rdoc.rb (RDoc::RDoc#document): scan only files modified
after the previous generation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rdoc/options.rb11
-rw-r--r--lib/rdoc/rdoc.rb54
2 files changed, 48 insertions, 17 deletions
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 53eee992e2..4dfe45169c 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -91,6 +91,9 @@ class Options
# multiple files
attr_reader :promiscuous
+ # scan newer sources than the flag file if true.
+ attr_reader :force_update
+
module OptionList
OPTION_LIST = [
@@ -134,6 +137,10 @@ class Options
"Silently discarded if --diagram is not given\n" +
"Experimental." ],
+ [ "--force-update", "-U", nil,
+ "forces to scan all sources even if newer than\n" +
+ "the flag file." ],
+
[ "--fmt", "-f", "format name",
"set the output formatter (see below)" ],
@@ -363,6 +370,7 @@ class Options
@include_line_numbers = false
@extra_accessor_flags = {}
@promiscuous = false
+ @force_update = false
@css = nil
@webcvs = nil
@@ -462,6 +470,9 @@ class Options
OptionList.error("Unknown extension .#{old} to -E")
end
+ when "--force-update"
+ @force_update = true
+
when "--version"
puts VERSION_STRING
exit
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index cb5d6501d8..91f5611196 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -16,6 +16,7 @@ require 'rdoc/diagram'
require 'find'
require 'ftools'
+require 'time'
# We put rdoc stuff in the RDoc module to avoid namespace
# clutter.
@@ -106,25 +107,38 @@ module RDoc
# then we refuse to use it, as we may clobber some
# manually generated documentation
- def setup_output_dir(op_dir)
- flag_file = File.join(op_dir, "created.rid")
+ def setup_output_dir(op_dir, force)
+ flag_file = output_flag_file(op_dir)
if File.exist?(op_dir)
unless File.directory?(op_dir)
error "'#{op_dir}' exists, and is not a directory"
end
- unless File.file?(flag_file)
+ begin
+ created = File.read(flag_file)
+ rescue SystemCallError
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"
+ else
+ last = (Time.parse(created) unless force rescue nil)
end
else
File.makedirs(op_dir)
end
- File.open(flag_file, "w") {|f| f.puts Time.now }
+ last
+ end
+
+ # Update the flag file in an output directory.
+ def update_output_dir(op_dir, time)
+ File.open(output_flag_file(op_dir), "w") {|f| f.puts time.rfc2822 }
+ end
+
+ # Return the path name of the flag file in an output directory.
+ def output_flag_file(op_dir)
+ File.join(op_dir, "created.rid")
end
-
# The .document file contains a list of file and directory name
# patterns, representing candidates for documentation. It may
@@ -160,8 +174,10 @@ module RDoc
relative_files.each do |rel_file_name|
next if exclude_pattern && exclude_pattern =~ rel_file_name
- case type = File.stat(rel_file_name).ftype
+ stat = File.stat(rel_file_name)
+ case type = stat.ftype
when "file"
+ next if @last_created and stat.mtime < @last_created
file_list << rel_file_name.sub(/^\.\//, '') if force_doc || ParserFactory.can_parse(rel_file_name)
when "directory"
next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -238,22 +254,25 @@ module RDoc
options = Options.instance
options.parse(argv, GENERATORS)
-
+
+ @last_created = nil
unless options.all_one_file
- setup_output_dir(options.op_dir)
+ @last_created = setup_output_dir(options.op_dir, options.force_update)
end
+ start_time = Time.now
file_info = parse_files(options)
- gen = options.generator
-
- $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
-
- require gen.file_name
-
- gen_class = Generators.const_get(gen.class_name)
-
- unless file_info.empty?
+ if file_info.empty?
+ $stderr.puts "\nNo newer files." unless options.quiet
+ else
+ gen = options.generator
+
+ $stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
+
+ require gen.file_name
+
+ gen_class = Generators.const_get(gen.class_name)
gen = gen_class.for(options)
pwd = Dir.pwd
@@ -263,6 +282,7 @@ module RDoc
begin
Diagram.new(file_info, options).draw if options.diagram
gen.generate(file_info)
+ update_output_dir(".", start_time)
ensure
Dir.chdir(pwd)
end