forked from puppetlabs/puppet-docs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
157 lines (128 loc) · 3.98 KB
/
Rakefile
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
require 'rubygems'
require 'rake'
require 'pathname'
require 'fileutils'
require 'linktree'
$LOAD_PATH.unshift File.expand_path('lib')
dependencies = %w(maruku nokogiri erubis rack blockenspiel versionomy)
references = %w(configuration function indirection metaparameter network report type)
namespace :install do
dependencies.each do |dep|
desc "Install '#{dep}' dependency"
task dep do
sh "gem install #{dep} --no-rdoc --no-ri"
end
end
end
desc "Install dependencies"
task :install => dependencies.map { |d| "install:#{d}" }
desc "Generate the documentation"
task :generate do
ENV.delete("PDF")
sh "bin/generate"
Rake::Task['references:symlink'].invoke
end
task :generate_pdf do
ENV["PDF"]="1"
sh "bin/generate"
Rake::Task['references:symlink'].invoke
what_files = Scanner.new('output','output/index.html').run()
sh "htmldoc -f puppet.pdf #{what_files}"
end
desc "Serve generated output on port 9292"
task :serve do
sh "rackup"
end
desc "Generate docs and serve locally"
task :run => [:generate, :serve]
desc "Create tarball of documentation"
task :tarball do
FileUtils.rm_rf 'output'
Rake::Task['generate'].invoke
FileUtils.cd('output')
FileUtils.ln_s '../files', 'guides/files'
FileUtils.ln_s '../../files', 'guides/types/files'
FileUtils.ln_s '../../../files', 'guides/types/nagios/files'
FileUtils.ln_s '../../../files', 'guides/types/selinux/files'
FileUtils.ln_s '../../files', 'guides/types/ssh/files'
FileUtils.ln_s '../files', 'references/files'
sh "tar -czf puppetdocs-latest.tar.gz *"
FileUtils.mv 'puppetdocs-latest.tar.gz', '..'
FileUtils.cd '..'
FileUtils.rm_rf 'output'
end
namespace :references do
namespace :symlink do
desc "Show the versions that will be symlinked"
task :versions do
require 'puppet_docs'
PuppetDocs::Reference.special_versions.each do |name, (version, source)|
puts "#{name}: #{version}"
end
end
end
desc "Symlink the latest & stable directories"
task :symlink do
require 'puppet_docs'
PuppetDocs::Reference.special_versions.each do |name, (version, source)|
Dir.chdir 'output/references' do
ln_s version.to_s, name.to_s
end
end
end
namespace :puppetdoc do
references.each do |name|
desc "Write references/VERSION/#{name}.txt"
task name => 'references:check_version' do
require 'puppet_docs'
PuppetDocs::Reference::Generator.new(ENV['VERSION'], name).generate
end
end
end
desc "Write all references for VERSION"
task :puppetdoc => references.map { |r| "puppetdoc:#{r}" }
namespace :index do
desc "Generate a stub index for VERSION"
task :stub => 'references:check_version' do
filename = Pathname.new('source/references') + ENV['VERSION'] + 'index.markdown'
filename.parent.mkpath
filename.open('w') do |f|
f.puts "# #{ENV['VERSION']} References"
f.puts "* * *\n\n"
f.puts "These are autogenerated from [puppetdoc](/projects/puppet/puppetdoc.html)."
references.each do |name|
f.puts "* [#{name.capitalize}](#{name}.html)"
end
end
puts "Wrote #{filename}"
end
end
task :check_version do
abort "No VERSION given (must be a valid repo tag)" unless ENV['VERSION']
end
end
#
# Puppet Labs Only:
# DISABLED FOR NOW, not the right location
#desc "Release the documentation (Puppet Labs Only)"
#task :release do
# sh "rsync -e ssh -avz output/ [email protected]:/var/www/docs/html"
#end
#require 'spec/rake/spectask'
#Spec::Rake::SpecTask.new(:spec) do |spec|
# spec.libs << 'lib' << 'spec'
# spec.spec_files = FileList['spec/**/*_spec.rb']
#end
#Spec::Rake::SpecTask.new(:rcov) do |spec|
# spec.libs << 'lib' << 'spec'
# spec.pattern = 'spec/**/*_spec.rb'
# spec.rcov = true
#end
task :default => :spec
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "puppet-docs"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end