forked from keycloak/keycloak-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-product.sh
executable file
·126 lines (105 loc) · 2.86 KB
/
build-product.sh
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash -e
TOOL="asciidoctor"
while getopts "h?auc" opt; do
case "$opt" in
h|\?)
echo "Usage: build-guide.sh [OPTION] [GUIDE]"
echo ""
echo " -a use asciidoctor (default)"
echo " -u use ccutil"
echo " -c delete built guides"
echo ""
echo "If guide is not specified all guides are built. GUIDE should be the directory"
echo "name of the specific guide to build."
exit 0
;;
a) TOOL="asciidoctor"
;;
u) TOOL="ccutil"
;;
c) TOOL="clean"
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
GUIDE_DIR=$1
function printLine
{
echo "************************************************************************************************"
}
function getTitle
{
GUIDE_DIR=`readlink -f $1`
TITLE_KEY=`cat $GUIDE_DIR/master-docinfo.xml | grep '<title>' | cut -d '{' -f 2 | cut -d '}' -f 1`
TITLE=`cat $GUIDE_DIR/topics/templates/document-attributes-product.adoc | grep $TITLE_KEY | sed "s/:$TITLE_KEY: //"`
echo $TITLE
}
function buildGuide
{
GUIDE_DIR=`readlink -f $1`
TITLE=`getTitle $GUIDE_DIR`
printLine
echo ""
echo "Building: $TITLE"
echo ""
cd $GUIDE_DIR
echo "Deleting $GUIDE_DIR/build"
rm -rf build
echo ""
echo "Running asciidoctor..."
echo ""
asciidoctor -t -dbook -a toc -o target/html/index.html master.adoc
echo ""
echo "Running ccutil..."
echo ""
ccutil compile --lang en_US --format html-single --main-file master.adoc
cd ..
echo ""
echo "Done"
echo ""
}
function clean
{
GUIDE_DIR=`readlink -f $1`
cd $GUIDE_DIR
echo "Deleting $GUIDE_DIR/build"
rm -rf $GUIDE_DIR/build
cd ..
}
if [ "$TOOL" = "clean" ]; then
if [ "$GUIDE_DIR" = "" ]; then
for i in `find -maxdepth 2 -name master.adoc | xargs dirname | sort`; do
getTitle $i
done
else
getTitle $GUIDE_DIR
fi
else
if [ "$GUIDE_DIR" = "" ]; then
for i in `find -maxdepth 2 -name master.adoc | xargs dirname | sort`; do
buildGuide $i
done
printLine
echo ""
for i in `find -maxdepth 2 -name master.adoc | xargs dirname | sort`; do
TITLE=`getTitle $i`
GUIDE_DIR=`readlink -f $i`
echo "$TITLE"
echo " - AsciiDoctor: file://$GUIDE_DIR/target/html/index.html"
echo " - ccutil: file://$GUIDE_DIR/build/tmp/en-US/html-single/index.html"
echo ""
done
printLine
else
buildGuide $GUIDE_DIR
printLine
TITLE=`getTitle $GUIDE_DIR`
echo ""
echo "$TITLE"
echo " - AsciiDoctor: file://$GUIDE_DIR/target/html/index.html"
echo " - ccutil: file://$GUIDE_DIR/build/tmp/en-US/html-single/index.html"
echo ""
printLine
fi
fi