Admin/isatest/isatest-annomaly
author wenzelm
Sat, 04 Oct 2008 16:05:09 +0200
changeset 28500 4b79e5d3d0aa
parent 22638 7cea3e27d05f
child 28504 7ad7d7d6df47
permissions -rwxr-xr-x
replaced ISATOOL by ISABELLE_TOOL;

#!/usr/bin/env bash
#
# $Id$
#
# Create AnnoMaLy documentation for Isabelle
#
# Based on http://martin.von-gagern.net/projects/annomaly/
#   2007  Martin von Gagern (martin@von-gagern.net)

## global settings
. ~/admin/isatest/isatest-settings

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

export SMLNJ_HOME="/home/gagern/annomaly"
export SML_DOC_DIR="$HOME/anno-html"

ADMIN="$HOME/admin/isatest"
LOGICS="HOL"

# Abort on any error
set -e -o pipefail

function usage()
{
  echo
  echo "Usage: $PRG"
  echo
  echo "  Generate html documentation from .ML files"
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  echo "$(date) $HOSTNAME $PRG: FAILED, $1" >> $MASTERLOG
  exit 2
}


## main

ISABELLE_HOME="$DISTPREFIX/Isabelle"
ISABELLE_TOOL="$ISABELLE_HOME/bin/isatool"

[ -d $ISABELLE_HOME ] || fail "$ISABELLE_HOME is not a directory."


# Create clean output directory
rm -rf "$SML_DOC_DIR"
mkdir "$SML_DOC_DIR"
cp "$SMLNJ_HOME/annomaly/resources/"* "$SML_DOC_DIR"
cat > "$SML_DOC_DIR/.htaccess" <<EOF
DirectoryIndex index.html source.html
<IfModule mod_deflate>
SetOutputFilter DEFLATE 
</IfModule>
AddType text/plain .dot
EOF

# Prepare build environemnt
cd "$ISABELLE_HOME"
cp "$ADMIN/annomaly.ML" src/Pure/ML-Systems/annomaly.ML
ln -fs run-smlnj lib/scripts/run-annomaly

cd "$ISABELLE_HOME"
export SML_DOC_REWRITE="isabelle=$(cd src; pwd -P)"


# Process image(s)
for L in $LOGICS
do
  ( cd "$ISABELLE_HOME/src/$L"; \
    cat ~/settings/annomaly >> $ISABELLE_HOME/etc/settings; \
    "$ISABELLE_TOOL" make || fail "isabelle make for $L failed." )
done


# Postprocess created files
cd "$SML_DOC_DIR"
dot -Tsvg depGraph.dot \
  | perl -pe 's/(width|height)="(\d+)/sprintf("%s=\"%.2f",$1,$2*0.6)/ge' \
  > depGraph.svg
dot -Tps2 depGraph.dot > depGraph.ps
ps2pdf depGraph.ps depGraph.pdf

# $ISABELLE_HOME does not seem to occur anywhere ??
# grep -rl "$ISABELLE_HOME" . | xargs sed -i "s@$ISABELLE_HOME@\$ISABELLE_HOME@g"


echo "$(date) $HOSTNAME $PRG: annomaly docs generated successfully." >> $MASTERLOG