summaryrefslogtreecommitdiffstats
path: root/maintenance/gen-doc.sh
blob: 2cfd0fac96625eaa0b28202010af582c186be0fa (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#
# Generate documentation
#


basedir="$(dirname "$0")"
[ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"

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"
	local pdf="$dir/$docname.pdf"

	echo "Generating $docname ..."

	echo "<!DOCTYPE html><html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"></head><body>" > "$html" ||\
		die "Failed to generate"
	markdown "$md" >> "$html" ||\
		die "Failed to generate"
	echo "</body></html>" >> "$html" ||\
		die "Failed to generate"

	wkhtmltopdf "$html" "$pdf" ||\
		die "Failed to generate"
}

for i in "$srcdir"/*.md; do
	gen "$i"
done

cd "$srcdir" || die "Failed to cd"

html2ps --encoding "UTF-8" \
	--web b \
	--dsc \
	--frame \
	--xref \
	--number \
	--underline \
	--colour \
	--hyphenate \
	README.html > AWLSIM.ps ||\
	die "Failed to generate"

ps2pdf AWLSIM.ps AWLSIM.pdf ||\
	die "Failed to generate"

exit 0
bues.ch cgit interface