diff --git a/.travis.yml b/.travis.yml index af832c89924d..e30ea14bf2fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,6 +56,7 @@ jobs: script: - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then (cd admin && ./init.sh); fi' - bundle exec jekyll build -s spec/ -d build/spec + - ./scripts/generate-spec-pdf.sh after_success: - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then ./scripts/travis-publish-spec.sh; fi' diff --git a/scripts/generate-spec-pdf.sh b/scripts/generate-spec-pdf.sh old mode 100644 new mode 100755 index 38f94ac1b24f..d69a35e0982a --- a/scripts/generate-spec-pdf.sh +++ b/scripts/generate-spec-pdf.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +set -e +set -v + # NOTES: # "toc" -> treated just like another page, its location can be changed # "--window-status loaded" -> when window.status is set to "loaded", wkhtmltopdf knows js is loaded @@ -8,15 +11,27 @@ THIS_SCRIPT_DIR=$(dirname $0) ROOT_DIR=$THIS_SCRIPT_DIR/.. SPEC_SRC_DIR=$ROOT_DIR/spec SPEC_BUILD_DIR=$ROOT_DIR/build/spec +PDF=$SPEC_BUILD_DIR/spec.pdf + +mkdir -p $SPEC_BUILD_DIR -WKHTML_OPTS='--print-media-type --window-status loaded --footer-center [page] --javascript-delay 1000 --footer-font-name "Luxi Sans"' +WKHTML_OPTS='--print-media-type --window-status loaded --footer-center [page] --javascript-delay 1000 --footer-font-name "Luxi Sans" --load-error-handling ignore' WKHTML_TOC="toc --xsl-style-sheet $SPEC_SRC_DIR/spec-toc.xslt" # exclude index.html, prepend SPEC_BUILD_DIR path -HTML_FILES=$(ls $SPEC_BUILD_DIR -I 'index.html' | grep '\.html$' | while read line; do echo "$SPEC_BUILD_DIR/$line"; done) +HTML_FILES=$(ls $SPEC_BUILD_DIR | grep -vx 'index.html' | grep '\.html$' | while read line; do echo "$SPEC_BUILD_DIR/$line"; done) -echo "Making Spec.pdf with HTML files: " +echo "Making spec.pdf with HTML files: " echo $SPEC_BUILD_DIR/index.html $HTML_FILES # first goes index.html, then TOC, then rest -wkhtmltopdf $WKHTML_OPTS $SPEC_BUILD_DIR/index.html $WKHTML_TOC $HTML_FILES $SPEC_BUILD_DIR/Spec.pdf \ No newline at end of file +rm -f $PDF +wkhtmltopdf $WKHTML_OPTS $SPEC_BUILD_DIR/index.html $WKHTML_TOC $HTML_FILES $PDF || true + +# the '|| true' thing is because we get: +# Error: Failed to load http:/, with network status code 3 and http status code 0 - Host not found +# Warning: Failed loading page http: (ignored) +# as long we have `--load-error-handling ignore` we still get a PDF, but we also get a nonzero exit code + +# fail if we didn't get a PDF file out +if [ ! -f $PDF ] ; then exit 1 ; fi