-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_docs
More file actions
executable file
·61 lines (53 loc) · 1.63 KB
/
Copy pathbuild_docs
File metadata and controls
executable file
·61 lines (53 loc) · 1.63 KB
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
58
59
60
61
#!/usr/bin/env bash
set -e
# $scriptname will already be set if build_docs is getting called from build_docs_to_publish.
# Otherwise, we need to set it to the basename of this script.
if [[ -z "${scriptname}" ]]; then
scriptname="${0##*/}"
fi
if [ ! -e doc-builder ]; then
# We're in the doc-builder directory itself
script="./tools/${scriptname}.py"
files_to_copy_to_source="conf.py substitutions.py _templates _static"
cp -a ${files_to_copy_to_source} source/
else
# We're in a repo that *includes* doc-builder
script="./doc-builder/tools/${scriptname}.py"
# Make sure the doc-builder submodule is checked out. If doc-builder isn't a submodule but is
# instead manually included, we will perform the `else`, which is safe because it's a no-op in
# that situation.
# (Assume that if the repo uses git-fleximod, doc-builder is handled with it.)
git_fleximod_path="$(git rev-parse --show-toplevel)/bin/git-fleximod"
if [[ -e "${git_fleximod_path}" ]]; then
"${git_fleximod_path}" update doc-builder
else
git submodule update --init -- doc-builder
fi
fi
# Check if --verbose or -V was passed
verbose=false
for arg in "$@"; do
case "$arg" in
--verbose|-V) verbose=true; break ;;
esac
done
if $verbose; then
echo "Running: make fetch-images"
make fetch-images
else
make fetch-images > /dev/null 2>&1
fi
if $verbose; then
echo "Running: ${script} $@"
fi
set +e
${script} "$@"
exit_code=$?
set -e
if [ ! -e doc-builder ]; then
# Clean up these things we copied
for f in ${files_to_copy_to_source}; do
rm -r "source/$f"
done
fi
exit $exit_code