Skip to content

Commit

Permalink
[ruby/rdoc] Support different drive latters in include paths
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Oct 29, 2019
1 parent b4da6fc commit c8ce37d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
21 changes: 18 additions & 3 deletions lib/rdoc/options.rb
Expand Up @@ -555,7 +555,13 @@ def finish_page_dir

@files << @page_dir.to_s

page_dir = @page_dir.expand_path.relative_path_from @root
page_dir = nil
begin
page_dir = @page_dir.expand_path.relative_path_from @root
rescue ArgumentError
# On Windows, sometimes crosses different drive letters.
page_dir = @page_dir.expand_path
end

@page_dir = page_dir
end
Expand Down Expand Up @@ -1154,8 +1160,17 @@ def sanitize_path path

path.reject do |item|
path = Pathname.new(item).expand_path
relative = path.relative_path_from(dot).to_s
relative.start_with? '..'
is_reject = nil
relative = nil
begin
relative = path.relative_path_from(dot).to_s
rescue ArgumentError
# On Windows, sometimes crosses different drive letters.
is_reject = true
else
is_reject = relative.start_with? '..'
end
is_reject
end
end

Expand Down
10 changes: 8 additions & 2 deletions test/rdoc/test_rdoc_options.rb
Expand Up @@ -507,8 +507,14 @@ def test_parse_page_dir
assert_empty out
assert_empty err

expected =
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
expected = nil
begin
expected =
Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root
rescue ArgumentError
# On Windows, sometimes crosses different drive letters.
expected = Pathname(Dir.tmpdir).expand_path
end

assert_equal expected, @options.page_dir
assert_equal [Dir.tmpdir], @options.files
Expand Down

0 comments on commit c8ce37d

Please sign in to comment.