lib/Tools/doc
author wenzelm
Sat Dec 20 11:39:27 2008 +0100 (2008-12-20)
changeset 29143 72c960b2b83e
parent 28650 a7ba12e0d3b7
child 32322 45cb4a86eca2
permissions -rwxr-xr-x
removed Ids;
     1 #!/usr/bin/env bash
     2 #
     3 # Author: Markus Wenzel, TU Muenchen
     4 #
     5 # DESCRIPTION: view Isabelle documentation
     6 
     7 
     8 PRG="$(basename "$0")"
     9 
    10 function usage()
    11 {
    12   echo
    13   echo "Usage: isabelle $PRG [DOC]"
    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=""
    30 [ "$#" -ge 1 ] && { DOC="$1"; shift; }
    31 
    32 [ "$#" -ne 0 -o "$DOC" = "-?" ] && usage
    33 
    34 
    35 ## main
    36 
    37 if [ -z "$DOC" ]; then
    38   ORIG_IFS="$IFS"
    39   IFS=":"
    40   for DIR in $ISABELLE_DOCS
    41   do
    42     [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    43     [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
    44   done
    45   IFS="$ORIG_IFS"
    46 else
    47   ORIG_IFS="$IFS"
    48   IFS=":"
    49   for DIR in $ISABELLE_DOCS
    50   do
    51     IFS="$ORIG_IFS"
    52     [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    53     for FMT in "$ISABELLE_DOC_FORMAT" dvi
    54     do
    55       [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
    56     done
    57   done
    58   IFS="$ORIG_IFS"
    59   fail "Unknown Isabelle document: $DOC"  
    60 fi
    61