File indexing completed on 2024-11-03 05:13:00
0001 #/bin/bash 0002 0003 exit_usage () 0004 { 0005 cmd=`basename $0` 0006 echo "\ 0007 Usage: 0008 $cmd TOPDBKFILE HTMLOUTDIR" 0009 exit 100 0010 } 0011 0012 topdbk=$1 0013 test -n "$topdbk" || exit_usage 0014 htmldir=$2 0015 test -n "$htmldir" || exit_usage 0016 0017 cmddir=`dirname $0` 0018 $cmddir/docbook-check.sh $topdbk || exit 1 0019 0020 rm -rf $htmldir && mkdir -p $htmldir 0021 0022 # Build HTML pages. 0023 xsltproc=${XSLTPROC_EXECUTABLE:-xsltproc} 0024 if test -z "`which $xsltproc`"; then 0025 echo "xsltproc (http://xmlsoft.org/) not found." 0026 exit 1 0027 fi 0028 # - find Docbook XSL stylesheets and configure style sheet extensions. 0029 dbxsldir= 0030 for adir in \ 0031 $DOCBOOK_XSL_DIR \ 0032 share/xml/docbook/stylesheet/docbook-xsl \ 0033 share/xml/docbook/xsl-stylesheets \ 0034 share/sgml/docbook/xsl-stylesheets \ 0035 share/xml/docbook/stylesheet/nwalsh/current \ 0036 share/xml/docbook/stylesheet/nwalsh \ 0037 share/xsl/docbook \ 0038 share/xsl/docbook-xsl \ 0039 ; do 0040 for tdir in /usr /usr/local; do 0041 if test -f $tdir/$adir/lib/lib.xsl; then 0042 dbxsldir=$tdir/$adir 0043 break 0044 fi 0045 done 0046 test -n "$dbxsldir" && break 0047 done 0048 if test -z "$dbxsldir"; then 0049 echo "Docbook XSL stylesheets not found in usual paths." 0050 if test -z "$DOCBOOK_XSL_DIR"; then 0051 echo "(If they are installed elsewhere," \ 0052 "set DOCBOOK_XSL_DIR environment variable to that path.)" 0053 fi 0054 exit 1 0055 fi 0056 for xslfile in docbook-html-mono.xsl docbook-html-chapters.xsl; do 0057 xslpath=$cmddir/$xslfile 0058 xslpath1=$cmddir/${xslfile/.xsl/-tmp.xsl} 0059 sed "s;@CONFIG_DBXSLDIR@;$dbxsldir;g" $xslpath >$xslpath1 0060 done 0061 # - build doc 0062 $xsltproc --xinclude $cmddir/docbook-html-mono-tmp.xsl $topdbk >$htmldir/index-mono.html 0063 $xsltproc --xinclude $cmddir/docbook-html-chapters-tmp.xsl $topdbk \ 0064 && mv html/* $htmldir && rmdir html 0065 # - add highlighting 0066 # This relies on custom XSLT of <programlisting> in local.xsl, 0067 # which adds <!-- language: ... --> comment. 0068 # Highlighting CSS definitions are also in docbook-html-style.css. 0069 $cmddir/add-html-highlight.py $htmldir/* 0070 0071 # - clean up 0072 rm $cmddir/*-tmp.xsl 0073 0074 # Sanitize HTML pages. 0075 tidy=${TIDY_EXECUTABLE:-tidy} 0076 if test -n "`which $tidy`"; then 0077 tidy -q --show-warnings no -utf8 -w 0 -m $htmldir/*.html; test -z 0078 fi 0079 # Remove title= attributes to sectioning classes, 0080 # because they cause a tooltip to be shown wherever the pointer is. 0081 sed -i -r 's/(<div[^>]* class="(abstract|article|book|chapter|sect)[^>]*) title="[^"]*"/\1/g' $htmldir/*.html 0082 0083 # Copy HTML data. 0084 dbkdir=`dirname $topdbk` 0085 cp $cmddir/docbook-html-style.css $htmldir/style.css 0086 find $dbkdir -maxdepth 1 \ 0087 -iname '*.png' -o \ 0088 -iname '*.jpg' -o \ 0089 -name DUMMY | xargs -r cp -t $htmldir 0090