diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 875461917c..31a92b3bec 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -35,11 +35,6 @@ class RDoc::RDoc GENERATORS = {} - ## - # File pattern to exclude - - attr_accessor :exclude - ## # Generator instance used for creating output @@ -93,7 +88,6 @@ def self.current= rdoc def initialize @current = nil - @exclude = nil @generator = nil @last_modified = {} @old_siginfo = nil @@ -116,7 +110,7 @@ def error(msg) def gather_files files files = ["."] if files.empty? - file_list = normalized_file_list files, true, @exclude + file_list = normalized_file_list files, true, @options.exclude file_list = file_list.uniq @@ -264,7 +258,7 @@ def parse_dot_doc_file in_dir, filename patterns.split.each do |patt| candidates = Dir.glob(File.join(in_dir, patt)) - result.concat normalized_file_list(candidates) + result.concat normalized_file_list(candidates, false, @options.exclude) end result @@ -472,8 +466,6 @@ def document options exit end - @exclude = @options.exclude - unless @options.coverage_report then @last_modified = setup_output_dir @options.op_dir, @options.force_update end diff --git a/test/test_rdoc_rdoc.rb b/test/test_rdoc_rdoc.rb index c46d9b4396..7c54e543f9 100644 --- a/test/test_rdoc_rdoc.rb +++ b/test/test_rdoc_rdoc.rb @@ -181,6 +181,60 @@ def test_normalized_file_list_non_file_directory assert_match %r"#{dev}$", err end + def test_normalized_file_list_with_dot_doc + expected_files = [] + files = temp_dir do |dir| + a = File.expand_path('a.rb') + b = File.expand_path('b.rb') + c = File.expand_path('c.rb') + FileUtils.touch a + FileUtils.touch b + FileUtils.touch c + + dot_doc = File.expand_path('.document') + FileUtils.touch dot_doc + open(dot_doc, 'w') do |f| + f.puts 'a.rb' + f.puts 'b.rb' + end + expected_files << a + expected_files << b + + @rdoc.normalized_file_list [dir] + end + + files = files.map { |file| File.expand_path file } + + assert_equal expected_files, files + end + + def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option + expected_files = [] + files = temp_dir do |dir| + a = File.expand_path('a.rb') + b = File.expand_path('b.rb') + c = File.expand_path('c.rb') + FileUtils.touch a + FileUtils.touch b + FileUtils.touch c + + dot_doc = File.expand_path('.document') + FileUtils.touch dot_doc + open(dot_doc, 'w') do |f| + f.puts 'a.rb' + f.puts 'b.rb' + end + expected_files << a + + @rdoc.options.exclude = Regexp.new(['b.rb'].join('|')) + @rdoc.normalized_file_list [dir] + end + + files = files.map { |file| File.expand_path file } + + assert_equal expected_files, files + end + def test_parse_file @rdoc.store = RDoc::Store.new