Last active
January 17, 2020 22:34
-
-
Save cokert/7b952b73849c4c3d6e71ce2f0aaa1444 to your computer and use it in GitHub Desktop.
Generate GO documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#note this depends on having the script at the gist below available by calling relapth.sh | |
#https://gist.github.com/cokert/089100625c6ebed2d10650b223cb7ca4 | |
if [ -z $1 ] | |
then | |
echo "destination not supplied" | |
exit 1 | |
fi | |
SRC=${PWD} | |
DOCPATH=$1 | |
#purge and recreate destination | |
rm -rf $DOCPATH | |
mkdir $DOCPATH | |
#generate docs (ignoring directories git and cmd) | |
find $SRC -not -path '*/\.git*' -not -path '*/cmd/*' -type d | xargs -I % sh -c 'relpath.sh '$SRC' %' | xargs -I % sh -c 'mkdir '$DOCPATH'/%; go doc -all ./% > '$DOCPATH'/%.txt' | |
#remove empty files/directories | |
find $DOCPATH -empty -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you try to execute in a folder where there is a package is in the root folder (like this: https://github.com/turnerlabs/cstore), that root package will be missed. and if you're looking at a repo where there are no folders (the package is the top level folder like this: https://github.com/juju/errors) it will output nothing. and complain about a relative find -delete
in the second case, you can (obviously) just run
go doc -all > <dest>/<filename>.txt
manually...