Skip to content

Override .document by --exclude option #603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions lib/rdoc/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ class RDoc::RDoc

GENERATORS = {}

##
# File pattern to exclude

attr_accessor :exclude

##
# Generator instance used for creating output

Expand Down Expand Up @@ -93,7 +88,6 @@ def self.current= rdoc

def initialize
@current = nil
@exclude = nil
@generator = nil
@last_modified = {}
@old_siginfo = nil
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions test/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down