-
Notifications
You must be signed in to change notification settings - Fork 24
/
Rakefile
98 lines (80 loc) · 2.44 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
require "rspec/core/rake_task"
require "yaml"
require "launchy"
STAGING_DIR = "staging"
SITE_DIR = "site"
TUTORIALS_DIR = "tutorials"
require_relative "tasks/tutorial_tasks"
require_relative "tasks/nokogiri_tasks"
namespace :dev do
MKDOCS_DIR = "../mkdocs"
MKDOCS_MATERIAL_INSIDERS_DIR = "mkdocs-material"
desc "Set up system dependencies to develop this site."
task :setup do
sh "pip3 install --upgrade --user pygments pymdown-extensions pillow cairosvg"
sh "pip3 uninstall --yes mkdocs-material"
if File.directory?(MKDOCS_MATERIAL_INSIDERS_DIR)
Dir.chdir(MKDOCS_MATERIAL_INSIDERS_DIR) do
# https://squidfunk.github.io/mkdocs-material/customization/#environment-setup
sh "pip3 install --user -e ."
sh "pip install mkdocs-minify-plugin"
sh "pip install mkdocs-redirects"
sh "npm install"
end
else
puts "WARNING: you don't have mkdocs-material-insiders installed, using OSS version"
sh "pip3 install --upgrade --user mkdocs-material"
end
end
# there is a patch of mkdocs-material search plugin to support rdoc pages here:
# https://gist.github.com/flavorjones/a2ee50d94888537d561db53c837c4bbf
task :build do |_, args|
dirty_p = args.extras.include?("dirty")
Dir.chdir(MKDOCS_MATERIAL_INSIDERS_DIR) do
if dirty_p
sh "npm run build:dirty"
else
sh "npm run build"
end
end
end
end
desc "Push everything to Github Pages"
task :deploy => :generate do
sh "mkdocs gh-deploy"
end
namespace :tutorials do
tasks = create_tutorial_tasks("docs", STAGING_DIR)
desc "Pull in tutorial content"
task :generate => tasks
end
namespace :nokogiri do
tasks = create_nokogiri_tasks(nokogiri_dir, STAGING_DIR)
desc "Pull in Nokogiri repo files"
task :generate => tasks
end
namespace :mkdocs do
desc "Use mkdocs to generate a static site"
task :generate do
sh "mkdocs build"
end
desc "Use mkdocs to generate a static site"
task :preview do
Thread.new do
sleep 1
Launchy.open "http://localhost:8000"
end
sh "mkdocs serve"
end
end
task :clean do
FileUtils.rm_rf STAGING_DIR
FileUtils.rm_rf SITE_DIR
end
desc "generate a static site"
task :generate => ["tutorials:generate", "nokogiri:generate", "mkdocs:generate"]
desc "preview the site"
task :preview => ["tutorials:generate", "nokogiri:generate", "mkdocs:preview"]
RSpec::Core::RakeTask.new(:spec)
task :spec => :generate
task :default => :spec