Skip to content

Commit 0526d97

Browse files
authored
Merge pull request #603 from aycabta/override-dot_doc-by-exclude-option
Override .document by --exclude option
2 parents 81522d7 + b9265b5 commit 0526d97

File tree

2 files changed

+56
-10
lines changed

2 files changed

+56
-10
lines changed

lib/rdoc/rdoc.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ class RDoc::RDoc
3535

3636
GENERATORS = {}
3737

38-
##
39-
# File pattern to exclude
40-
41-
attr_accessor :exclude
42-
4338
##
4439
# Generator instance used for creating output
4540

@@ -93,7 +88,6 @@ def self.current= rdoc
9388

9489
def initialize
9590
@current = nil
96-
@exclude = nil
9791
@generator = nil
9892
@last_modified = {}
9993
@old_siginfo = nil
@@ -116,7 +110,7 @@ def error(msg)
116110
def gather_files files
117111
files = ["."] if files.empty?
118112

119-
file_list = normalized_file_list files, true, @exclude
113+
file_list = normalized_file_list files, true, @options.exclude
120114

121115
file_list = file_list.uniq
122116

@@ -264,7 +258,7 @@ def parse_dot_doc_file in_dir, filename
264258

265259
patterns.split.each do |patt|
266260
candidates = Dir.glob(File.join(in_dir, patt))
267-
result.concat normalized_file_list(candidates)
261+
result.concat normalized_file_list(candidates, false, @options.exclude)
268262
end
269263

270264
result
@@ -472,8 +466,6 @@ def document options
472466
exit
473467
end
474468

475-
@exclude = @options.exclude
476-
477469
unless @options.coverage_report then
478470
@last_modified = setup_output_dir @options.op_dir, @options.force_update
479471
end

test/test_rdoc_rdoc.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,60 @@ def test_normalized_file_list_non_file_directory
181181
assert_match %r"#{dev}$", err
182182
end
183183

184+
def test_normalized_file_list_with_dot_doc
185+
expected_files = []
186+
files = temp_dir do |dir|
187+
a = File.expand_path('a.rb')
188+
b = File.expand_path('b.rb')
189+
c = File.expand_path('c.rb')
190+
FileUtils.touch a
191+
FileUtils.touch b
192+
FileUtils.touch c
193+
194+
dot_doc = File.expand_path('.document')
195+
FileUtils.touch dot_doc
196+
open(dot_doc, 'w') do |f|
197+
f.puts 'a.rb'
198+
f.puts 'b.rb'
199+
end
200+
expected_files << a
201+
expected_files << b
202+
203+
@rdoc.normalized_file_list [dir]
204+
end
205+
206+
files = files.map { |file| File.expand_path file }
207+
208+
assert_equal expected_files, files
209+
end
210+
211+
def test_normalized_file_list_with_dot_doc_overridden_by_exclude_option
212+
expected_files = []
213+
files = temp_dir do |dir|
214+
a = File.expand_path('a.rb')
215+
b = File.expand_path('b.rb')
216+
c = File.expand_path('c.rb')
217+
FileUtils.touch a
218+
FileUtils.touch b
219+
FileUtils.touch c
220+
221+
dot_doc = File.expand_path('.document')
222+
FileUtils.touch dot_doc
223+
open(dot_doc, 'w') do |f|
224+
f.puts 'a.rb'
225+
f.puts 'b.rb'
226+
end
227+
expected_files << a
228+
229+
@rdoc.options.exclude = Regexp.new(['b.rb'].join('|'))
230+
@rdoc.normalized_file_list [dir]
231+
end
232+
233+
files = files.map { |file| File.expand_path file }
234+
235+
assert_equal expected_files, files
236+
end
237+
184238
def test_parse_file
185239
@rdoc.store = RDoc::Store.new
186240

0 commit comments

Comments
 (0)