From bca292d04915378ad5e4d8ebe053b0d91963f16a Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 11 Feb 2014 00:24:38 +0100 Subject: [PATCH] Code cleanup --- doc/scripts/docbook.sh | 43 ++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/doc/scripts/docbook.sh b/doc/scripts/docbook.sh index 8772306..941da7c 100755 --- a/doc/scripts/docbook.sh +++ b/doc/scripts/docbook.sh @@ -44,6 +44,38 @@ _debug() } +#docbook +_docbook() +{ + target="$1" + + source="${target%.*}.xml" + ext="${target##*.}" + ext="${ext##.}" + case "$ext" in + html) + XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" + [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" + $DEBUG $XSLTPROC -o "$target" "$XSL" "$source" + ;; + 1|2|3|4|5|6|7|8|9) + XSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" + $DEBUG $XSLTPROC -o "$target" "$XSL" "$source" + ;; + *) + echo "$0: $target: Unknown type" 1>&2 + return 2 + ;; + esac + + if [ $? -ne 0 ]; then + echo "$0: $target: Could not create page" 1>&2 + $RM -- "$target" + return 2 + fi +} + + #error _error() { @@ -103,7 +135,6 @@ fi while [ $# -gt 0 ]; do target="$1" - source="${target%.*}.xml" shift #determine the type @@ -111,12 +142,9 @@ while [ $# -gt 0 ]; do ext="${ext##.}" case "$ext" in html) - XSL="http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl" - [ -f "${target%.*}.xsl" ] && XSL="${target%.*}.xsl" instdir="$DATADIR/doc/$ext/$PACKAGE" ;; 1|2|3|4|5|6|7|8|9) - XSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" instdir="$MANDIR/man$ext" ;; *) @@ -142,11 +170,6 @@ while [ $# -gt 0 ]; do fi #create - $DEBUG $XSLTPROC -o "$target" "$XSL" "$source" #XXX ignore errors - if [ $? -ne 0 ]; then - echo "$0: $target: Could not create page" 1>&2 - $RM -- "$target" - break - fi + _docbook "$target" || break done