@@ -174,6 +174,8 @@ standardBuildProcess() {
174
174
175
175
buildstep packageLambdaFunction
176
176
177
+ buildstep generateCodeDocs
178
+
177
179
if [ ! -z ${GOFMT_TARGETS+x} ]; then
178
180
echo " ERROR: GOFMT_TARGETS is deprecated"
179
181
exit 1
@@ -197,6 +199,16 @@ function packageLambdaFunction {
197
199
)
198
200
}
199
201
202
+ # uses doc2go to (auto)generate documentation for Go code.
203
+ # https://abhinav.github.io/doc2go/
204
+ # use case: private projects for which https://pkg.go.dev/ docs aren't accessible.
205
+ function generateCodeDocs {
206
+ local docsTempDir=" /tmp/docsite"
207
+ rm -rf " $docsTempDir "
208
+ doc2go -out " $docsTempDir " ./...
209
+ tar -C " $docsTempDir " . -czf rel/code-documentation.tar.gz
210
+ }
211
+
200
212
# not being sourced?
201
213
#
202
214
# when we don't go into the if, we're in backwards compatiblity mode. this script used to be sourced,
@@ -207,9 +219,10 @@ function packageLambdaFunction {
207
219
# so the new style is to just invoke this script with args.
208
220
if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
209
221
SKIP_PACKAGELAMBDAFUNCTION=y
222
+ SKIP_GENERATECODEDOCS=y
210
223
211
224
# we don't use short options but "-o" needs to be set, otherwise it mysteriously just doesn't work...
212
- options=$( getopt -l " directory:,binary-basename:,aws-lambda-zip" -o " " -a -- " $@ " )
225
+ options=$( getopt -l " directory:,binary-basename:,aws-lambda-zip,generate-code-documentation " -o " " -a -- " $@ " )
213
226
214
227
eval set -- " $options "
215
228
@@ -227,6 +240,9 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
227
240
--aws-lambda-zip)
228
241
unset SKIP_PACKAGELAMBDAFUNCTION
229
242
;;
243
+ --generate-code-documentation)
244
+ unset SKIP_GENERATECODEDOCS
245
+ ;;
230
246
--)
231
247
shift
232
248
break ;;
@@ -247,6 +263,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
247
263
SKIP_CODEGENERATION=y
248
264
SKIP_STATICANALYSIS=y
249
265
SKIP_TESTS=y
266
+ SKIP_GENERATECODEDOCS=y
250
267
fi
251
268
252
269
standardBuildProcess
0 commit comments