#!/bin/bash #set -e # Branch from which github create the projects page DOC_BRANCH="gh-pages" # Should the projects README.md converted into the index.html file? ## If you which so, make sure the system has a working `pandoc` installation! CREATE_UPDATE_README=true # Should the orginal libmodbus documentation build? BUILD_LIBMODBUS_DOC=true [[ "$(git symbolic-ref --short HEAD)" == "master" ]] || exit 0 msg() { echo "> $@" } dir="$(pwd)" last_rev="$(git rev-parse HEAD)" last_msg="$(git log -1 --pretty=%B)" unset GIT_WORK_TREE msg "Cloning into a temporary directory..." # The second call is to support OSX. tmp="$(mktemp -d 2>/dev/null || mktemp -d -t 'tmp-rust-docs')" trap "cd \"$dir\"; rm -rf \"$tmp\"" EXIT git clone --quiet --branch master "$dir" "$tmp" cd "$tmp" ln -s "$dir/target" "$tmp/target" msg "Generating documentation..." cargo doc # If $BUILD_LIBMODBUS_DOC is set, build origin libmodbus documentation if "$BUILD_LIBMODBUS_DOC"; then msg "Create libmodbus documentation from libmodbus C library" pushd libmodbus-sys/libmodbus/doc make --quiet htmldoc 2>/dev/null popd fi # Switch to pages msg "Replacing documentation..." # Only if $DOC_BRANCH not exists if ! git checkout --quiet "$DOC_BRANCH" 2>/dev/null; then git checkout --quiet --orphan "$DOC_BRANCH" git rm --quiet --ignore-unmatch -rf . cat > .gitignore <