lib/Tools/doc
author wenzelm
Tue, 13 Jun 2006 23:41:39 +0200
changeset 19876 11d447d5d68c
parent 15717 541e50adfc73
child 28500 4b79e5d3d0aa
permissions -rwxr-xr-x
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10511
diff changeset
     1
#!/usr/bin/env bash
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     2
#
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     3
# $Id$
9788
wenzelm
parents: 8130
diff changeset
     4
# Author: Markus Wenzel, TU Muenchen
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     5
#
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     6
# DESCRIPTION: view Isabelle documentation
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     7
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
     8
10511
wenzelm
parents: 9788
diff changeset
     9
PRG="$(basename "$0")"
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    10
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    11
function usage()
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    12
{
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    13
  echo
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    14
  echo "Usage: $PRG [DOC]"
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    15
  echo
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    16
  echo "  View Isabelle documentation DOC, or show list of available documents."
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    17
  echo
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    18
  exit 1
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    19
}
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    20
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    21
function fail()
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    22
{
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    23
  echo "$1" >&2
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    24
  exit 2
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    25
}
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    26
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    27
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    28
## args
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    29
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    30
DOC=""
9788
wenzelm
parents: 8130
diff changeset
    31
[ "$#" -ge 1 ] && { DOC="$1"; shift; }
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    32
9788
wenzelm
parents: 8130
diff changeset
    33
[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    34
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    35
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    36
## main
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    37
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    38
if [ -z "$DOC" ]; then
9788
wenzelm
parents: 8130
diff changeset
    39
  ORIG_IFS="$IFS"
wenzelm
parents: 8130
diff changeset
    40
  IFS=":"
wenzelm
parents: 8130
diff changeset
    41
  for DIR in $ISABELLE_DOCS
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    42
  do
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    43
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
9788
wenzelm
parents: 8130
diff changeset
    44
    [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    45
  done
9788
wenzelm
parents: 8130
diff changeset
    46
  IFS="$ORIG_IFS"
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    47
else
9788
wenzelm
parents: 8130
diff changeset
    48
  ORIG_IFS="$IFS"
wenzelm
parents: 8130
diff changeset
    49
  IFS=":"
wenzelm
parents: 8130
diff changeset
    50
  for DIR in $ISABELLE_DOCS
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    51
  do
15703
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    52
    IFS="$ORIG_IFS"
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    53
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    54
    for FMT in "$ISABELLE_DOC_FORMAT" dvi
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    55
    do
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    56
      [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISATOOL" display "$DOC.$FMT"; }
727ef1b8b3ee *** empty log message ***
wenzelm
parents: 14981
diff changeset
    57
    done
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    58
  done
9788
wenzelm
parents: 8130
diff changeset
    59
  IFS="$ORIG_IFS"
2332
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    60
  fail "Unknown Isabelle document: $DOC"  
ae592411c199 doc: view Isabelle documentation;
wenzelm
parents:
diff changeset
    61
fi
15717
541e50adfc73 *** MESSAGE REFERS TO PREVIOUS VERSION ***
wenzelm
parents: 15703
diff changeset
    62