summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-20 11:12:09 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-09-20 11:41:32 +0200
commit1dcedd671f892f07d7805c88352661007b88800d (patch)
tree416cc67fc276c1a6277a8171aba46a7553017182
parentb25e8b11aacd927adfb0278756fb800f879904c5 (diff)
Docs - autogenerate cover
Change-Id: Ia0a8a6b19ce7b173189d73cdc5c0bbba77b2b71f Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
-rw-r--r--docs/cover.jpgbin216292 -> 280059 bytes
-rw-r--r--docs/cover_small.jpgbin10750 -> 19414 bytes
-rwxr-xr-xdocs/resources/make_cover.sh27
-rwxr-xr-xgendocs.sh12
4 files changed, 31 insertions, 8 deletions
diff --git a/docs/cover.jpg b/docs/cover.jpg
index fd2e03d..4732f0b 100644
--- a/docs/cover.jpg
+++ b/docs/cover.jpg
Binary files differ
diff --git a/docs/cover_small.jpg b/docs/cover_small.jpg
index 0be3fdb..cf2d3a3 100644
--- a/docs/cover_small.jpg
+++ b/docs/cover_small.jpg
Binary files differ
diff --git a/docs/resources/make_cover.sh b/docs/resources/make_cover.sh
index fbbbc02..1026ecb 100755
--- a/docs/resources/make_cover.sh
+++ b/docs/resources/make_cover.sh
@@ -1,14 +1,27 @@
#!/bin/bash
+DOCS_DIR=$(cd $(dirname $0)/.. && pwd)
+BOOKFILE=$DOCS_DIR/../book.json
-cat cover.svg | sed -e 's/{title}/Low Level CAN binding/' \
- -e 's/font-size:87.5px/font-size:50px/g' \
- -e 's/{subtitle}//g' \
- -e 's/{version}/Version 4.99-EERC1/g' \
- -e 's/{date}/September 2017/g' \
+TITLE=$(grep '"title":' $BOOKFILE | cut -d'"' -f 4)
+SUBTITLE=$(grep '"subtitle":' $BOOKFILE | cut -d'"' -f 4)
+VERSION="Version $(grep '"version":' $BOOKFILE | cut -d'"' -f 4)"
+DATE=$(grep '"published":' $BOOKFILE | cut -d'"' -f 4)
+
+[ -z "$TITLE" ] && { echo "Error TITLE not set!" ; exit 1; }
+[ -z "$VERSION" ] && { echo "Error VERSION not set!" ; exit 1; }
+[ -z "$DATE" ] && { echo "Error DATE not set!" ; exit 1; }
+
+
+cat $(dirname $0)/cover.svg | sed -e "s/{title}/$TITLE/g" \
+ -e "s/font-size:87.5px/font-size:54px/g" \
+ -e "s/{subtitle}/$SUBTITLE/g" \
+ -e "s/font-size:62.5px/font-size:40px/g" \
+ -e "s/{version}/$VERSION/g" \
+ -e "s/{date}/$DATE/g" \
> /tmp/cover.svg
# use imagemagick convert tool (cover size must be 1800x2360)
convert -resize "1600x2160!" -border 100 -bordercolor white -background white \
- -flatten -quality 100 /tmp/cover.svg ../cover.jpg
+ -flatten -quality 100 /tmp/cover.svg $DOCS_DIR/cover.jpg
-convert -resize "200x262!" ../cover.jpg ../cover_small.jpg
+convert -resize "200x262!" $DOCS_DIR/cover.jpg $DOCS_DIR/cover_small.jpg
diff --git a/gendocs.sh b/gendocs.sh
index a0f6e5c..897e762 100755
--- a/gendocs.sh
+++ b/gendocs.sh
@@ -1,7 +1,13 @@
#!/bin/bash
+OUTFILENAME="LowLevelCanBinding_Guide"
+
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]
@@ -57,7 +63,11 @@ if [ "$DO_ACTION" = "pdf" -o "$DO_ACTION" = "serve" ]; then
[ "$?" = "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/LowLevelCanBinding_Guide.pdf
+
+ # 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