lib/Tools/doc
author kleing
Sun, 18 May 2003 15:28:41 +0200
changeset 14035 c46ce87960fb
parent 10555 2323ec838401
child 14981 e73f8140af78
permissions -rwxr-xr-x
attach log files

#!/usr/bin/env bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# DESCRIPTION: view Isabelle documentation


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

function usage()
{
  echo
  echo "Usage: $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

if [ -z "$DOC" ]; then
  ORIG_IFS="$IFS"
  IFS=":"
  for DIR in $ISABELLE_DOCS
  do
    [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
  done
  IFS="$ORIG_IFS"
else
  ORIG_IFS="$IFS"
  IFS=":"
  for DIR in $ISABELLE_DOCS
  do
    [ -f "$DIR/$DOC.dvi" ] && { cd "$DIR"; IFS="$ORIG_IFS"; exec $DVI_VIEWER "$DOC.dvi"; }
  done
  IFS="$ORIG_IFS"
  fail "Unknown Isabelle document: $DOC"  
fi