-
Notifications
You must be signed in to change notification settings - Fork 13
/
generate-guides.sh
executable file
·47 lines (33 loc) · 1.15 KB
/
generate-guides.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
#!/bin/bash
# Require BASH 3 or newer
REQUIRED_BASH_VERSION=3.0.0
if [[ $BASH_VERSION < $REQUIRED_BASH_VERSION ]]; then
echo "You must use Bash version 3 or newer to run this script"
exit
fi
# Canonicalise the source dir, allow this script to be called anywhere
DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
# DEFINE
TARGET=target/guides
OUTPUT_FORMATS=("html" "xml" "epub" "pdf")
OUTPUT_CMDS=("asciidoc -b html5 -a toc2 -a pygments -o \${output_filename} \$file" "asciidoc -b docbook -o \${output_filename} \$file" "a2x -f epub -D \$dir \$file" "a2x --dblatex-opts \"-P latex.output.revhistory=0\" -D \$dir \$file")
echo "** Building tutorial"
echo "**** Cleaning $TARGET"
rm -rf $TARGET
mkdir -p $TARGET
files=`find * -iname \*.asciidoc`
element_count=${#OUTPUT_FORMATS[@]}
for ((i=0; i < $element_count; i++))
do
output_format=${OUTPUT_FORMATS[i]}
dir=$TARGET/$output_format
mkdir -p $dir
echo "**** Copying shared resources to $dir"
cp -r gfx $dir
for file in $files
do
output_filename=$dir/${file//.asciidoc/.$output_format}
echo "**** Processing $file > ${output_filename}"
eval ${OUTPUT_CMDS[i]}
done
done