* 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/trunk@10956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8114a2edb0
commit
392f342f04
@ -1,3 +1,8 @@
|
|||||||
|
Sun Sep 17 23:44:58 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/rdoc/rdoc.rb (RDoc::RDoc#document): scan only files modified
|
||||||
|
after the previous generation.
|
||||||
|
|
||||||
Sun Sep 17 17:42:13 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Sep 17 17:42:13 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk (install-doc): reverted.
|
* common.mk (install-doc): reverted.
|
||||||
|
@ -91,6 +91,9 @@ class Options
|
|||||||
# multiple files
|
# multiple files
|
||||||
attr_reader :promiscuous
|
attr_reader :promiscuous
|
||||||
|
|
||||||
|
# scan newer sources than the flag file if true.
|
||||||
|
attr_reader :force_update
|
||||||
|
|
||||||
module OptionList
|
module OptionList
|
||||||
|
|
||||||
OPTION_LIST = [
|
OPTION_LIST = [
|
||||||
@ -134,6 +137,10 @@ class Options
|
|||||||
"Silently discarded if --diagram is not given\n" +
|
"Silently discarded if --diagram is not given\n" +
|
||||||
"Experimental." ],
|
"Experimental." ],
|
||||||
|
|
||||||
|
[ "--force-update", "-U", nil,
|
||||||
|
"forces to scan all sources even if newer than\n" +
|
||||||
|
"the flag file." ],
|
||||||
|
|
||||||
[ "--fmt", "-f", "format name",
|
[ "--fmt", "-f", "format name",
|
||||||
"set the output formatter (see below)" ],
|
"set the output formatter (see below)" ],
|
||||||
|
|
||||||
@ -363,6 +370,7 @@ class Options
|
|||||||
@include_line_numbers = false
|
@include_line_numbers = false
|
||||||
@extra_accessor_flags = {}
|
@extra_accessor_flags = {}
|
||||||
@promiscuous = false
|
@promiscuous = false
|
||||||
|
@force_update = false
|
||||||
|
|
||||||
@css = nil
|
@css = nil
|
||||||
@webcvs = nil
|
@webcvs = nil
|
||||||
@ -462,6 +470,9 @@ class Options
|
|||||||
OptionList.error("Unknown extension .#{old} to -E")
|
OptionList.error("Unknown extension .#{old} to -E")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
when "--force-update"
|
||||||
|
@force_update = true
|
||||||
|
|
||||||
when "--version"
|
when "--version"
|
||||||
puts VERSION_STRING
|
puts VERSION_STRING
|
||||||
exit
|
exit
|
||||||
|
@ -16,6 +16,7 @@ require 'rdoc/diagram'
|
|||||||
|
|
||||||
require 'find'
|
require 'find'
|
||||||
require 'ftools'
|
require 'ftools'
|
||||||
|
require 'time'
|
||||||
|
|
||||||
# We put rdoc stuff in the RDoc module to avoid namespace
|
# We put rdoc stuff in the RDoc module to avoid namespace
|
||||||
# clutter.
|
# clutter.
|
||||||
@ -106,25 +107,38 @@ module RDoc
|
|||||||
# then we refuse to use it, as we may clobber some
|
# then we refuse to use it, as we may clobber some
|
||||||
# manually generated documentation
|
# manually generated documentation
|
||||||
|
|
||||||
def setup_output_dir(op_dir)
|
def setup_output_dir(op_dir, force)
|
||||||
flag_file = File.join(op_dir, "created.rid")
|
flag_file = output_flag_file(op_dir)
|
||||||
if File.exist?(op_dir)
|
if File.exist?(op_dir)
|
||||||
unless File.directory?(op_dir)
|
unless File.directory?(op_dir)
|
||||||
error "'#{op_dir}' exists, and is not a directory"
|
error "'#{op_dir}' exists, and is not a directory"
|
||||||
end
|
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" +
|
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" +
|
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
|
||||||
"destroying any of your existing files, you'll need to\n" +
|
"destroying any of your existing files, you'll need to\n" +
|
||||||
"specify a different output directory name (using the\n" +
|
"specify a different output directory name (using the\n" +
|
||||||
"--op <dir> option).\n\n"
|
"--op <dir> option).\n\n"
|
||||||
|
else
|
||||||
|
last = (Time.parse(created) unless force rescue nil)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
File.makedirs(op_dir)
|
File.makedirs(op_dir)
|
||||||
end
|
end
|
||||||
File.open(flag_file, "w") {|f| f.puts Time.now }
|
last
|
||||||
end
|
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
|
# The .document file contains a list of file and directory name
|
||||||
# patterns, representing candidates for documentation. It may
|
# patterns, representing candidates for documentation. It may
|
||||||
@ -160,8 +174,10 @@ module RDoc
|
|||||||
|
|
||||||
relative_files.each do |rel_file_name|
|
relative_files.each do |rel_file_name|
|
||||||
next if exclude_pattern && exclude_pattern =~ 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"
|
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)
|
file_list << rel_file_name.sub(/^\.\//, '') if force_doc || ParserFactory.can_parse(rel_file_name)
|
||||||
when "directory"
|
when "directory"
|
||||||
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
||||||
@ -239,12 +255,17 @@ module RDoc
|
|||||||
options = Options.instance
|
options = Options.instance
|
||||||
options.parse(argv, GENERATORS)
|
options.parse(argv, GENERATORS)
|
||||||
|
|
||||||
|
@last_created = nil
|
||||||
unless options.all_one_file
|
unless options.all_one_file
|
||||||
setup_output_dir(options.op_dir)
|
@last_created = setup_output_dir(options.op_dir, options.force_update)
|
||||||
end
|
end
|
||||||
|
start_time = Time.now
|
||||||
|
|
||||||
file_info = parse_files(options)
|
file_info = parse_files(options)
|
||||||
|
|
||||||
|
if file_info.empty?
|
||||||
|
$stderr.puts "\nNo newer files." unless options.quiet
|
||||||
|
else
|
||||||
gen = options.generator
|
gen = options.generator
|
||||||
|
|
||||||
$stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
|
$stderr.puts "\nGenerating #{gen.key.upcase}..." unless options.quiet
|
||||||
@ -252,8 +273,6 @@ module RDoc
|
|||||||
require gen.file_name
|
require gen.file_name
|
||||||
|
|
||||||
gen_class = Generators.const_get(gen.class_name)
|
gen_class = Generators.const_get(gen.class_name)
|
||||||
|
|
||||||
unless file_info.empty?
|
|
||||||
gen = gen_class.for(options)
|
gen = gen_class.for(options)
|
||||||
|
|
||||||
pwd = Dir.pwd
|
pwd = Dir.pwd
|
||||||
@ -263,6 +282,7 @@ module RDoc
|
|||||||
begin
|
begin
|
||||||
Diagram.new(file_info, options).draw if options.diagram
|
Diagram.new(file_info, options).draw if options.diagram
|
||||||
gen.generate(file_info)
|
gen.generate(file_info)
|
||||||
|
update_output_dir(".", start_time)
|
||||||
ensure
|
ensure
|
||||||
Dir.chdir(pwd)
|
Dir.chdir(pwd)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user