forked from apple/coremltools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_docs.sh
executable file
·118 lines (103 loc) · 3.44 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
##=============================================================================
## Main configuration processing
COREMLTOOLS_HOME=$( cd "$( dirname "$0" )/.." && pwd )
# command flag options
PYTHON="3.7"
SOURCE_VERSION=""
RELEASE=0
UPLOAD=0
MAIN_VERSION=0
AUTH_TOKEN=""
CHECK_ENV=1
WHEEL_PATH=""
VERSION=""
unknown_option() {
echo "Unknown option $1. Exiting."
exit 1
}
print_help() {
echo "Builds the docs associated with the code"
echo
echo "Usage: zsh -i make_docs.sh"
echo
echo " --wheel-path=* Specify which wheel to use to make docs."
echo " --python=* Python to use for configuration."
echo " --version=* ReadMe version to upload to. Default is the installed coremltools version."
echo " --upload Upload these docs with the current coremltools version."
echo " --release Release the uploaded docs with the current coremltools version."
echo " --from-source-version=* If a version must be created, use this as the base to copy from.\
Default is the most recent version."
echo " --auth-token=* Auth token for accessing documentation API."
echo " --set-main-version Set the uploaded doc version as the main ('stable release') version."
echo " --no-check-env Don't check the environment to verify it's up to date."
echo
exit 1
} # end of print help
# command flag options
# Parse command line configure flags ------------------------------------------
while [ $# -gt 0 ]
do case $1 in
--python=*) PYTHON=${1##--python=} ;;
--version=*) VERSION=${1##--version=} ;;
--wheel-path=*) WHEEL_PATH=${1##--wheel-path=} ;;
--from-source-version=*) SOURCE_VERSION=${1##--from-source-version=} ;;
--auth-token=*) AUTH_TOKEN=${1##--auth-token=} ;;
--upload) UPLOAD=1 ;;
--release) RELEASE_VERSION=1 ;;
--no-check-env) CHECK_ENV=0 ;;
--set-main-version) MAIN_VERSION=1 ;;
--help) print_help ;;
*) unknown_option $1 ;;
esac
shift
done
cd ${COREMLTOOLS_HOME}
if [[ $PYTHON != "None" ]]; then
# Setup the right python
if [[ $CHECK_ENV == 1 ]]; then
zsh -i scripts/env_create.sh --python=$PYTHON --include-docs-deps --exclude-test-deps
fi
source scripts/env_activate.sh --python=$PYTHON
fi
echo
echo "Using python from $(which python)"
echo
if [[ $WHEEL_PATH != "" ]]; then
$PIP_EXECUTABLE install ${WHEEL_PATH} --upgrade
else
cd ..
$PIP_EXECUTABLE install -e coremltools --upgrade
cd ${COREMLTOOLS_HOME}
fi
cd docs
make html
cd ..
if [[ $UPLOAD == 1 ]]; then
if [[ $AUTH_TOKEN == "" ]]; then
echo "No auth token provided. Skipping upload."
pip uninstall coremltools
exit
fi
# Set up base API call
DOC_COMMAND=(python docs/upload_docs.py --auth_token $AUTH_TOKEN)
if [[ $VERSION != "" ]]; then
DOC_COMMAND+=(--version $VERSION)
fi
if [[ $SOURCE_VERSION != "" ]]; then
DOC_COMMAND+=(--from_source_version $SOURCE_VERSION)
fi
if [[ $RELEASE == 1 ]]; then
DOC_COMMAND+=(--release_version)
fi
if [[ $MAIN_VERSION == 1 ]]; then
DOC_COMMAND+=(--set_version_stable)
fi
${DOC_COMMAND[@]}
else
if [[ $MAIN_VERSION == 1 ]]; then
echo "You must set release-version to use set-main-version."
fi
fi
pip uninstall -y coremltools # We're using the build env for this script, so uninstall the wheel when we're done.