forked from openziti/ziti-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gendoc.sh
executable file
·183 lines (161 loc) · 5.8 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash -eu
shopt -s expand_aliases
function clone_or_pull {
remote=$1
dir="${ZITI_DOC_GIT_LOC}/${2}"
if [[ -n ${3:-} ]]; then
local BRANCH="${3}"
else
local BRANCH="main"
fi
if [ -d "${dir}" ]; then
pushd "${dir}"
git fetch
git checkout "${BRANCH}"
git pull
popd
else
git clone "${remote}" --branch "${BRANCH}" --single-branch "${dir}" --depth 1
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"
SDK_ROOT_TARGET="${script_root}/docusaurus/static/docs/reference/developer/sdk"
BLOG_ROOT_TARGET="${script_root}/docusaurus/blog"
: ${ZITI_DOCUSAURUS:=yes}
echo "- processing opts"
while getopts ":glc" OPT; do
case ${OPT} in
g ) # skip git
echo "- skipping creating and updating Git working copies"
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 that deletes Git working copies"
SKIP_CLEAN="yes"
;;
*)
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"
clone_or_pull "https://github.com/openziti/ziti-tunnel-sdk-c" "ziti-tunnel-sdk-c"
clone_or_pull "https://github.com/openziti/helm-charts" "helm-charts"
clone_or_pull "https://github.com/openziti-test-kitchen/kubeztl" "kubeztl"
fi
if [[ "${SKIP_CLEAN}" == no ]]; then
if test -d "${SDK_ROOT_TARGET}"; then
# specifically using ../ziti-doc just to remove any chance to rm something unintended
echo removing previous build at: rm -r "${SDK_ROOT_TARGET}"
rm -r "${SDK_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="${SDK_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="${SDK_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="${SDK_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
if test -f "${ZITI_DOC_GIT_LOC}/kubeztl/README.md"; then
echo "moving kubernetes blog from checkout to blog location..."
KUBE_BLOG_TARGET="${BLOG_ROOT_TARGET}/zitification/kubernetes"
mkdir -p "${KUBE_BLOG_TARGET}"
cp "${ZITI_DOC_GIT_LOC}"/kubeztl/{README.md,private-kubernetes.svg} "${KUBE_BLOG_TARGET}/"
mv "${KUBE_BLOG_TARGET}"/{README,index}.md
else
echo "ERROR: could not find kubernetes README.md???"
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