This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
doctool.pl
executable file
·98 lines (72 loc) · 2.51 KB
/
doctool.pl
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
#!perl
# ewpratten's javadoc tool
# By: Evan Pratten <ewpratten@retrylife.ca>
use 5.010;
use strict;
use warnings;
# Handle CLI flags
my ($mode, $setting) = @ARGV;
# Ensure we actually have flags
if (not defined $mode){
print "No program arguments specified. \nUse one of -l (local) or -p (publish) to specify mode.\n";
exit 1;
} else {
print "Starting javadoc tool\n";
}
# No matter the mode, we must build the documentation first
print "Building javadoc\n";
system("./gradlew javadoc --console=plain");
# Deal with javascript bug
print "Injecting javascript search bugfix\n";
system("sed -i 's/useModuleDirectories/false/g' build/reports/docs/search.js");
# Handle local hosting
if ($mode eq "-l"){
print("Starting local javadoc server\n");
print("This will move to the documentation directory\n");
# Move to docs directory
chdir "./build/reports/docs";
# Start http server
system("python -m SimpleHTTPServer 5806");
} elsif ($mode eq "-p"){
print "Publishing documentation\n";
# Read the current git origin URL
my $origin = `git config --get remote.origin.url`;
chomp $origin;
# Read the repo name and dir
my $name = `basename \`git rev-parse --show-toplevel\``;
my $dir = `pwd`;
chomp $name;
chomp $dir;
print "Detected repo settings (Name: '$name', URL: '$origin')\n";
# Clone a copy of the current repo, one level up
chdir "../";
system("git clone '$origin' '$name-DOBLE_TMP'");
chdir "$name-DOBLE_TMP";
# Checkout the latest gh-pages branch (Redundant)
# system("git checkout -b gh-pages");
my $fail = system("git checkout gh-pages");
if ($fail){
print "Could not checkout gh-pages\n";
exit 1;
}
# Determine date string for branch name
my $date = `date +"%I_%M-%h%d"`;
chomp $date;
# Checkout a new branch for this docs release
my $new_branch = "javadoc-doble-$date";
system("git checkout -b $new_branch");
# Remove all branch contents
system("rm -rf ./*");
system("git add .");
system("git commit -m \"Auto-authored by doble. Branch cleared\"");
# Copy all documentation over to new branch
system("cp -r $dir/build/reports/docs/* .");
# Add all and make a commit for the new changes
system("git add .");
system("git commit -m \"Auto-authored by doble. Javadocs have been updated\"");
# Push the changes
system("git push --set-upstream origin $new_branch");
} else {
print "Invalid program arguments. Stopping\n";
exit 1;
}