Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (82 sloc) 3.08 KB
#!/bin/bash
# git bash setting to prevent conversion to Windows directory names
export MSYS_NO_PATHCONV=1
# Environment variables used on this script
dockeropts="-it --rm -v"
dockerdir=$(pwd)
dockertag='cloudcompass/docker-rtdsphinx'
dockercmd="docker run ${dockeropts} ${dockerdir}:/documents/ ${dockertag}"
buildDir="docs/build/html"
openBrowser='open'
if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then
openBrowser='explorer'
fi
# =================================================================================================================
# Usage:
# -----------------------------------------------------------------------------------------------------------------
usage () {
cat <<-EOF
Usage: $0 [-f] command [options]
The command must be run from the directory above the project "docs" directory (e.g. the root of the repo). Use the "-f" parameter to bypass this requirement.
Commands:
help - Print this usage information
html - Generate sphinx HTML documents (does a clean before)
view - Open a browser at the root of the generated HTML documentation
clean - Clean out the HTML documents
sphinx-quickstart <args> - run the sphinx-quickstart utility. No args are needed, but can be added.
Reference: http://www.sphinx-doc.org/en/master/man/sphinx-quickstart.html
sphinx-apidoc <args> source-code-path - run the sphinx-apigen utility in the current directory with the arg "-o source"
Needs at least the path to the source code added, and other args can be added before the path
Reference: http://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html
cli - Starts a bash shell on the docker image for ad hoc commands
EOF
exit 1
}
# -----------------------------------------------------------------------------------------------------------------
# Functions:
# -----------------------------------------------------------------------------------------------------------------
# =================================================================================================================
# You must be in the "docs" directory to run this command
if [ "$1" != "-f" ]; then
if [ ! -d "docs" ]; then
echo $0 ERROR - must be run from the directory above the "docs" directory.
echo Add the first parameter \"-f\" to your command to bypass this requirement.
exit 1
fi
else
shift
fi
# Print usage if no command given
if [ "$1" == "" ]; then
usage
exit 0
fi
case "$1" in
html)
${dockercmd} /bin/bash -c "make clean;make html"
;;
view)
if [ -d ${buildDir} ]; then
/bin/bash -c "cd ${buildDir};${openBrowser} index.html;cd ../../.."
else
echo Directory ${buildDir} does not exist. Are you in the right directory?
fi
;;
clean)
${dockercmd} /bin/bash -c "make clean"
;;
sphinx-quickstart)
shift
${dockercmd} /bin/bash -c "sphinx-quickstart #@"
;;
sphinx-apidoc)
shift
echo ${dockercmd} /bin/bash -c "cd ..;sphinx-apidoc -o docs/source/ $@"
${dockercmd} /bin/bash -c "cd ..;sphinx-apidoc -o docs/source/ $@"
;;
cli)
${dockercmd}
;;
*)
usage;;
esac
You can’t perform that action at this time.