lib/Tools/doc
author wenzelm
Fri, 07 Jan 2011 17:07:00 +0100
changeset 41447 537b290bbe38
parent 32390 468eff174a77
child 52427 9d1cc9a22177
permissions -rwxr-xr-x
tuned whitespace, indentation, comments;

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