bidict/build-docs.sh

43 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
2018-08-13 17:57:07 +00:00
#
# Copyright 2018 Joshua Bronson. All Rights Reserved.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
LAST_EXIT="0"
# Generate a new types diagram image from the source file if it's been modified
2018-03-27 07:35:52 +00:00
GRAPH_SRC="bidict-types-diagram.dot"
MODIFIED_GRAPH_SRC="$(git ls-files -m | grep ${GRAPH_SRC})"
if [[ -n "${MODIFIED_GRAPH_SRC}" ]]; then
2018-03-27 07:35:52 +00:00
MODIFIED_GRAPH_DST="${MODIFIED_GRAPH_SRC%.*}.png"
if which dot &>/dev/null ; then
2018-03-28 02:20:12 +00:00
dot -v -Tpng -o "${MODIFIED_GRAPH_DST}" < "${MODIFIED_GRAPH_SRC}"
LAST_EXIT="$?"
if [[ "${LAST_EXIT}" -ne 0 ]]; then
echo -e "\033[0;31m* dot exited nonzero (${LAST_EXIT})\033[0m\0007"
else
if which optipng &>/dev/null ; then
2018-03-28 02:20:12 +00:00
optipng "${MODIFIED_GRAPH_DST}"
LAST_EXIT="$?"
if [[ "LAST_EXIT" -ne 0 ]]; then
echo -e "\033[0;31m* optipng exited nonzero (${LAST_EXIT})\033[0m\0007"
fi
else
echo -e "\033[0;31m* optipng not found, skipping. Hint: brew install optipng\033[0m\0007"
fi
fi
else
2018-03-27 07:35:52 +00:00
echo -e "\033[0;31m* dot not found, skipping. Hint: brew install graphviz\033[0m\0007"
fi
fi
# Build the docs.
cd docs
make clean html