summaryrefslogtreecommitdiffstats
path: root/gendocs.sh
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-19 16:43:41 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commite11314b2e9fef34f569bb7b042b432aed661cdc0 (patch)
treeaaaae4d5820238e53a555f290a0a1ea8faa28b9e /gendocs.sh
parentf4fba8a2744991ff8c5cb8af4a67c7d9456f1057 (diff)
Added documentation
Change-Id: Iaa6bb0470652d3d0dc97c6320dbf210567ccec80 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'gendocs.sh')
-rwxr-xr-xgendocs.sh83
1 files changed, 83 insertions, 0 deletions
diff --git a/gendocs.sh b/gendocs.sh
new file mode 100755
index 0000000..24764aa
--- /dev/null
+++ b/gendocs.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+OUTFILENAME="Signal Composer"
+
+SCRIPT=$(basename $BASH_SOURCE)
+
+VERSION=$(grep '"version":' $(dirname $BASH_SOURCE)/book.json | cut -d'"' -f 4)
+[ "$VERSION" != "" ] && OUTFILENAME="${OUTFILENAME}_${VERSION}"
+
+
+function usage() {
+ cat <<EOF >&2
+Usage: $SCRIPT [options] [pdf|serve|doxygen]
+
+Options:
+ --debug
+ enable debug when generating pdf or html documentation
+ -d|--dry
+ dry run
+ -h|--help
+ get this help
+
+Example:
+ $SCRIPT pdf
+
+EOF
+ exit 1
+}
+
+function info() {
+ echo "$@" >&2
+}
+
+#default values
+DEBUG_FLAG=""
+DRY=""
+DO_ACTION=""
+OUT_DIR=./build
+
+[[ $? != 0 ]] && usage
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --debug) DEBUG_FLAG="--log=debug --debug";;
+ -d|--dry) DRY=echo;;
+ -h|--help) usage;;
+ pdf | serve | doxygen) DO_ACTION=$1;;
+ --) break;;
+ esac
+ shift
+done
+
+cd $(dirname $0)
+ROOTDIR=`pwd -P`
+
+# Create out dir if needed
+[ -d $OUT_DIR ] || mkdir -p $OUT_DIR
+
+if [ "$DO_ACTION" = "pdf" -o "$DO_ACTION" = "serve" ]; then
+ GITBOOK=`which gitbook`
+ [ "$?" = "1" ] && { echo "You must install gitbook first, using: sudo npm install -g gitbook-cli"; exit 1; }
+
+ EBCONV=`which ebook-convert`
+ [ "$?" = "1" ] && { echo "You must install calibre first, using: 'sudo apt install calibre' or refer to https://calibre-ebook.com/download"; exit 1; }
+
+ if [ "$DO_ACTION" = "pdf" ]; then
+
+ # Update cover when book.json has been changed
+ [[ $ROOTDIR/book.json -nt $ROOTDIR/docs/cover.jpg ]] && { echo "Update cover files"; $ROOTDIR/docs/resources/make_cover.sh || exit 1; }
+
+ OUTFILE=$OUT_DIR/$OUTFILENAME.pdf
+ $DRY $GITBOOK pdf $ROOTDIR $OUTFILE $DEBUG_FLAG
+ [ "$?" = "0" ] && echo "PDF has been successfully generated in $OUTFILE"
+ else
+ $DRY $GITBOOK serve $DEBUG_FLAG
+ fi
+
+elif [ "$DO_ACTION" = "doxygen" ]; then
+ $DRY cd $OUT_DIR && cmake .. && make doxygen $ROOTDIR/Doxyfile
+
+else
+ echo "Unknown action !"
+ usage
+fi