summaryrefslogtreecommitdiffstats
path: root/tasks/rake/manpages.rake
blob: f7275e4c384c543a5edb407d8b876c469d056357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# require 'fileutils'

desc "Build Puppet manpages"
task :gen_manpages do

  sbins = Dir.glob(%w{sbin/*})
  bins  = Dir.glob(%w{bin/*})
  applications  = Dir.glob(%w{lib/puppet/application/*})
  # Locate ronn
  ronn = %x{which ronn}.chomp
  unless File.executable?(ronn) then fail("Ronn does not appear to be installed.") end

  # Create puppet.conf.5 man page
  %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")

  # 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")
  end

  # Create modern binary man pages
  applications.each do |app|
    app.gsub!( /^lib\/puppet\/application\/(.*?)\.rb/, '\1')
    %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")
  end


end