aboutsummaryrefslogtreecommitdiffstats
path: root/gendocs.sh
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-06-19 11:40:32 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-06-19 16:19:39 +0200
commitc826c6662dc83633aac0ce1622e4a91b4c8100e3 (patch)
treeca440d402ada8e3ae7acad1fe3d876ad3a0259ff /gendocs.sh
parentf6bc48698587758fb764bae66302002fe148e978 (diff)
Add gitbook documentation (support PDF generation).
To generate PDF doc: ./gendocs.sh pdf To generate HTML doc (local webserver): ./gendocs.sh serve Change-Id: I77156a45e86f3bcab045cee05694f93b7a50e4ba Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'gendocs.sh')
-rwxr-xr-xgendocs.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/gendocs.sh b/gendocs.sh
new file mode 100755
index 00000000..5aec2a76
--- /dev/null
+++ b/gendocs.sh
@@ -0,0 +1,75 @@
+#!/bin/bash
+
+OUTFILENAME="Application-Framework-Binder"
+
+SCRIPT=$(basename $BASH_SOURCE)
+
+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
+ 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