Skip to content

Commit 946d259

Browse files
committed
Support different drive latters in include paths
1 parent 45e624e commit 946d259

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/rdoc/options.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,13 @@ def finish_page_dir
555555

556556
@files << @page_dir.to_s
557557

558-
page_dir = @page_dir.expand_path.relative_path_from @root
558+
page_dir = nil
559+
begin
560+
page_dir = @page_dir.expand_path.relative_path_from @root
561+
rescue ArgumentError
562+
# On Windows, sometimes crosses different drive letters.
563+
page_dir = @page_dir.expand_path
564+
end
559565

560566
@page_dir = page_dir
561567
end
@@ -1154,8 +1160,17 @@ def sanitize_path path
11541160

11551161
path.reject do |item|
11561162
path = Pathname.new(item).expand_path
1157-
relative = path.relative_path_from(dot).to_s
1158-
relative.start_with? '..'
1163+
is_reject = nil
1164+
relative = nil
1165+
begin
1166+
relative = path.relative_path_from(dot).to_s
1167+
rescue ArgumentError
1168+
# On Windows, sometimes crosses different drive letters.
1169+
is_reject = true
1170+
else
1171+
is_reject = relative.start_with? '..'
1172+
end
1173+
is_reject
11591174
end
11601175
end
11611176

test/rdoc/test_rdoc_options.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,14 @@ def test_parse_page_dir
493493
assert_empty out
494494
assert_empty err
495495

496-
expected =
497-
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
496+
expected = nil
497+
begin
498+
expected =
499+
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
500+
rescue ArgumentError
501+
# On Windows, sometimes crosses different drive letters.
502+
expected = Pathname(Dir.tmpdir).expand_path
503+
end
498504

499505
assert_equal expected, @options.page_dir
500506
assert_equal [Dir.tmpdir], @options.files

0 commit comments

Comments
 (0)