lib/Tools/doc
author wenzelm
Sat Aug 22 17:08:06 2009 +0200 (2009-08-22)
changeset 32390 468eff174a77
parent 32322 45cb4a86eca2
child 52427 9d1cc9a22177
permissions -rwxr-xr-x
function splitarray: splightly more abstract version that accomodates older bashes;
     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 splitarray ":" "$ISABELLE_DOCS"; DOCS=("${SPLITARRAY[@]}")
    38 
    39 if [ -z "$DOC" ]; then
    40   for DIR in "${DOCS[@]}"
    41   do
    42     [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    43     [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
    44   done
    45 else
    46   for DIR in "${DOCS[@]}"
    47   do
    48     [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    49     for FMT in "$ISABELLE_DOC_FORMAT" dvi
    50     do
    51       [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
    52     done
    53   done
    54   fail "Unknown Isabelle document: $DOC"  
    55 fi
    56