summaryrefslogtreecommitdiff
path: root/lib/rdoc/rdoc.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-28 14:45:44 +0900
committeraycabta <aycabta@gmail.com>2020-09-18 14:57:58 +0900
commite23f0f29daa45f69ef78b174340c747ac09bfb60 (patch)
treedd5191d06314d6812f3a4eb0b3a4777f63adee64 /lib/rdoc/rdoc.rb
parentb5db9b8a314249adee021ba6a426c6a2ebbc6804 (diff)
[ruby/rdoc] update all files if any file is newer
Cross references need parse all files which define the subject names. This commit makes `--force-update` option enforce to parse all files if any file is newer than the previous parse, not only updated files. https://github.com/ruby/rdoc/commit/13e9a44896
Diffstat (limited to 'lib/rdoc/rdoc.rb')
-rw-r--r--lib/rdoc/rdoc.rb38
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index a0835d1dfe..93e764c462 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -112,11 +112,17 @@ class RDoc::RDoc
file_list = normalized_file_list files, true, @options.exclude
- file_list = file_list.uniq
-
- file_list = remove_unparseable file_list
-
- file_list.sort
+ file_list = remove_unparseable(file_list)
+
+ if file_list.count {|name, mtime|
+ file_list[name] = @last_modified[name] unless mtime
+ mtime
+ } > 0
+ @last_modified.replace file_list
+ file_list.keys.sort
+ else
+ []
+ end
end
##
@@ -254,11 +260,11 @@ option)
# read and strip comments
patterns = File.read(filename).gsub(/#.*/, '')
- result = []
+ result = {}
patterns.split(' ').each do |patt|
candidates = Dir.glob(File.join(in_dir, patt))
- result.concat normalized_file_list(candidates, false, @options.exclude)
+ result.update normalized_file_list(candidates, false, @options.exclude)
end
result
@@ -278,21 +284,21 @@ option)
def normalized_file_list(relative_files, force_doc = false,
exclude_pattern = nil)
- file_list = []
+ file_list = {}
relative_files.each do |rel_file_name|
+ rel_file_name = rel_file_name.sub(/^\.\//, '')
next if rel_file_name.end_with? 'created.rid'
next if exclude_pattern && exclude_pattern =~ rel_file_name
stat = File.stat rel_file_name rescue next
case type = stat.ftype
when "file" then
- next if last_modified = @last_modified[rel_file_name] and
- stat.mtime.to_i <= last_modified.to_i
+ mtime = (stat.mtime unless (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_modified[rel_file_name] = stat.mtime
+ file_list[rel_file_name] = mtime
end
when "directory" then
next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -303,16 +309,16 @@ option)
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
if File.file? dot_doc then
- file_list << parse_dot_doc_file(rel_file_name, dot_doc)
+ file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
else
- file_list << list_files_in_directory(rel_file_name)
+ file_list.update(list_files_in_directory(rel_file_name))
end
else
warn "rdoc can't parse the #{type} #{rel_file_name}"
end
end
- file_list.flatten
+ file_list
end
##
@@ -427,7 +433,7 @@ The internal error was:
# files for emacs and vim.
def remove_unparseable files
- files.reject do |file|
+ files.reject do |file, *|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
(file =~ /tags$/i and
open(file, 'rb') { |io|