-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
72 lines (62 loc) · 1.81 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
require 'nanoc3/tasks'
desc "Compile the site"
task :compile do
`nanoc compile`
end
desc "Publish to http://docs.rmx.im"
task :publish => [ :clean ] do
FileUtils.rm_r('public') if File.exist?('public')
`nanoc compile`
# this should not be necessary, but I can't figure out how to
# just keep a goddamn static file in the root with nanoc
File.open("public/CNAME", 'w+') do |f|
f.puts("docs.encounter.io")
end
ENV['GIT_DIR'] = File.expand_path(`git rev-parse --git-dir`.chomp)
old_sha = `git rev-parse refs/remotes/origin/gh-pages`.chomp
Dir.chdir('public') do
ENV['GIT_INDEX_FILE'] = gif = '/tmp/docs.rmx.im-index'
ENV['GIT_WORK_TREE'] = Dir.pwd
File.unlink(gif) if File.file?(gif)
`git add -A`
tsha = `git write-tree`.strip
puts "Created tree #{tsha}"
if old_sha.size == 40
csha = `echo 'boom' | git commit-tree #{tsha} -p #{old_sha}`.strip
else
csha = `echo 'boom' | git commit-tree #{tsha}`.strip
end
puts "Created commit #{csha}"
puts `git show #{csha} --stat`
puts "Updating gh-pages from #{old_sha}"
`git update-ref refs/heads/gh-pages #{csha}`
`git push origin gh-pages`
end
end
task :ref, :name do |t, args|
name = ARGV.first.gsub(/^ref\[(.*)\]$/, '\1').split(' :: ')
File.open('./content/api/ref/' + name[0] + '.md', 'w') do |f|
f.write <<EOF
---
title: API - Reference - #{name[0]}
---
### #{name[0]} :: #{name[1]}
EOF
end
end
task :event, :name do |t, args|
name = ARGV.first.gsub(/^event\[(.*)\]$/, '\1').split(' :: ')
File.open('./content/api/event/' + name[0] + '.md', 'w') do |f|
f.write <<EOF
---
title: API - event - #{name[0]}
---
### event #{name[0]}
#{ if name[1] then
"## Event Data\n\n" + name[1].split(',').map {|x|
"<span class='event-data-field'>" + x.strip + "</span>\n"
}.join("\n")
end }
EOF
end
end