forked from urbanairship/java-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
80 lines (66 loc) · 2.47 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
# Copyright 2013 Urban Airship
desc "Build the docs for the API Client using javasphinx. This produces rst for sphinx"
task :build_javadocs do
puts "Building javadocs"
# These need to be broken up into per directory calls to control
# what gets into the docs
sh "javasphinx-apidoc -f -o ./docs src/main/java/com/urbanairship/api/client/"
sh "javasphinx-apidoc -f -o ./docs src/main/java/com/urbanairship/api/push/model/audience"
sh "javasphinx-apidoc -f -o ./docs src/main/java/com/urbanairship/api/push/model/notification/ios"
puts "Finished build_javadocs"
end
desc "Build the Sphinx docs. This builds the actual HTML"
task :build_sphinx_docs do
puts "Building Sphinx docs"
# Change directory for the do block only
Dir.chdir("./docs") do
sh "make html"
end
puts "Finished build_sphinx_docs"
end
desc "Glob the javasphinx-apidoc document output directory and append the output to the packages.rst file"
task :setup_packages_rst do
puts "Setting up packages.rst with package-index.rst files globbed from docs/com/**"
packages_rst_path = "./docs/packages.rst"
dir_glob = Dir.glob("docs/com/**/package-index.rst")
lines = nil
File.open(packages_rst_path) do |f|
lines = f.readlines
end
# Strip out old directories in packages.rst data and append new
# dirs.
updated_lines = lines.select {| line | !line.include? "com/urbanairship"}
package_index_paths = dir_glob.map do |path|
truncated_path = path.slice /com\/.*/
# add Tab spaces and newline for file output
" " + truncated_path + "\n"
end
tmp_write_path = packages_rst_path + "-tmp"
File.open(tmp_write_path, 'w') do |fh|
(updated_lines + package_index_paths).each do |line|
fh.write(line)
end
end
# if the above process didn't exception, move tmp to actual
FileUtils.mv(tmp_write_path, packages_rst_path, {:verbose => true})
puts "Finished setup_packages_rst"
end
desc "Clean the docs/com directory, this is not cleaned by javasphinx"
task :clean_docs do
puts "Cleaning docs"
if File.directory? "./docs/com"
FileUtils.remove_entry_secure("./docs/com/")
puts "docs/com cleaned"
else
puts "No 'docs/com/' directory, cleaning skipped"
end
Dir.chdir("./docs") do
sh "make clean"
end
puts "Ran 'make clean'"
end
# TODO The dependencies for all the tasks need to be setup more cleanly
desc "Build all the docs"
task :build_docs => [:clean_docs, :build_javadocs, :setup_packages_rst, :build_sphinx_docs] do
puts "Built the docs"
end