#!/bin/sh # gnome-doc-html - Convert documentation to HTML # gnome-doc-html. Generated from gnome-doc-html.in by configure. # Copyright (C) 2006 Shaun McCance # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. progname=`echo "$0" | sed 's%^.*/%%'` PROGRAM=gnome-doc-html PACKAGE=@PACKAGE@ VERSION=@VERSION@ prefix=@prefix@ datarootdir=@datarootdir@ datadir=@datadir@ pkgdatadir=@datadir@/gnome-doc-utils xsltdir=@datadir@/xml/gnome/xslt error() { echo "$progname: $1" 1>&2; exit 1; } print_help() { cat < [OPTIONS] FILE Process a documentation file. COMMAND is one of: html convert the document to HTML xhtml convert the document to XHTML help display this help and exit EOF } print_help_html() { format="$1" upformat=`echo $format | tr a-z A-Z` cat <&2; exit 1; fi eval set -- "$options"; while [ "$1" != "--" ]; do case "$1" in -c | --css-file) doc_css_file="$2";; -d | --chunk-depth) doc_chunk_depth="$2";; -e | --extension) doc_extension="$2";; -n | --no-figures) doc_no_figures="1";; -o | --output) doc_output="$2";; --copy-graphics) doc_copy_graphics="1";; --admon-graphics-path) doc_admon_graphics_path="$2";; --admon-graphics-size) doc_admon_graphics_size="$2";; --classsynopsis-language) doc_classsynopsis_language="$2";; --funcsynopsis-style) doc_funcsynopsis_style="$2";; -v | --verbose) doc_verbose=1;; -V | --version) echo "$PROGRAM ($PACKAGE) $VERSION" exit 0;; -h | --help) print_help_html $doc_format exit 0;; --) print_help_html $doc_format 1>&2 exit 1;; esac shift done shift if [ "$#" != "1" ]; then print_help_html $doc_format 1>& 2; exit 1; fi; doc_input="$1" if [ ! -f "$doc_input" ]; then error "$doc_input: No such file"; fi doc_indir=$( (cd $(dirname "$doc_input") && pwd) ) doc_infile=$(basename "$doc_input") doc_inbase=$(basename "$doc_infile" ".xml") if [ "$doc_inbase" = "$doc_infile" ]; then doc_inbase=$(basename "$doc_infile" ".docbook") fi; if [ "x$doc_output" = "x" ]; then doc_outdir=`pwd` if [ "x$doc_extension" = "x" ]; then doc_extension=".$doc_format"; fi doc_outfile="${doc_inbase}${doc_extension}" elif [ -d "$doc_output" -o $(echo "$doc_output" | sed -e 's/.*\/$/\//') = "/" ]; then mkdir_p "$doc_output" doc_outdir=`(cd "$doc_output" && pwd)` if [ "x$doc_extension" = "x" ]; then doc_extension=".$doc_format"; fi doc_outfile="${doc_inbase}${doc_extension}" else dir=`dirname "$doc_output"` mkdir_p "$dir" doc_outdir=`(cd "$dir" && pwd)` doc_outfile=`basename "$doc_output"` if [ "x$doc_extension" = "x" ]; then doc_extension=`echo "$doc_outfile" | grep -o '\..*'` fi; fi; doc_outbase=$(basename "$doc_outfile" "$doc_extension") params='--param db.chunk.chunk_top 0' params="$params --stringparam db.chunk.basename \"$doc_outbase\"" params="$params --stringparam db.chunk.extension \"$doc_extension\"" if [ "x$doc_chunk_depth" != "x" ]; then params="$params --param db.chunk.max_depth $doc_chunk_depth" fi if [ "x$doc_css_file" != "x" ]; then params="$params --stringparam db2html.css.file \"$doc_css_file\"" fi graphics=`xmllint --noent --xinclude "$doc_indir/$doc_infile" \ | xsltproc "$xsltdir/docbook/utils/graphics.xsl" -`; if [ "x$doc_copy_graphics" = "x1" ]; then for graphic in `echo $graphics | tr ' ' '\n' | grep '^admon-'`; do param="theme.icon."`echo $graphic | sed -e 's/\.png$//' -e 's/-/./'`; if [ "x$doc_admon_graphics_path" = "x" ]; then cmd="cp \"$pkgdatadir/icons/hicolor/48x48/$graphic\" \"$doc_outdir/$graphic\"" echo_verbose "$cmd" eval "$cmd" params="$params --stringparam $param \"$graphic\"" elif [ -f "$doc_admon_graphics_path/$graphic" ] ; then cmd="cp \"$doc_admon_graphics_path/$graphic\" \"$doc_outdir/$graphic\"" echo_verbose "$cmd" eval "$cmd" params="$params --stringparam $param \"$graphic\"" fi done fi if [ "x$doc_copy_graphics" != "x1" -a "x$doc_admon_graphics_path" != "x" ]; then params="$params --stringparam theme.icon.admon.path \"$doc_admon_graphics_path\"" fi if [ "x$doc_admon_graphics_size" != "x" ]; then params="$params --stringparam theme.icon.admon.size \"$doc_admon_graphics_size\"" fi if [ "x$doc_classsynopsis_language" != "x" ]; then params="$params --stringparam db2html.classsynopsis.language" params="$params \"$doc_classsynopsis_language\"" fi if [ "x$doc_funcsynopsis_style" != "x" ]; then params="$params --stringparam db2html.funcsynopsis.style" params="$params \"$doc_funcsynopsis_style\"" fi cmd="xmllint --noent --xinclude \"$doc_indir/$doc_infile\" |\ xsltproc $params -o \"$doc_outdir/$doc_outfile\" \"$xsltdir/docbook/html/db2$doc_format.xsl\" -" echo_verbose "$cmd" eval "$cmd" if [ "x$doc_no_figures" != "x1" -a "$doc_indir" != "$doc_outdir" ]; then xmllint --noent --xinclude "$doc_indir/$doc_infile" \ | xsltproc "$xsltdir/docbook/utils/figures.xsl" - \ | while read fig; do mkdir_p "$doc_outdir/"`dirname "$fig"` cmd="cp \"$doc_indir/$fig\" \"$doc_outdir/$fig\"" echo_verbose "$cmd" eval "$cmd" done fi } command="$1"; if [ "x$command" = "x" ]; then print_help 1>&2; exit 1; fi; shift; if [ "$command" = "html" -o "$command" = "xhtml" ]; then DO_html "$command" $@; elif [ "$command" = "-V" -o "$command" = "--version" ]; then echo "$PROGRAM ($PACKAGE) $VERSION"; exit 0; elif [ "$command" = "help" ]; then print_help; exit 0; else print_help 1>&2; exit 1; fi;