# vim: syntax=ruby require 'bluecloth' htmlfiles = [] CLEAN = [] FileList['**/*.page'].each do |src| name = src.sub(".page", ".html") htmlfiles << name CLEAN << name file name => [src, "Rakefile"] do File.open(name, "w") do |f| text = File.read(src).sub(/\A^---[^-]+^---$/, '') f.puts BlueCloth.new( text ).to_html end end end task :clean do CLEAN.each do |file| if FileTest.directory?(file) sh %{rm -rf #{file}} elsif FileTest.exists?(file) File.unlink(file) end end end task :html => htmlfiles task :default => :html docs = %w{configref typedocs reports functions} docs.each do |doc| task doc do docs = %x{puppetdoc --mode #{doc}} header = "documentation/reference/%s.header" % doc if FileTest.exists?(header) headertext = File.read(header) else headertext = "" end file = "documentation/reference/%s.page" % doc puts "Creating %s" % file File.open(file, "w") do |f| f.puts headertext f.puts docs end end end task :docs => docs