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
|
(test -d global && test -f build.sh) || {
echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory"
exit 1
}
. global/common.sh
reqpack cmark "generate documentation"
file="$1"
filename="$(basename "$file")"
stem=${filename%%.md}
mandest="$out/doc/man"
section=${section:-4}
out="$mandest/$stem.$section"
desc_rec="$(grep -m1 "^$stem:" global/modules)"
if test "$desc_rec" != ""; then
desc=" - $(echo $desc_rec | cut -d: -f4)"
else
desc=""
fi
date="$(date -r"$file" "+%d %A %Y")"
mkdir -p "$mandest"
echo >"$out" ".TH ${stem^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\""
echo >>"$out" ".SH NAME"
echo >>"$out" "$stem$desc"
echo >>"$out" ".SH SYNOPSIS"
dhead=$(grep -m1 -n "^# description$" "$file")
if test $? -eq 0; then
descline=$(echo "$dhead" | cut -d: -f1)
offset=1
else
descline=$(grep -m2 -n "^#" "$file" | tail -n1 | cut -d: -f1)
offset=0
fi
tail -n+2 $file | head -n$(expr $descline - 2) | cmark -t man >>"$out"
echo >>"$out" ".SH DESCRIPTION"
tail -n+$(expr $descline + $offset) "$file" | cmark -t man >> "$out"
if has gzip; then
gzip -f "$out"
out="$out.gz"
fi
say "wrote manpage for $stem to $out"
|
|
>
|
>
>
>
|
|
>
>
>
>
<
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
>
>
>
>
|
|
>
|
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
(test -d global && test -f build.sh) || {
echo >&2 "($0) run [1m$me[21m from root of [1mlibk[21m source directory"
exit 1
}
. global/common.sh
reqpack cmark "generate documentation"
check gen "a directory for generated build dependencies"
file="$1"
filename="$(basename "$file")"
stem=${filename%%.md}
mandest=${out_manpage:-"$out/doc/man"}
htmldest=${out_html:-"$out/doc/html"}
pdfdest=${out_pdf:-"$out/doc/pdf"}
section=${manual_section:-4}
man="$mandest/$stem.$section"
html="$htmldest/$stem.html"
pdf="$pdfdest/$stem.pdf"
fmt="$gen/$stem.tmp"
desc_rec="$(grep -m1 "^$stem:" global/modules)"
if test "$desc_rec" != ""; then
desc=" - $(echo $desc_rec | cut -d: -f4)"
else
desc=""
fi
date="$(date -r"$file" "+%d %A %Y")"
echo >"$fmt" ".TH ${stem^^} \"$section\" \"$date\" \"hale.su libk [r$build]\" \"modules\""
echo >>"$fmt" ".SH NAME"
echo >>"$fmt" "$stem$desc"
echo >>"$fmt" ".SH SYNOPSIS"
dhead=$(grep -m1 -n "^# description$" "$file")
if test $? -eq 0; then
descline=$(echo "$dhead" | cut -d: -f1)
offset=1
else
descline=$(grep -m2 -n "^#" "$file" | tail -n1 | cut -d: -f1)
offset=0
fi
tail -n+2 $file | head -n$(expr $descline - 2) | cmark -t man >>"$fmt"
echo >>"$fmt" ".SH DESCRIPTION"
tail -n+$(expr $descline + $offset) "$file" | cmark -t man >> "$fmt"
test "$doc_html" = "yes" && {
mkdir -p "$htmldest"
groff -Thtml -Kutf8 -m man "$fmt" > "$html"
say "wrote html page for $stem to $html"
}
test "$doc_pdf" = "yes" && {
mkdir -p "$pdfdest"
groff -Tpdf -Kutf8 -m man "$fmt" > "$pdf"
say "wrote pdf for $stem to $pdf"
}
test "$doc_man" = "yes" && {
mkdir -p "$mandest"
if has gzip; then
man="$man.gz"
gzip -c -f "$fmt" > "$man"
else
mv "$fmt" "$man"
fi
say "wrote manpage for $stem to $man"
}
|