forked from nasser/zajal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
64 lines (51 loc) · 1.92 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
require_relative 'lib/zajal'
namespace :docs do
DocsDirectory = "docs"
OutputDirectory = "#{DocsDirectory}/out"
StaticDirectory = "#{DocsDirectory}/static"
SourceDirectory = "lib"
DocsURL = "docs.zajal.cc"
desc "Remove generated documentation"
task :clean do
rm_rf OutputDirectory
end
desc "Build the documentation"
task :build, :file do |t, args|
require_relative 'docs/lib/yard-zajal'
log.show_progress = true
d = Dir.pwd
YARD.parse(args[:file] ? args[:file] : SourceDirectory)
Dir.chdir d
FileUtils.mkpath "#{OutputDirectory}"
log.capture("Writing index") { File.open("#{OutputDirectory}/index.html", 'w') { |f| f.write Index.render } }
# YARD::Registry.all(:method).each do |methobj|
# if methobj.tag(:api) and methobj.tag(:api).text == "zajal"
# log.capture("Writing #{methobj.file_path}") do
# FileUtils.mkpath "#{OutputDirectory}/#{methobj.file_path}/"
# File.open("#{OutputDirectory}/#{methobj.file_path}/index.html", 'w') { |f| f.write Mathod.new(methobj).render }
# end
# end
# end
cp_r FileList["#{StaticDirectory}/*"], OutputDirectory
end
task :build => :clean
desc "Deploy documentation to http://#{DocsURL}"
task :deploy => :build do
require "aws/s3"
include AWS::S3
require "yard"
log.show_progress = true
log.capture("Connecting to Amazon") do
Base.establish_connection!(
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
)
end
Bucket.find(DocsURL).each { |obj| log.capture("Deleting #{obj.key}") { obj.delete } }
# upload new documentation
cd OutputDirectory
Dir["**/*"].select { |f| f =~ /\.(html|css|js|ttf|eot|woff|svg)$/ }.each do |filename|
log.capture("Storing #{filename}") { S3Object.store(filename, open(filename), 'docs.zajal.cc', :access => :public_read) }
end
end
end