Test commit
[cogito/jonas.git] / Documentation / make-cg-ref-asciidoc
blob960e711b5b3a5fc8e4b251298b4c9338b4c89b18
1 #!/usr/bin/env bash
3 # Generate asciidoc manpage markup from Cogito quick reference file.
4 # Copyright (c) Jonas Fonseca, 2006
6 # Takes the path to the reference file. Prints the manpage to stdout.
8 PACKAGE=${CGPACKAGE:-cogito}
10 ref=$1
12 cat <<__END__
13 cg-ref(7)
14 =========
16 NAME
17 ----
18 cg-ref - Cogito quick reference
20 SYNOPSIS
21 --------
22 A list of frequently used commands grouped with related commands.
24 DESCRIPTION
25 -----------
27 __END__
29 sed '
30 0,/^$/d
31 /^`---/d
32 /frame="none"/,1d
33 s/\\$//
34 s/[*]\([^*]*\)[*]/\1/g
35 s/[`]\([^`]*\)[`]/\1/g
36 s/['\'']\([^'\'']*\)['\'']/\1/g
37 ' < "$ref" | \
38 while read line; do
39 col1=$(echo "$line" | cut -f 1)
40 case "$line" in
41 *":")
42 echo "$line"
43 echo "$line" | sed "s/[^~]/~/g"
44 echo
45 echo "[verse]"
46 continue
48 "-----"*|"")
49 echo "$line" | sed 's/-/./g'
50 continue
52 "{cg-refopt}"*)
53 col1=$(echo "$col1" | sed 's/.*cg-refopt}/ /')
55 esac
56 col2=$(echo "$line" | sed 's/.*[ ]\+//')
57 printf "%-30s %s\n" "$col1" "$col2"
58 done
60 cat << __END__
62 COPYRIGHT
63 ---------
64 Copyright (C) Jonas Fonseca, 2006.
66 SEE ALSO
67 --------
68 gitlink:cg-ref[7] is part of gitlink:${PACKAGE}[7],
69 a toolkit for managing gitlink:git[7] trees.
70 __END__