summaryrefslogtreecommitdiffhomepage
path: root/include/mkman
blob: 30250eb1d32e8ac806c24e83f13d7140eff3dcb2 (plain) (blame)
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
#!/usr/local/bin/andy

func dl link {
	set man `basename $link
	set dst out/man/$man

	mkdir -p $dst
	set name `echo $man | sed -E 's/(.*)\.(.)/\U\1(\2)/'
	{
		echo "header { div { h1 {-$name Manual Page}"
		cat include/nav.gsp
		echo "}} hr{}"
	} | gsp -d | read head
	curl -LSs $link
	| mandoc -Thtml -Ostyle=/man/style.css
	| awk -v head=$head '
		!/^<body>/
		 /^<body>/ { print $0, head }
	' >!$dst/index.html

	printf 'li {a href="%s" {-%s%s}}\n' (
		$man
		`printf $name | tr A-Z a-z
		`htmlq -t .Nd <$dst/index.html | tr -d \n | tr -s ' '
	)
}

cd `dirname $args[0]
cd ..

if ! test -f src/man/links {
	set argv0 `basename $args[0]
	echo "$argv0: Links file does not exist" >/dev/stderr
	exit 1
}

while read -d\n -n1 _ {
	dl $_
} <src/man/links | sort