lib/Tools/doc
author hoelzl
Mon, 06 Dec 2010 19:54:48 +0100
changeset 41024 ba961a606c67
parent 32390 468eff174a77
child 52427 9d1cc9a22177
permissions -rwxr-xr-x
move coercions to appropriate places

#!/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