Skip to content

Commit cd0f3ce

Browse files
committed
(PUP-9997) Remove dead code
The Puppet::Util::Reference.pdf method has been broken since 2012 due to commit f0c9995, because it was calling Puppet::Util.replace_file with 1 argumentm, but it takes 2, resulting in: $ puppet doc --mode pdf --reference type creating pdf Error: Could not run: wrong number of arguments (given 1, expected 2) So delete the code and remove `pdf` as a valid reference doc mode.
1 parent ee46e78 commit cd0f3ce

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

lib/puppet/application/doc.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,7 @@ def other
173173

174174
text += Puppet::Util::Reference.footer unless with_contents # We've only got one reference
175175

176-
if options[:mode] == :pdf
177-
Puppet::Util::Reference.pdf(text)
178-
else
179-
puts text
180-
end
176+
puts text
181177

182178
exit exit_code
183179
end

lib/puppet/util/reference.rb

+1-30
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Puppet::Util::Reference
1313
instance_load(:reference, 'puppet/reference')
1414

1515
def self.modes
16-
%w[pdf text]
16+
%w[text]
1717
end
1818

1919
def self.newreference(name, options = {}, &block)
@@ -32,35 +32,6 @@ def self.page(*sections)
3232
end
3333
end
3434

35-
def self.pdf(text)
36-
puts _("creating pdf")
37-
rst2latex = which('rst2latex') || which('rst2latex.py') ||
38-
raise(_("Could not find rst2latex"))
39-
40-
cmd = %(#{rst2latex} /tmp/puppetdoc.txt > /tmp/puppetdoc.tex)
41-
Puppet::Util.replace_file("/tmp/puppetdoc.txt") { |f| f.puts text }
42-
# There used to be an attempt to use secure_open / replace_file to secure
43-
# the target, too, but that did nothing: the race was still here. We can
44-
# get exactly the same benefit from running this effort:
45-
begin
46-
Puppet::FileSystem.unlink('/tmp/puppetdoc.tex')
47-
rescue
48-
nil
49-
end
50-
output = %x(#{cmd})
51-
unless $CHILD_STATUS == 0
52-
$stderr.puts _("rst2latex failed")
53-
$stderr.puts output
54-
exit(1)
55-
end
56-
$stderr.puts output
57-
58-
# Now convert to pdf
59-
Dir.chdir("/tmp") do
60-
%x(texi2pdf puppetdoc.tex >/dev/null 2>/dev/null)
61-
end
62-
end
63-
6435
def self.references(environment)
6536
instance_loader(:reference).loadall(environment)
6637
loaded_instances(:reference).sort_by(&:to_s)

0 commit comments

Comments
 (0)