-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate-docs.sh
More file actions
executable file
·196 lines (167 loc) · 4.08 KB
/
Copy pathgenerate-docs.sh
File metadata and controls
executable file
·196 lines (167 loc) · 4.08 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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE_PATH="${ROOT_DIR}/SampleApps/Ping.xcworkspace"
DOCS_DIR="${ROOT_DIR}/docs"
AUTHOR="Ping Identity"
AUTHOR_URL="https://www.pingidentity.com/"
GITHUB_URL="https://github.com/ForgeRock/ping-ios-sdk"
THEME="fullwidth"
MODULES=(
Logger
Storage
Network
Commons
Browser
Orchestrate
DavinciPlugin
JourneyPlugin
Oidc
Davinci
TamperDetector
DeviceId
DeviceProfile
Journey
DeviceClient
ExternalIdP
ExternalIdPApple
ExternalIdPGoogle
ExternalIdPFacebook
Protect
ReCaptchaEnterprise
Fido
Oath
Push
Binding
)
get_scheme_override() {
local module="$1"
case "$module" in
Network) echo "PingNetwork" ;;
DeviceId) echo "PingDeviceId" ;;
ExternalIdPFacebook) echo "PingExternalIdPFacebook" ;;
Protect) echo "PingProtect" ;;
*) echo "" ;;
esac
}
get_project_schemes() {
local project_path="$1"
xcodebuild -list -project "${project_path}" 2>/dev/null | awk '
/^ *Schemes:$/ { in_schemes=1; next }
in_schemes {
if ($0 ~ /^$/) exit
if ($0 ~ /^[[:space:]]+/) {
gsub(/^[[:space:]]+/, "", $0)
print
}
}
'
}
get_best_scheme() {
local project_path="$1"
local module="$2"
local ping_module="Ping${module}"
local schemes
local scheme
schemes="$(get_project_schemes "${project_path}")"
# 1. Exact Ping<Module>
while IFS= read -r scheme; do
[[ -z "${scheme}" ]] && continue
if [[ "${scheme}" == "${ping_module}" ]]; then
echo "${scheme}"
return 0
fi
done <<EOF
${schemes}
EOF
# 2. Exact <Module>
while IFS= read -r scheme; do
[[ -z "${scheme}" ]] && continue
if [[ "${scheme}" == "${module}" ]]; then
echo "${scheme}"
return 0
fi
done <<EOF
${schemes}
EOF
# 3. Any non-test Ping* scheme
while IFS= read -r scheme; do
[[ -z "${scheme}" ]] && continue
case "${scheme}" in
*Tests|*UITests) continue ;;
esac
if [[ "${scheme}" == Ping* ]]; then
echo "${scheme}"
return 0
fi
done <<EOF
${schemes}
EOF
# 4. Any non-test scheme
while IFS= read -r scheme; do
[[ -z "${scheme}" ]] && continue
case "${scheme}" in
*Tests|*UITests) continue ;;
esac
echo "${scheme}"
return 0
done <<EOF
${schemes}
EOF
return 1
}
workspace_has_scheme() {
local workspace_path="$1"
local target_scheme="$2"
xcodebuild -list -workspace "${workspace_path}" 2>/dev/null | awk '
/^ *Schemes:$/ { in_schemes=1; next }
in_schemes {
if ($0 ~ /^$/) exit
if ($0 ~ /^[[:space:]]+/) {
gsub(/^[[:space:]]+/, "", $0)
print
}
}
' | grep -Fxq "${target_scheme}"
}
echo "Cleaning consolidated docs directory..."
rm -rf "${DOCS_DIR}"
mkdir -p "${DOCS_DIR}"
if [[ ! -d "${WORKSPACE_PATH}" ]]; then
echo "Workspace not found at ${WORKSPACE_PATH}"
exit 1
fi
for module in "${MODULES[@]}"; do
PROJECT_PATH="${ROOT_DIR}/${module}/${module}.xcodeproj"
MODULE_DIR="${ROOT_DIR}/${module}"
OUTPUT_PATH="${DOCS_DIR}/${module}"
if [[ ! -d "${PROJECT_PATH}" ]]; then
echo "Skipping ${module}: project not found at ${PROJECT_PATH}"
continue
fi
scheme="$(get_scheme_override "${module}")"
if [[ -z "${scheme}" ]]; then
scheme="$(get_best_scheme "${PROJECT_PATH}" "${module}" || true)"
fi
if [[ -z "${scheme}" ]]; then
echo "Skipping ${module}: no suitable scheme found in ${PROJECT_PATH}"
continue
fi
if ! workspace_has_scheme "${WORKSPACE_PATH}" "${scheme}"; then
echo "Skipping ${module}: scheme '${scheme}' is not shared in workspace ${WORKSPACE_PATH}"
continue
fi
echo "Generating docs for ${module} using scheme ${scheme}..."
pushd "${MODULE_DIR}" >/dev/null
jazzy \
--clean \
--author "${AUTHOR}" \
--author_url "${AUTHOR_URL}" \
--github_url "${GITHUB_URL}" \
--theme "${THEME}" \
--disable-search \
--hide-documentation-coverage \
--output "${OUTPUT_PATH}" \
--build-tool-arguments "-workspace,${WORKSPACE_PATH},-scheme,${scheme},-sdk,iphoneos,-destination,generic/platform=iOS"
popd >/dev/null
done