lib/Tools/doc
author blanchet
Wed, 02 Jun 2010 15:18:48 +0200
changeset 37321 9d7cfae95b30
parent 32390 468eff174a77
child 52427 9d1cc9a22177
permissions -rwxr-xr-x
honor "xsymbols"

#!/usr/bin/env bash
#
# Author: Markus Wenzel, TU Muenchen
#
# DESCRIPTION: view Isabelle documentation


PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: isabelle $PRG [DOC]"
  echo
  echo "  View Isabelle documentation DOC, or show list of available documents."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## args

DOC=""
[ "$#" -ge 1 ] && { DOC="$1"; shift; }

[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage


## main

splitarray ":" "$ISABELLE_DOCS"; DOCS=("${SPLITARRAY[@]}")

if [ -z "$DOC" ]; then
  for DIR in "${DOCS[@]}"
  do
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
  done
else
  for DIR in "${DOCS[@]}"
  do
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    for FMT in "$ISABELLE_DOC_FORMAT" dvi
    do
      [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
    done
  done
  fail "Unknown Isabelle document: $DOC"  
fi