summaryrefslogtreecommitdiffstats
path: root/Documentation/technical/api-index.sh
blob: 296488557434b7fff60ab25f4246a4dc270729c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

if test $# -ne 2
then
	echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
	exit 1
fi

SOURCE_DIR="$1"
OUTPUT="$2"

(
	cd "$SOURCE_DIR"

	c=////////////////////////////////////////////////////////////////
	skel=api-index-skel.txt
	sed -e '/^\/\/ table of contents begin/q' "$skel"
	echo "$c"

	ls api-*.txt |
	while read filename
	do
		case "$filename" in
		api-index-skel.txt | api-index.txt) continue ;;
		esac
		title=$(sed -e 1q "$filename")
		html=${filename%.txt}.html
		echo "* link:$html[$title]"
	done
	echo "$c"
	sed -n -e '/^\/\/ table of contents end/,$p' "$skel"
) >"$OUTPUT"+

if test -f "$OUTPUT" && cmp "$OUTPUT" "$OUTPUT"+ >/dev/null
then
	rm -f "$OUTPUT"+
else
	mv "$OUTPUT"+ "$OUTPUT"
fi