changeset 626:39fb83d9a2dc

Refactored documentation generating.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 Jun 2007 03:21:55 +0000
parents f4f7ab72d7c5
children 0b777d93eb98
files docs/build-docs.sh
diffstat 1 files changed, 58 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/docs/build-docs.sh	Wed Jun 06 03:20:43 2007 +0000
+++ b/docs/build-docs.sh	Wed Jun 06 03:21:55 2007 +0000
@@ -1,38 +1,65 @@
 #!/bin/sh
 ### Settings
 SRCFILE="manual.sgml"
+SRCTMP="manual.xml"
 HTMLPATH="html"
+HTMLFILE="manual.html"
+TXTFILE="manual.txt"
 
 ### Get paths, if available
 echo "* Initialization"
-JW=`which jw`
 GS=`which gs`
 CONVERT=`which convert`
 PNMTOPS=`which pnmtops`
 GIFTOPNM=`which giftopnm`
 TIDY=`which tidy`
-
+XSLTPROC=`which xsltproc`
+CATALOGS1=`locate xhtml/chunk.xsl`
+CATALOGS2=`locate xhtml/docbook.xsl`
+LINKS=`which links`
+ELINKS=`which elinks`
+LYNX=`which lynx`
 
 ### Convert images
 echo "* Checking for image to EPS converting utilities ..."
 if test -n "$PNMTOPS" && test -x "$PNMTOPS" && test -n "$GIFTOPNM" && test -x "$GIFTOPNM"; then
 	echo "** NetPBM tools found"
 	for i in *.gif; do
+		echo " - $i"
 		$GIFTOPNM "$i" | $PNMTOPS -scale=0.5 -noturn > `echo "$i" | sed "s/.gif/.eps/"`
 	done
+elif test -n "$CONVERT" && test -x "$CONVERT"; then
+	echo "** ImageMagick found"
+	for i in *.gif; do
+		echo " - $i"
+		$CONVERT "$i" `echo "$i" | sed "s/.gif/.eps/"`
+	done
 else
 	echo "*** WARNING! No supported image conversion tools found, not converting images."
 	echo "*** This may cause some document format conversions to fail or produce errors."
 fi
 
 
-### Check that we have JW installed
-if test -n "$JW" && test -x "$JW"; then
-	echo "** DocBook SGML tools and JW found(?) Generating documentation ..."
+### Check that we have xsltproc installed for DocBook XML processing
+if test -n "$XSLTPROC" && test -x "$XSLTPROC"; then
+	echo "*** xsltproc found, good... testing for DocBook XML stuff .."
+	if test -n "$CATALOGS1"; then
+		echo "  * $CATALOGS1 found."
+	else
+		echo "*** xhtml/chunk.xsl not found!"
+		exit 1
+	fi
+	if test -n "$CATALOGS2"; then
+		echo "  * $CATALOGS2 found."
+	else
+		echo "*** xhtml/docbook.xsl not found!"
+		exit 1
+	fi
+	perl -w normalizeml.pl < "$SRCFILE" > "$SRCTMP"
 else
-	echo "*** ERROR! Jade Wrapper does not seem to be installed."
-	echo "You must have DocBook SGML tools/schemas and JadeTex installed"
-	echo "in order to generate the documentation."
+	echo "*** ERROR! Could not find xsltproc! You need xsltproc and the"
+	echo "*** DocBook XML suite (with XSL stylesheets) to be able to"
+	echo "*** generate the documentation!"
 	exit 1
 fi
 
@@ -45,29 +72,28 @@
 mkdir -p "$HTMLPATH"
 
 if test -d "$HTMLPATH"; then
-	cp *.png *.gif "$HTMLPATH"
+	TMP=`pwd`
+	cp *.png *.gif "$HTMLPATH" && cd "$HTMLPATH" && $XSLTPROC "$CATALOGS1" "../$SRCTMP"
+	cd $TMP
 	
-	$JW -f docbook -b html -o "$HTMLPATH" "$SRCFILE"
+	$XSLTPROC "$CATALOGS2" "$SRCTMP" > "$HTMLFILE"
 
 	echo "** Checking for HTML Tidy ..."
-	if test -n "$JW" && test -x "$JW"; then
+	if test -n "$TIDY" && test -x "$TIDY"; then
 		echo "** Found, cleaning up the mess by DocBook .."
-		$TIDY -asxhtml -i -m $HTMLPATH/*.html
+		$TIDY -w 80 -utf8 -asxhtml -i -m $HTMLPATH/*.html "$HTMLFILE"
 	else
 		echo "*** WARNING! HTML tidy not found."
 	fi
 fi
 
-#exit 0
-
 ### Generate PostScript file
-echo "* PostScript"
-$JW -f docbook -b ps "$SRCFILE"
-
+#echo "* PostScript"
+rm -f manual.ps
 
 ### Generate PDF
-if test -n "$GS" && test -x "$GS"; then
-echo "* PDF ..."
+if test -n "$GS" && test -x "$GS" && test -e manual.ps; then
+	echo "* PDF ..."
 	rm -f manual.pdf
 	$GS -dSAFER -dCompatibilityLevel=1.2 -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
 	-sOutputFile=manual.pdf -dCompatibilityLevel=1.2 -c .setpdfwrite -f manual.ps
@@ -77,5 +103,16 @@
 fi
 
 ### Generate ASCII text
-echo "* Text"
-$JW -f docbook -b txt "$SRCFILE"
+if test -e "$HTMLFILE"; then
+	echo "* Text"
+	if test -n "$LINKS" && test -x "$LINKS"; then
+		$LINKS -dump "$HTMLFILE" > "$TXTFILE"
+	elif test -n "$ELINKS" && test -x "$ELINKS"; then
+		$ELINKS -dump "$HTMLFILE" > "$TXTFILE"
+	elif test -n "$LYNX" && test -x "$LYNX"; then
+		echo "foobar"
+	else
+		echo "*** No Links, ELinks or Lynx found. Not generating plaintext documentation."
+	fi
+fi
+