From 50d188cc2f447a17b43b5bc7c9db5f7430826529 Mon Sep 17 00:00:00 2001 From: nfagerlund Date: Wed, 8 Jun 2011 17:18:15 -0700 Subject: Maint: Update static man page generator for Faces. The man page updater wasn't making man pages for the new Faces app. This commit gives it that capability, and handles the name collision on puppet resource. Reviewed-By: Nick Lewis --- tasks/rake/manpages.rake | 54 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/tasks/rake/manpages.rake b/tasks/rake/manpages.rake index f7275e4c3..a2dc850c8 100644 --- a/tasks/rake/manpages.rake +++ b/tasks/rake/manpages.rake @@ -2,36 +2,68 @@ desc "Build Puppet manpages" task :gen_manpages do + require 'puppet/face' + require 'fileutils' + helpface = Puppet::Face[:help, '0.0.1'] + manface = Puppet::Face[:man, '0.0.1'] sbins = Dir.glob(%w{sbin/*}) bins = Dir.glob(%w{bin/*}) - applications = Dir.glob(%w{lib/puppet/application/*}) + non_face_applications = helpface.legacy_applications + faces = Puppet::Face.faces + ronn_args = '--manual="Puppet manual" --organization="Puppet Labs, LLC" -r' + # Locate ronn ronn = %x{which ronn}.chomp unless File.executable?(ronn) then fail("Ronn does not appear to be installed.") end +# def write_manpage(text, filename) +# IO.popen("#{ronn} #{ronn_args} -r > #{filename}") do |fh| fh.write text end +# end + # Create puppet.conf.5 man page +# IO.popen("#{ronn} #{ronn_args} > ./man/man5/puppet.conf.5", 'w') do |fh| +# fh.write %x{RUBYLIB=./lib:$RUBYLIB bin/puppetdoc --reference configuration} +# end %x{RUBYLIB=./lib:$RUBYLIB bin/puppetdoc --reference configuration > ./man/man5/puppetconf.5.ronn} - %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man5/puppetconf.5.ronn} - File.move("./man/man5/puppetconf.5", "./man/man5/puppet.conf.5") - File.unlink("./man/man5/puppetconf.5.ronn") + %x{#{ronn} #{ronn_args} ./man/man5/puppetconf.5.ronn} + FileUtils.mv("./man/man5/puppetconf.5", "./man/man5/puppet.conf.5") + FileUtils.rm("./man/man5/puppetconf.5.ronn") # Create LEGACY binary man pages (i.e. delete me for 2.8.0) binary = bins + sbins binary.each do |bin| b = bin.gsub( /^s?bin\//, "") %x{RUBYLIB=./lib:$RUBYLIB #{bin} --help > ./man/man8/#{b}.8.ronn} - %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/#{b}.8.ronn} - File.unlink("./man/man8/#{b}.8.ronn") + %x{#{ronn} #{ronn_args} ./man/man8/#{b}.8.ronn} + FileUtils.rm("./man/man8/#{b}.8.ronn") end - # Create modern binary man pages - applications.each do |app| - app.gsub!( /^lib\/puppet\/application\/(.*?)\.rb/, '\1') + # Create regular non-face man pages + non_face_applications.each do |app| %x{RUBYLIB=./lib:$RUBYLIB bin/puppet #{app} --help > ./man/man8/puppet-#{app}.8.ronn} - %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/puppet-#{app}.8.ronn} - File.unlink("./man/man8/puppet-#{app}.8.ronn") + %x{#{ronn} #{ronn_args} ./man/man8/puppet-#{app}.8.ronn} + FileUtils.rm("./man/man8/puppet-#{app}.8.ronn") + end + + # Create face man pages + faces.each do |face| + File.open("./man/man8/puppet-#{face}.8.ronn", 'w') do |fh| + # For some reason no one understands at the moment, it duplicates termini, + # so we have to remove the dupes with a gsub. + fh.write manface.man("#{face}", {:render_as => :s}).gsub(/^(\* `[^`]+`)\n\1/, '\1') + end + + %x{#{ronn} #{ronn_args} ./man/man8/puppet-#{face}.8.ronn} + FileUtils.rm("./man/man8/puppet-#{face}.8.ronn") end + # Vile hack: create puppet resource man page + # Currently, the useless resource face wins against puppet resource in puppet + # man. (And actually, it even gets removed from the list of legacy + # applications.) So we overwrite it with the correct man page at the end. + %x{RUBYLIB=./lib:$RUBYLIB bin/puppet resource --help > ./man/man8/puppet-resource.8.ronn} + %x{#{ronn} #{ronn_args} ./man/man8/puppet-resource.8.ronn} + FileUtils.rm("./man/man8/puppet-resource.8.ronn") end \ No newline at end of file -- cgit