forked from SAP-archive/fedem-docs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake-docs.sh
executable file
·121 lines (111 loc) · 3.35 KB
/
make-docs.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
#!/bin/sh
# SPDX-FileCopyrightText: 2023 SAP SE
#
# SPDX-License-Identifier: Apache-2.0
#
# This file is part of FEDEM - https://openfedem.org
print_help () {
echo "make-docs.sh"
echo ""
echo "build the end user documentation for FEDEM."
echo ""
echo "Usage:"
echo "make-docs.sh --option <argument>"
echo ""
echo "-t, --theory Build the theory guideline (requires pdflatex)"
echo "-u, --user Build the user guideline (requires pdflatex)"
echo "-r, --ref Build the reference guide (not implemented yet)"
echo "-i <folder>, --install <folder>"
echo " Install the produced documents on <folder>"
echo "-h, --help Show this help page"
}
BUILD_THEORY=false
BUILD_USER=false
BUILD_REF=false
INSTALL=false
INSTALL_DIR=""
while [[ $# -gt 0 ]]; do
case $1 in
-t|--theory)
BUILD_THEORY=true
shift # past argument
;;
-u|--user)
BUILD_USER=true
shift # past argument
;;
-r|--ref)
BUILD_REF=true
shift # past argument
;;
-i|--install)
INSTALL=true
INSTALL_DIR="$2"
shift # past argument
shift # past value
;;
-h|--help)
print_help
shift # past argument
;;
-*|--*)
echo "Unknown option $1"
exit 2
;;
*)
esac
done
# Print an error if reference guide is asked (to be fixed)
if [ "$BUILD_REF" = true ] ; then
echo "Reference guide building is not implemented on Linux yet!"
echo "Please, execute the command again without the option -r, --ref"
exit 2
fi
# Check that something has to be done
if [ "$BUILD_THEORY" = false ] && [ "$BUILD_USER" = false ] ; then
echo "Nothing to be done..."
echo "Please, type 'make-docs.sh -h' to see the program usage"
exit 0
fi
# Check that pdflatex is available to build theory or user guides
if [ "$BUILD_THEORY" = true ] || [ "$BUILD_USER" = true ] ; then
pdflatex -v > /dev/null
if [ $? -ne 0 ]; then
echo "pdflatex cannot be found"
echo "Please, install pdflatex. If you already have pdflatex installed,"
echo "please set the PATH environment variable to point to it typing"
echo "export PATH=$PATH:$PDFLATEX_PATH, with $PDFLATEX_PATH the path where"
echo "pdflatex can be found"
exit 127
fi
fi
# Time to stop execution if something fails
set -e
# Save the working folder
cwd=$(pwd)
if [ "$BUILD_THEORY" = true ] ; then
cd $cwd/src/TheoryGuide
echo "Generate the Fedem Theory Guide (pdf)"
pdflatex -interaction=nonstopmode theory_main.tex > pdflatex.log
echo "2nd pass"
pdflatex -interaction=nonstopmode theory_main.tex >> pdflatex.log
mv theory_main.pdf FedemTheoryGuide.pdf
if [ "$INSTALL" = true ] ; then
echo "Installing FedemTheoryGuide.pdf in $INSTALL_DIR"
mv FedemTheoryGuide.pdf $INSTALL_DIR/FedemTheoryGuide.pdf
fi
cd $cwd
fi
if [ "$BUILD_USER" = true ] ; then
cd $cwd/src/UsersGuide
echo "Generate the Fedem User Guide (pdf)"
pdflatex -interaction=nonstopmode user_main.tex > pdflatex.log
echo "2nd pass"
pdflatex -interaction=nonstopmode user_main.tex >> pdflatex.log
mv user_main.pdf FedemUsersGuide.pdf
if [ "$INSTALL" = true ] ; then
echo "Installing FedemUsersGuide.pdf in $INSTALL_DIR"
mv FedemUsersGuide.pdf $INSTALL_DIR/FedemUsersGuide.pdf
fi
cd $cwd
fi