Skip to content

Commit b9265b5

Browse files
committed
Override .document setting by --exclude option
1 parent 30b7109 commit b9265b5

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

lib/rdoc/rdoc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def parse_dot_doc_file in_dir, filename
258258

259259
patterns.split.each do |patt|
260260
candidates = Dir.glob(File.join(in_dir, patt))
261-
result.concat normalized_file_list(candidates)
261+
result.concat normalized_file_list(candidates, false, @options.exclude)
262262
end
263263

264264
result

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)