summaryrefslogtreecommitdiffstats
path: root/maintenance/gen-doc.sh
blob: 7cbcd1a170b00a4bbac736bc74a9389c78e331e2 (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
#!/bin/sh
#
# Generate documentation
#

basedir="$(realpath "$0" | xargs dirname)"
srcdir="$basedir/.."

die()
{
	echo "$*" >&2
	exit 1
}

gen()
{
	local md="$1"
	local docname="$(basename "$md" .md)"
	local dir="$(dirname "$md")"
	local html="$dir/$docname.html"

	echo "Generating $(realpath --relative-to="$srcdir" "$html") from $(realpath --relative-to="$srcdir" "$md") ..."
	python3 -m readme_renderer -o "$html" "$md" ||\
		die "Failed to generate HTML."
}

for i in $(find "$srcdir" \( -name release-archives -prune \) -o \( -name target -prune \) -o \( -name '*.md' -print \)); do
	gen "$i"
done

cd "$srcdir" || die "cd failed."
cargo doc || die "cargo doc failed."

exit 0
bues.ch cgit interface