aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-03-20 15:34:01 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-03-20 15:34:01 +0100
commitdb3dea9a59746b26b966b022d046ec8e44c37539 (patch)
tree5c6145d539579d3fab7770a2518c72eba81e70ea
parente2d3b306a08bb536209f9a101315ad036186fe4c (diff)
Use bash script to generate doc instead of cmake
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--CMakeLists.txt26
-rw-r--r--README.md10
-rwxr-xr-xgendocs.sh71
3 files changed, 78 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05fbd5fc..233ee695 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,29 +20,3 @@
cmake_minimum_required(VERSION 3.3)
project(low-can-binding)
add_subdirectory(src)
-
-add_custom_command(
- OUTPUT ${PROJECT_NAME}.pdf
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND gitbook install
- COMMAND gitbook pdf docs ${PROJECT_NAME}.pdf
-)
-add_custom_target(pdf
- DEPENDS ${PROJECT_NAME}.pdf)
-
-add_custom_command(
- OUTPUT _book
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND gitbook install
- COMMAND gitbook serve
-)
-add_custom_target(serve
- DEPENDS _book)
-
-add_custom_command(
- OUTPUT docs_doxygen
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- COMMAND doxygen CAN_signaling.doxygen
-)
-add_custom_target(doxygen
- DEPENDS docs_doxygen) \ No newline at end of file
diff --git a/README.md b/README.md
index bcf99819..55fc453e 100644
--- a/README.md
+++ b/README.md
@@ -33,17 +33,21 @@ cmake ..
Generate a PDF version :
```bash
-make pdf
+gendocs.sh pdf
```
Serve an HTML version, this will run a web server that will serve you locally documentation :
```bash
-make serve
+gendocs.sh serve
```
Generate doxygen documentation:
```bash
-make doxygen
+gendocs.sh doxygen
+```
+or
+```bash
+cd build && make doxygen
``` \ No newline at end of file
diff --git a/gendocs.sh b/gendocs.sh
new file mode 100755
index 00000000..9d9b74a3
--- /dev/null
+++ b/gendocs.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+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
+ $DRY $GITBOOK pdf $ROOTDIR $OUT_DIR/LowLevelCanBinder_Guide.pdf $DEBUG_FLAG
+ 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