Files
go_goutils/.githooks/pre-commit/01-docgen
brent saner 1bd6e1256c v1.16.3
ADDED:
* Much more functions to tplx/sprigx
2026-01-29 19:02:21 -05:00

41 lines
881 B
Bash
Executable File

#!/bin/bash
orig="${PWD}"
if ! command -v asciidoctor &> /dev/null;
then
exit 0
fi
set -e
for f in $(find . -type f -iname "README.adoc"); do
filename=$(basename -- "${f}")
docsdir=$(dirname -- "${f}")
nosuffix="${filename%.*}"
pfx="${docsdir}/${nosuffix}"
newf="${pfx}.html"
asciidoctor -a ROOTDIR="${orig}/" -o "${newf}" "${f}"
echo "Generated ${newf} from ${f}"
git add "${newf}"
if command -v pandoc &> /dev/null;
then
newf="${pfx}.md"
set +e
asciidoctor -a ROOTDIR="${orig}/" -b docbook -o - "${f}" | pandoc -f docbook -t markdown_strict -o "${newf}"
if [ $? -eq 0 ];
then
echo "Generated ${newf} from ${f}"
git add "${newf}"
else
echo "Failed to generate ${newf} from ${f}"
git rm "${newf}"
fi
set -e
fi
cd ${orig}
done
echo "Regenerated docs"