1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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:
nobu 2006-09-17 14:46:13 +00:00
parent 8114a2edb0
commit 392f342f04
3 changed files with 53 additions and 17 deletions

View file

@ -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>
* common.mk (install-doc): reverted.

View file

@ -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

View file

@ -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