summaryrefslogtreecommitdiffstats
path: root/documentation/Rakefile
blob: 640a7cf5dc3fb2b6ec49d43a096adf094a15515d (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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