forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-docs.sh
executable file
·57 lines (44 loc) · 1.71 KB
/
build-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -euo pipefail
PYTHON_DEPS="$PWD/python-deps"
#----------------------------------------------------------------------
# Install python depednencies to a local tree
if [ ! -d ${PYTHON_DEPS} ]; then
mkdir -p "${PYTHON_DEPS}"
pip install --ignore-installed --install-option="--prefix=${PYTHON_DEPS}" -r requirements.txt
fi
export PYTHONPATH=${PYTHON_DEPS}/lib/python3.6/site-packages:${PYTHON_DEPS}/lib/python3.7/site-packages
export PATH=${PYTHON_DEPS}/bin:$PATH
#----------------------------------------------------------------------
# CONFIG
staging=".staging"
output="dist"
refsrc="../dist/sphinx"
refdocs="refs"
refdocsdir="${staging}/${refdocs}"
refs_index="${staging}/reference.rst"
#----------------------------------------------------------------------
# PREREQ CHECK
if ! which sphinx-build > /dev/null; then
echo "'sphinx-build' not found. Please 'pip install sphinx'.">&2
exit 1
fi
#----------------------------------------------------------------------
# DO THE WORK
echo "Staging Sphinx doc site under ${staging}"
mkdir -p ${staging}
rsync -av src/ ${staging}
echo "Copying generated reference documentation..."
if [ ! -d "${refsrc}" ]; then
echo "Cannot find ${refsrc} in the root directory of this repo"
echo "Did you run ./pack.sh?"
exit 1
fi
rm -fr ${refdocsdir}/
rsync -av ${refsrc}/ ${refdocsdir}/
echo "Generating reference docs toctree under ${refs_index}..."
cat ${refs_index}.template > ${refs_index}
ls -1 ${refdocsdir} | grep '.rst$' | sed -e 's/\.rst//' | sort | xargs -I{} echo " ${refdocs}/{}" >> ${refs_index}
export CDK_VERSION=$(../tools/pkgtools/bin/cdk-version)
echo "Set CDK_VERSION=${CDK_VERSION} (consumed by conf.py)..."
sphinx-build -b html $staging $output