parsing: improve parsing of arguments
[gtk-doc.git] / gtkdoc-mkhtml.in
blob1abdf4f82b044ffad2e9b9f892db683d985f4fc5
1 #!/bin/sh
4 usage="\
5 Usage: gtkdoc-mkhtml [--path=SEARCH_PATH] MODULE DRIVER_FILE [BACKEND_OPTIONS...]"
7 #echo "args $0\n";
9 # parse options, ignore unknown options for future extensions
11 searchpath=
12 uninstalled=no
13 while true; do
14 case "X$1" in
15 X--version) echo "@VERSION@"; exit 0;;
16 X--help) echo "$usage"; exit 0;;
17 X--uninstalled) uninstalled=yes; shift;;
18 X--path=*) searchpath=`echo $1 | sed s/.*=//`; shift;;
19 X--*) shift;;
20 X*) break;;
21 esac
22 done
24 if test $# -lt 2; then
25 echo "${usage}" 1>&2
26 exit 1
29 module=$1
30 shift
31 document=$1
32 shift
34 if test $uninstalled = yes; then
35 # this does not work from buiddir!=srcdir
36 gtkdocdir=`dirname $0`
37 if test ! -e $gtkdocdir/gtk-doc.xsl; then
38 # try to src dir (set from makefiles) too
39 if test -e $ABS_TOP_SRCDIR/gtk-doc.xsl; then
40 gtkdocdir=$ABS_TOP_SRCDIR
43 #echo "uninstalled, gtkdocdir=$gtkdocdir, cwd=$PWD"
44 else
45 # the first two are needed to resolve datadir
46 prefix=@prefix@
47 datarootdir=@datarootdir@
48 gtkdocdir=@datadir@/gtk-doc/data
51 if head -n 1 $document | grep "<?xml" > /dev/null; then
52 is_xml=true
53 path_option='--path'
54 else
55 is_xml=false
56 path_option='--directory'
59 # we could do "$path_option $PWD "
60 # to avoid needing rewriting entities that are copied from the header
61 # into docs under xml
62 if test "X$searchpath" = "X"; then
63 path_arg=
64 else
65 path_arg="$path_option $searchpath"
68 # Delete the old index.sgml file, if it exists.
69 if test -f index.sgml; then
70 rm -f index.sgml
73 if $is_xml; then
74 #echo @XSLTPROC@ $path_arg --nonet --xinclude \
75 # --stringparam gtkdoc.bookname $module \
76 # --stringparam gtkdoc.version "@VERSION@" \
77 # "$@" $gtkdocdir/gtk-doc.xsl $document
78 @XSLTPROC@ $path_arg --nonet --xinclude \
79 --stringparam gtkdoc.bookname $module \
80 --stringparam gtkdoc.version "@VERSION@" \
81 "$@" $gtkdocdir/gtk-doc.xsl $document || exit $?
82 else
83 @JADE@ $path_arg -t @SGML_FORMAT_TYPE@ -w no-idref -d $gtkdocdir/gtk-doc.dsl \
84 -V "gtkdoc-bookname=$module" -V "gtkdoc-version=@VERSION@" \
85 "$@" $gtkdocdir/gtk-doc.dcl $document || exit $?
88 # copy navigation images and stylesheets to html directory ...
89 cp -f $gtkdocdir/*.png ./
90 cp -f $gtkdocdir/*.css ./
93 echo "timestamp" > ../html.stamp