forked from openziti/ziti-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gendoc.sh
executable file
·169 lines (148 loc) · 5.07 KB
/
gendoc.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash -eu
shopt -s expand_aliases
function clone_or_pull {
remote=$1
dir="${ZITI_DOC_GIT_LOC}/${2}"
if [ -d "${dir}" ]; then
pushd "${dir}"
git pull
popd
else
git clone "${remote}" --branch main --single-branch "${dir}"
fi
}
set -e
script_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "$script_root"
: ${SKIP_GIT:=no}
: ${SKIP_LINKED_DOC:=no}
: ${SKIP_CLEAN:=no}
ZITI_DOC_GIT_LOC="${script_root}/docusaurus/_remotes"
DOC_ROOT_TARGET="${script_root}/docusaurus/static/docs/reference/api"
: ${ZITI_DOCUSAURUS:=yes}
echo "- processing opts"
while getopts ":glcwd" OPT; do
case ${OPT} in
g ) # skip git
echo "- skipping git cleanup"
SKIP_GIT="yes"
;;
l ) # skip linked doc gen
echo "- skipping linked doc generation"
SKIP_LINKED_DOC="yes"
;;
c ) # skip clean steps
echo "- skipping clean step"
SKIP_CLEAN="yes"
;;
w ) # process option t
echo "- treating warnings as errors"
WARNINGS_AS_ERRORS="--warningsAsErrors"
;;
d)
echo "WARN: ignoring option ${OPT}" >&2
;;
*)
echo "WARN: ignoring option ${OPT}" >&2
;;
esac
done
echo "- done processing opts"
if [[ "${SKIP_GIT}" == no ]]; then
echo "updating dependencies by rm/checkout"
mkdir -p "${ZITI_DOC_GIT_LOC}"
if [[ "${SKIP_CLEAN}" == no ]]; then
rm -rf ${ZITI_DOC_GIT_LOC}/ziti-*
fi
git config --global --add safe.directory $(pwd)
clone_or_pull "https://github.com/openziti/ziti" "ziti-cmd"
clone_or_pull "https://github.com/openziti/ziti-sdk-csharp" "ziti-sdk-csharp"
clone_or_pull "https://github.com/openziti/ziti-sdk-c" "ziti-sdk-c"
clone_or_pull "https://github.com/openziti/ziti-android-app" "ziti-android-app"
clone_or_pull "https://github.com/openziti/ziti-sdk-swift" "ziti-sdk-swift"
fi
if [[ "${SKIP_CLEAN}" == no ]]; then
if test -d "${DOC_ROOT_TARGET}"; then
# specifically using ../ziti-doc just to remove any chance to rm something unintended
echo removing previous build at: rm -r "${DOC_ROOT_TARGET}"
rm -r "${DOC_ROOT_TARGET}" || true
fi
fi
if [[ "${SKIP_LINKED_DOC}" == no ]]; then
commands_to_test=(doxygen wget)
# verify all the commands required in the automation exist before trying to run the full suite
for cmd in "${commands_to_test[@]}"; do
# checking all commands are on the path before continuing...
result="$(type ${cmd} &>/dev/null && echo "Found" || echo "Not Found")"
if [[ "Not Found" == "${result}" ]]; then
missing_requirements+=" * ${cmd}\n"
fi
done
# are requirements ? if yes, stop here and help 'em out
if [[ -n "${missing_requirements:-}" ]]; then
echo " "
echo "The commands listed below are required to be on the path for this script to function properly."
echo "Please ensure the commands listed are on the path and then try again."
printf "\n${missing_requirements}"
echo " "
echo "If any of these commands are declared as aliases ensure your alias is"
echo "declared inside of ~/.bash_aliases - or modify this script to add the aliases you require"
exit 1
fi
if [[ "${ZITI_DOCUSAURUS}" == yes ]]; then
echo "=================================================="
#echo "csharp: building the c# sdk docs"
#
CSHARP_SOURCE="${ZITI_DOC_GIT_LOC}/ziti-sdk-csharp/docs"
CSHARP_TARGET="${DOC_ROOT_TARGET}/csharp"
echo "Copying csharp SDK docs"
echo " from: ${CSHARP_SOURCE}"
echo " to: ${CSHARP_TARGET}"
echo " "
mkdir -p "${CSHARP_TARGET}"
cp -r "${CSHARP_SOURCE}/"* "${CSHARP_TARGET}"
fi
if test -f "${ZITI_DOC_GIT_LOC}/ziti-sdk-c/Doxyfile"; then
pushd "${ZITI_DOC_GIT_LOC}/ziti-sdk-c"
doxygen
CLANG_SOURCE="${ZITI_DOC_GIT_LOC}/ziti-sdk-c/api"
CLANG_TARGET="${DOC_ROOT_TARGET}/clang"
echo " "
echo "Copying C SDK doc"
echo " from: ${CLANG_SOURCE}"
echo " to: ${CLANG_TARGET}"
echo " "
mkdir -p "${CLANG_TARGET}"
cp -r "${CLANG_SOURCE}/"* "${CLANG_TARGET}"
echo " "
echo "Removing"
echo " ${ZITI_DOC_GIT_LOC}/ziti-sdk-c/api"
rm -rf "${ZITI_DOC_GIT_LOC}/ziti-sdk-c/api"
popd
else
echo "ERROR: CSDK Doxyfile not located"
fi
if test -f "${ZITI_DOC_GIT_LOC}/ziti-sdk-swift/CZiti.xcodeproj/project.pbxproj"; then
SWIFT_API_TARGET="${DOC_ROOT_TARGET}/swift"
mkdir -p "${SWIFT_API_TARGET}"
pushd "${SWIFT_API_TARGET}"
swift_tgz="https://github.com/openziti/ziti-sdk-swift/releases/latest/download/ziti-sdk-swift-docs.tgz"
echo " "
echo "Copying Swift docs"
echo " from: ${swift_tgz}"
echo " to: ${SWIFT_API_TARGET}"
echo " "
echo " via: wget -q -O - ${swift_tgz} | tar -zxv"
pwd
#wget -q -O - "${swift_tgz}" | tar -zxvC "${SWIFT_API_TARGET}"
wget -q -O - "${swift_tgz}" | tar -zxv
find "${SWIFT_API_TARGET}" -name "EnrollmentResponse*"
popd
fi
fi
pushd ${ZITI_DOC_GIT_LOC}/..
echo "running 'yarn install' in ${PWD}"
yarn install --frozen-lockfile
echo "running 'yarn build' in ${PWD}"
yarn build
popd