10555
|
1 |
#!/usr/bin/env bash
|
2332
|
2 |
#
|
9788
|
3 |
# Author: Markus Wenzel, TU Muenchen
|
2332
|
4 |
#
|
|
5 |
# DESCRIPTION: view Isabelle documentation
|
|
6 |
|
|
7 |
|
10511
|
8 |
PRG="$(basename "$0")"
|
2332
|
9 |
|
|
10 |
function usage()
|
|
11 |
{
|
|
12 |
echo
|
28650
|
13 |
echo "Usage: isabelle $PRG [DOC]"
|
2332
|
14 |
echo
|
|
15 |
echo " View Isabelle documentation DOC, or show list of available documents."
|
|
16 |
echo
|
|
17 |
exit 1
|
|
18 |
}
|
|
19 |
|
|
20 |
function fail()
|
|
21 |
{
|
|
22 |
echo "$1" >&2
|
|
23 |
exit 2
|
|
24 |
}
|
|
25 |
|
|
26 |
|
|
27 |
## args
|
|
28 |
|
|
29 |
DOC=""
|
9788
|
30 |
[ "$#" -ge 1 ] && { DOC="$1"; shift; }
|
2332
|
31 |
|
9788
|
32 |
[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage
|
2332
|
33 |
|
|
34 |
|
|
35 |
## main
|
|
36 |
|
|
37 |
if [ -z "$DOC" ]; then
|
9788
|
38 |
ORIG_IFS="$IFS"
|
|
39 |
IFS=":"
|
|
40 |
for DIR in $ISABELLE_DOCS
|
2332
|
41 |
do
|
15703
|
42 |
[ -d "$DIR" ] || fail "Bad document directory: $DIR"
|
9788
|
43 |
[ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
|
2332
|
44 |
done
|
9788
|
45 |
IFS="$ORIG_IFS"
|
2332
|
46 |
else
|
9788
|
47 |
ORIG_IFS="$IFS"
|
|
48 |
IFS=":"
|
|
49 |
for DIR in $ISABELLE_DOCS
|
2332
|
50 |
do
|
15703
|
51 |
IFS="$ORIG_IFS"
|
|
52 |
[ -d "$DIR" ] || fail "Bad document directory: $DIR"
|
|
53 |
for FMT in "$ISABELLE_DOC_FORMAT" dvi
|
|
54 |
do
|
28500
|
55 |
[ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
|
15703
|
56 |
done
|
2332
|
57 |
done
|
9788
|
58 |
IFS="$ORIG_IFS"
|
2332
|
59 |
fail "Unknown Isabelle document: $DOC"
|
|
60 |
fi
|
15717
|
61 |
|