#!/bin/sh
# usage: cov
# env vars required: srcdir

test -n "${srcdir}"

sed -e '//{N;s/^../=====/g;}' \
    -e '/^=====/!d' \
    -e 's/^=====//g' \
    -e 's/[()]//g' \
    -e 's/ .*//g' \
    ../*/*.doc \
    | sort \
    > TMP-dot-doc-files

sed -e '/twerpdoc/!d' \
    -e 's/.*(//g;s/).*//g' \
    ${srcdir}/*.twerp \
    | sort \
    > TMP-twerpdoc-directives

diff -u TMP-dot-doc-files TMP-twerpdoc-directives > TMP

if [ -s TMP ] ; then
    echo 'ERROR: bad doc coverage!'
    cat TMP
    rm TMP-* TMP
    exit 1
fi

rm TMP-* TMP
exit 0

# cov ends here
