@@ -174,6 +174,8 @@ standardBuildProcess() {
174174
175175 buildstep packageLambdaFunction
176176
177+ buildstep generateCodeDocs
178+
177179 if [ ! -z ${GOFMT_TARGETS+x} ]; then
178180 echo " ERROR: GOFMT_TARGETS is deprecated"
179181 exit 1
@@ -197,6 +199,16 @@ function packageLambdaFunction {
197199 )
198200}
199201
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+
200212# not being sourced?
201213#
202214# 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 {
207219# so the new style is to just invoke this script with args.
208220if [[ " ${BASH_SOURCE[0]} " == " ${0} " ]]; then
209221 SKIP_PACKAGELAMBDAFUNCTION=y
222+ SKIP_GENERATECODEDOCS=y
210223
211224 # 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 -- " $@ " )
213226
214227 eval set -- " $options "
215228
@@ -227,6 +240,9 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
227240 --aws-lambda-zip)
228241 unset SKIP_PACKAGELAMBDAFUNCTION
229242 ;;
243+ --generate-code-documentation)
244+ unset SKIP_GENERATECODEDOCS
245+ ;;
230246 --)
231247 shift
232248 break ;;
@@ -247,6 +263,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
247263 SKIP_CODEGENERATION=y
248264 SKIP_STATICANALYSIS=y
249265 SKIP_TESTS=y
266+ SKIP_GENERATECODEDOCS=y
250267 fi
251268
252269 standardBuildProcess
0 commit comments