2019-11-05 17:46:13 +01:00

66 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# @see https://intoli.com/blog/exit-on-errors-in-bash-scripts/
set -e
trap 'LASTRES=$?; LAST=$BASH_COMMAND; if [[ LASTRES -ne 0 ]]; then fail "Command: \"$LAST\" exited with exit code: $LASTRES"; elif [ "$FAIL" -eq "1" ]; then fail finished with error; else pass "finished";fi' EXIT
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DIR_NAME="${CURRENT_DIR##*/}"
FAIL=0
SOURCE_DIR=$CURRENT_DIR"/.."
BUILD_DIR=$SOURCE_DIR"/../../build"
main() {
doc "$@"
}
function doc() {
info "Generation documentation"
mkdir -p $BUILD_DIR
cd $BUILD_DIR/..
cd ..
if [ ! -d "m.css" ] ; then
info "Cloning m.css"; git clone git://github.com/mosra/m.css;
fi
cd m.css/documentation
info "Installing jinja2 and Pygments"
pip3 install jinja2 Pygments
info "Generating doxygen"
if [ "$1" == "clean" ]; then rm -fr $BUILD_DIR/doc/$DIR_NAME; fi
./doxygen.py --debug $SOURCE_DIR/doc/Doxyfile-mcss
if [ "$1" == "open" ]; then
open $BUILD_DIR/doc/core-sdk/html/index.html
fi
}
# ################
# Output funcitons
# ################
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function info () {
echo -e "[${BLUE} $@ ${NC}]"
}
function pass() {
echo -e "[${GREEN}PASS${NC}] $@"
}
function fail() {
FAIL=1; echo -e "[${RED}FAIL${NC}] $@"
}
# Run main function
main "$@"