forked from raspberrypi/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
42 lines (35 loc) · 898 Bytes
/
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
require "rubygems"
require "rake"
require "redcarpet"
require "html-proofer"
BUILD_DIR = "./_build"
task :build => [:clean]
task :test => [:build]
task :default => [:test]
desc "Generate the build"
task :build do
# copy files
files = Dir.glob("*")
mkdir BUILD_DIR
cp_r files, BUILD_DIR
# render markdown
redcarpet = Redcarpet::Markdown.new Redcarpet::Render::HTML.new({}), {}
md_files = Dir.glob File.join(BUILD_DIR, "**", "*.md")
md_files.each do |md|
html = redcarpet.render File.open(md).read
File.open(md, File::WRONLY).write html
end
puts "Rendered #{md_files.length} markdown files."
end
desc "Remove the build"
task :clean do
rm_rf BUILD_DIR
end
desc "Test the build"
task :test do
options = {
:extension => ".md",
:directory_index_file => "README.md"
}
HTMLProofer.check_directory(BUILD_DIR, options).run
end