lib/Tools/doc
author wenzelm
Wed, 13 Apr 2005 18:48:05 +0200
changeset 15717 541e50adfc73
parent 15703 727ef1b8b3ee
child 28500 4b79e5d3d0aa
permissions -rwxr-xr-x
*** MESSAGE REFERS TO PREVIOUS VERSION *** ISABELLE_DOC_FORMAT;

#!/usr/bin/env bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
#
# 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
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    [ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
  done
  IFS="$ORIG_IFS"
else
  ORIG_IFS="$IFS"
  IFS=":"
  for DIR in $ISABELLE_DOCS
  do
    IFS="$ORIG_IFS"
    [ -d "$DIR" ] || fail "Bad document directory: $DIR"
    for FMT in "$ISABELLE_DOC_FORMAT" dvi
    do
      [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISATOOL" display "$DOC.$FMT"; }
    done
  done
  IFS="$ORIG_IFS"
  fail "Unknown Isabelle document: $DOC"  
fi