Last active
January 4, 2016 21:51
-
-
Save rdegges/4c18067d90c793043cff to your computer and use it in GitHub Desktop.
Sphinx build step for Stormpath projects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script will build all Sphinx project documentation if, and only if, | |
# an environment variable named `BUILD_DOCS` is present. | |
PWD=`pwd` | |
# First off, we'll find a list of *all* directories which contain a `conf.py` | |
# file. This is the configuration file that Sphinx ships with, so by looking | |
# for this file we can find (for certain) any Sphinx documentation directories | |
# that are inside of this project, even if they're nested in some deep hierarchy. | |
# | |
# NOTE: For OSX you need to modify the sed command to use the -E flag instead of | |
# the --regexp-extended flag, due to shitty OSX developers not implementing standard | |
# GNU utils properly. | |
for dir in `find . -type f -name 'conf.py' | sed -E 's|/[^/]+$||' | sort | uniq`; do | |
# If the directory path ends with /source, then it means the Sphinx docs are | |
# setup using the separation of source / build files, so we need to go back a | |
# directory before building. | |
if [[ $dir == *source ]]; then | |
dir=`dirname $dir` | |
fi | |
# Build the Sphinx documentation then return to the original working directory. | |
test -z "$BUILD_DOCS" || cd $dir | |
test -z "$BUILD_DOCS" || make html | |
test -z "$BUILD_DOCS" || cd $PWD | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment