#!/bin/sh
#
# Hacked version of gtkdoc-mkhtml to allow using different stylesheets.

usage="\
Usage: mkhtml MODULE SGML_FILE STYLESHEET"

if test "x$1" = "x--version"; then
      echo "0.10"
      exit 0
fi

if test $# -lt 2; then
      echo "${usage}" 1>&2
      exit 1
fi

module=$1
document=$2
prefix=/usr
gtkdocdir=/usr/share/gtk-doc

declaration=$gtkdocdir/gtk-doc.dcl

if head -1 $document | grep -q "<?xml"; then
  is_xml=true
else
  is_xml=false
fi

# Delete the old index.sgml file, if it exists.
if test -f index.sgml; then
      rm -f index.sgml
fi

if $is_xml; then

    stylesheet=$gtkdocdir/gtk-doc.xsl
    if test $# -ge 3; then
	stylesheet=$3
    fi
    
    /usr/bin/xsltproc --xinclude --stringparam gtkdoc.bookname $module $stylesheet $document
    cp -f $gtkdocdir/*.png .
else

    stylesheet=$gtkdocdir/gtk-doc.dsl
    if test $# -ge 3; then
	stylesheet=$3
    fi

    /usr/bin/openjade -t sgml -w no-idref -d $stylesheet \
	$gtkdocdir/gtk-doc.dcl $document
    
    sed s%href=\"%href=\"$module/% < index.sgml > index.sgml.tmp && mv index.sgml.tmp index.sgml
fi

echo "timestamp" > ../html.stamp

