blob: 82e4807e419d23a6774ac4dcd5f07d74e3423cbe (
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
|
#!/bin/sh -e
# Convert 'contrib' scripts to manual pages.
# This script basically converts some of the comments inside scripts to manual
# page format. The intention behind this utility is to generate manual pages for
# contrib scripts without much hassle.
case "$1" in
--help|-h|'')
printf 'usage: %s [file]\n' "${0##*/}" >&2
exit 1
esac
out() { printf '%s\n' "$@"; }
file=$1
filename=${file##*/}
date=$(date "+%b %d, %Y")
docstr=$(sed -n '2s/# //p' $file)
out \
".Dd $date" \
".Dt $filename 1" \
".Sh NAME" \
".Nm $filename" \
".Nd $docstr"
while read -r line; do
case $line in
'###'*:)
line=${line%:}
out ".Ss ${line#'### '}"
;;
'##'*:)
line=${line%:}
out ".Sh ${line#'## '}"
;;
'##'|'###')
out ".Pp"
;;
'##'*)
line=${line#'##'}
line=${line#'#'}
line=${line# }
out "$line"
;;
esac
done < "$file"
out ".Sh AUTHOR" ".An Cem Keylan Aq Mt cem@ckyln.com"
out ".Sh LICENSE" "See LICENSE for copyright information."
out ".Sh SEE ALSO" ".Xr cpt 1"
|