scmdoc

Automatically generate documentation from comments in R7RS Scheme code

git clone https://git.8pit.net/scmdoc.git

 1#!/bin/sh
 2
 3cd "$(dirname "$0")"
 4
 5abort() {
 6	printf "${1}\n" 1>&2
 7	exit 1
 8}
 9
10if ! command -v scmdoc 1>/dev/null; then
11	abort "Error: Couldn't find 'scmdoc' in \$PATH" 1>&2
12elif ! command -v tidy 1>/dev/null; then
13	abort "Error: Couldn't find 'tidy' in \$PATH" 1>&2
14fi
15
16TESTDIR="/tmp/scmdoc-test"
17
18mkdir -p "${TESTDIR}"
19trap "rm -rf '${TESTDIR}'" INT EXIT
20
21for test in *; do
22	[ -d "${test}" ] || continue
23
24	name="${test##*/}"
25	printf "Running test case '%s': " "${name}"
26
27	scmdoc "${test}"/*.scm -o "${TESTDIR}"
28	find "${TESTDIR}" -name '*.html' \
29		-exec tidy --wrap 0 --indent yes \
30		--show-body-only yes -o {} {} \; 2>/dev/null
31
32	diff=$(diff -ur "${test}/expected" "${TESTDIR}")
33	if [ $? -ne 0 ]; then
34		printf "FAIL: Output differs.\n\n"
35		printf "%s\n" "${diff}"
36		exit 1
37	fi
38
39	rm -r "${TESTDIR}"/*
40	printf "OK.\n"
41done