#
# Revision: 56 1.6 build/makeApiDocs.ksh, build, xml4j2, xml4j2_0_15 
#

echo "Generating API Documentation..."

#
# Define the environment variables pointing to relevant directories.
#

. setupEnvVars.ksh

#
# Test to see if required environment variables have been set or not.
# Its fatal if any of them are not set, so we exit.
#
# The following variables should be set:
#     XML4JAPIDOCDIR
#     SWINGJAR
#     JDK12BIN
#     DOCSRCDIR
#     CLASSPATH
#     XML4JVERSION
#

errFlg=0

if test ! -n "$XML4JAPIDOCDIR"
then
    echo "Build Error: Environment variable XML4JAPIDOCDIR is not set."
    errFlg=1
else
    echo "XML4JAPIDOCDIR=$XML4JAPIDOCDIR"
fi


if test ! -n "$SWINGJAR"
then
    echo "Build Error: Environment variable SWINGJAR is not set."
    errFlg=1
else
    echo "SWINGJAR=$SWINGJAR"
fi


if test ! -n "$JDK12BIN"
then
    echo "Build Error: Environment variable JDK12BIN is not set."
    errFlg=1
else
    echo "JDK12BIN=$JDK12BIN"
fi


if test ! -n "$DOCSRCDIR"
then
    echo "Build Error: Environment variable DOCSRCDIR is not set."
    errFlg=1
else
    echo "DOCSRCDIR=$DOCSRCDIR"
fi


if test ! -n "$CLASSPATH"
then
    echo "Build Error: Environment variable CLASSPATH is not set."
    errFlg=1
else
    echo "CLASSPATH=$CLASSPATH"
fi


if test ! -n "$XML4JVERSION"
then
    echo "Build Error: Environment variable XML4JVERSION is not set."
    errFlg=1
else
    echo "XML4JVERSION=$XML4JVERSION"
fi


if test $errFlg -eq 1
then
    echo "Aborting..."
    exit
else
    echo ""
fi


APIDOCDIR=$XML4JAPIDOCDIR
PACKAGES="com.ibm.xml.parsers com.ibm.xml.framework com.ibm.xml.dom org.w3c.dom org.xml.sax org.xml.sax.helpers"

TXAPIDOCDIR=$XML4JTXAPIDOCDIR
TXPACKAGES="com.ibm.xml.parser com.ibm.xml.parser.util com.ibm.xml.xpointer"
#
# Create the API documentation output directory if required.
#

if test ! -d $APIDOCDIR
then
    mkdir $APIDOCDIR
fi
if test ! -d $APIDOCDIR/images
then
    mkdir $APIDOCDIR/images
fi

if test ! -d $TXAPIDOCDIR
then
	mkdir $TXAPIDOCDIR
fi
if test ! -d $TXAPIDOCDIR/images
then
	mkdir $TXAPIDOCDIR/images
fi

#
# Now, generate the API documentation using 'javadoc'.
#

VerWithDot=`echo $XML4JVERSION | sed 's/_/./g'`
$JDK12BIN/javadoc -J-mx100m -windowtitle "XML for Java $VerWithDot API" \
                  -splitindex -header "XML for Java $VerWithDot" \
                  -classpath "$CLASSPATH;$SWINGJAR" -version  \
                  -d $APIDOCDIR $PACKAGES

$JDK12BIN/javadoc -J-mx100m -windowtitle "XML for Java $VerWithDot Compatibility API" \
                  -splitindex -header "XML for Java Compatibility API $VerWithDot" \
                  -classpath "$CLASSPATH;$SWINGJAR" -version  \
                  -d $TXAPIDOCDIR $TXPACKAGES

#                  -stylesheetfile $XML4JROOT/docs/xml4j.css \

echo "Finished generating API Documentation."
