Skip to content

Commit 6767686

Browse files
committed
(PUP-391) Fix Rdoc 4+ specs on Windows Ruby 2 x64
- When calling the document method on RDoc and the root option has not been specified, RDoc will provide a default in the options class: @root = Pathname(Dir.pwd). NOTE: This does not affect RDoc 3.9.5 that ships with Ruby 1.9.3 on Windows, only RDoc 4.0.0+ that ships with Ruby 2.0.0+ on Windows. - The win32-dir monkey patches the Dir.pwd method, and instead of using / separators like the rest of Ruby, it uses \ as a path separator. - RDoc uses Pathname, specifically the relative_path_from method which expects / separators, and gets confused with \. Therefore, provide a workaround to ensure that Windows uses the appropriate / in paths.
1 parent 0bc115f commit 6767686

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/puppet/util/rdoc.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def rdoc(outputdir, files, charset = nil)
3737
options << "--force-update"
3838
end
3939
options += [ "--charset", charset] if charset
40+
# Rdoc root default is Dir.pwd, but the win32-dir gem monkey patchs Dir.pwd
41+
# replacing Ruby's normal / with \. When RDoc generates relative paths it
42+
# uses relative_path_from that will generate errors when the slashes don't
43+
# properly match. This is a workaround for that issue.
44+
if Puppet.features.microsoft_windows? && RDoc::VERSION !~ /^[0-3]\./
45+
options += [ "--root", Dir.pwd.gsub(/\\/, '/')]
46+
end
4047
options += files
4148

4249
# launch the documentation process

0 commit comments

Comments
 (0)