doc/scdoc/notdoc
$ cat notdoc
#!/bin/sh
# shell script to emit mdoc from scf files, using lowdown

set -eu

if [ "$#" -ne 0 ]; then
	printf '%s\n' 'usage: scdoc < input.scd > output.roff' >&2
	exit 1
fi

if ! command -v lowdown >/dev/null 2>&1; then
	printf '%s\n' 'notdoc: lowdown is required' >&2
	exit 127
fi

_tmp=$(mktemp "${TMPDIR:-/tmp}/notdoc.XXXXXXXX")
trap 'rm -f "$_tmp"' EXIT HUP INT TERM

_input=$(mktemp "${TMPDIR:-/tmp}/notdoc-in.XXXXXXXX")
trap 'rm -f "$_tmp" "$_input"' EXIT HUP INT TERM
cat >"$_input"

# metadata line and remove commnents
sed -e '1s/^/% /' \
	-e '/^; /d' \
	"$_input" >"$_tmp"

if [ -n "${SOURCE_DATE_EPOCH:-}" ]; then
	_date=$(date -u -d "@${SOURCE_DATE_EPOCH}" +%Y-%m-%d) || {
		printf '%s\n' 'scdoc: could not convert SOURCE_DATE_EPOCH' >&2
		exit 1
	}
else
	_date=$(date -u +%Y-%m-%d)
fi

lowdown -s -t mdoc -M "date=${_date}" --roff-manpage "$_tmp"