diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rwxr-xr-x | gnome-doc-html.in | 212 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-classsynopsis.xsl | 2 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-cmdsynopsis.xsl | 10 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-funcsynopsis.xsl | 35 | ||||
-rw-r--r-- | xslt/docbook/html/db2html-media.xsl | 81 | ||||
-rw-r--r-- | xslt/docbook/utils/Makefile.am | 2 | ||||
-rw-r--r-- | xslt/docbook/utils/figures.xsl | 45 |
10 files changed, 351 insertions, 61 deletions
@@ -1,3 +1,25 @@ +2006-10-09 Shaun McCance <shaunm@gnome.org> + + * Makefile.am: + * configure.in: + * gnome-doc-html: + - Added gnome-doc-html, no-fuss script to convert DocBook to HTML + + * xslt/docbook/html/db2html-classsynopsis.xsl: + - Fixed type: python mode was calling cpp mode + + * xslt/docbook/html/db2html-cmdsynopsis.xsl: + - Fixed documentation typos: s/paramter/parameter/ + + * xslt/docbook/html/db2html-funcsynopsis.xsl: + - Whitespace + + * xslt/docbook/html/db2html-media.xsl: + * xslt/docbook/utils/Makefile.am: + * xslt/docbook/utils/figures.xsl: + - Split out db2html.imagedata.src to give figures.xsl + - Added figures.xsl util to list the actual media files used + 2006-09-11 Theppitak Karoonboonyanan <thep@linux.thai.net> * xslt/gettext/l10n-numbers.xsl: diff --git a/Makefile.am b/Makefile.am index 01a07546..d969ba21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ pkgdata_DATA=\ template.make \ template-document.xml -bin_SCRIPTS = gnome-doc-prepare +bin_SCRIPTS = gnome-doc-prepare gnome-doc-html endif # doc must go last diff --git a/configure.in b/configure.in index d6cc237a..f5cee753 100644 --- a/configure.in +++ b/configure.in @@ -33,6 +33,7 @@ AM_GLIB_GNU_GETTEXT AC_OUTPUT([ Makefile +gnome-doc-html gnome-doc-prepare gnome-doc-utils.pc doc/Makefile diff --git a/gnome-doc-html.in b/gnome-doc-html.in new file mode 100755 index 00000000..2e5212b3 --- /dev/null +++ b/gnome-doc-html.in @@ -0,0 +1,212 @@ +#!/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 <shaunm@gnome.org> +# +# 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 + +function error { + echo "$progname: $1" 1>&2; + exit 1; +} +# FIXME: chunk depth +function print_help { + echo "Usage: $progname [OPTIONS] FILE" + echo "Convert FILE into HTML." + echo "" + echo "Basic Output Control:" + echo " -d, --chunk-depth=INT how deep sections should be chunked" + echo " -e, --extension=EXT the extension to append to output files" + echo " -n, --no-figures do not copy figures into the output directory" + echo " -o, --output=PATH the file or directory to output to" + echo "" + echo "Formatting Control:" + echo " --admon-graphics-path=PATH the path to the admonition graphics" + echo " --admon-graphics-size=INT the size of the admonition graphics" + echo " --admon-graphics-extension=EXT the extension of the admonition grahpics" + echo " --classsynopsis-language=LANG the default programming language to be used" + echo " for classsynopsis elements" + echo " --funcsynopsis-style=STYLE the style to be used to render funcsynopsis" + echo " elements, either 'KR' or 'ANSI'" + echo "" + echo "Miscellaneous:" + echo " -v, --verbose print all the commands executed" + echo " -V, --version print version information and exit" + echo " -h, --help display this help and exit" +} +function echo_verbose { + if [ "x$doc_verbose" == "x1" ]; then echo $1; fi +} +function mkdir_p { + dir=''; + echo $1 | sed -e 's/\//\n/g' | while read d; do + dir="$dir$d/" + if [ ! -d "$dir" ]; then + echo_verbose "mkdir \"$dir\"" + mkdir "$dir" + fi + done; +} + +longopts=' + -lchunk-depth: + -lextension: + -lno-figures + -loutput: + -ladmon-graphics-path: + -ladmon-graphics-size: + -ladmon-graphics-extension: + -lclasssynopsis-language: + -lfuncsynopsis-style: + -lverbose + -lversion + -lhelp +' +options=`getopt -qn$progname $longopts -- d:e:o:nvVh "$@"` +if [ "$?" != "0" ]; then print_help 1>&2; exit 1; fi + +eval set -- "$options"; +while [ "$1" != "--" ]; do + case "$1" in + -d | --chunk-depth) + doc_chunk_depth="$2";; + -e | --extension) + doc_extension="$2";; + -n | --no-figures) + doc_no_figures="1";; + -o | --output) + doc_output="$2";; + + --admon-graphics-path) + doc_admon_graphics_path="$2";; + --admon-graphics-size) + doc_admon_graphics_size="$2";; + --admon-graphics-extension) + doc_admon_graphics_extension="$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 + exit 0;; + --) + print_help 1>&2 + exit 1;; + esac + shift +done +shift + +if [ "$#" != "1" ]; then print_help 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) +if [ "x${doc_infile: -4}" == "x.xml" ]; then + doc_inbase=${doc_infile:0:$((${#doc_infile}-4))} +else + doc_inbase="$doc_infile" +fi + +if [ "x$doc_output" == "x" ]; then + doc_outdir=`pwd` + if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; fi + doc_outfile="${doc_inbase}${doc_extension}" +elif [ -d "$doc_output" -o "${doc_output: -1}" == "/" ]; then + mkdir_p "$doc_output" + doc_outdir=`(cd "$doc_output" && pwd)` + if [ "x$doc_extension" == "x" ]; then doc_extension='.xhtml'; 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; +if [ "x${doc_outfile: -${#doc_extension}}" == "x${doc_extension}" ]; then + doc_outbase="${doc_outfile:0:$((${#doc_outfile}-${#doc_extension}))}" +else + doc_outbase="${doc_outfile}" +fi + +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_admon_graphics_path" != "x" ]; then + params="$params --stringparam db2html.admon.graphics_path" + params="$params \"$doc_admon_graphics_path\"" +fi +if [ "x$doc_admon_graphics_size" != "x" ]; then + params="$params --stringparam db2html.admon.graphics_size" + params="$params \"$doc_admon_graphics_size\"" +fi +if [ "x$doc_admon_graphics_extension" != "x" ]; then + params="$params --stringparam db2html.admon.graphics_extension" + params="$params \"$doc_admon_graphics_extension\"" +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/db2html.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 diff --git a/xslt/docbook/html/db2html-classsynopsis.xsl b/xslt/docbook/html/db2html-classsynopsis.xsl index 0e1af239..250fe298 100644 --- a/xslt/docbook/html/db2html-classsynopsis.xsl +++ b/xslt/docbook/html/db2html-classsynopsis.xsl @@ -79,7 +79,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA <xsl:apply-templates mode="db2html.class.cpp.mode" select="."/> </xsl:when> <xsl:when test="$language = 'python'"> - <xsl:apply-templates mode="db2html.class.cpp.mode" select="."/> + <xsl:apply-templates mode="db2html.class.python.mode" select="."/> </xsl:when> <xsl:otherwise> <xsl:message> diff --git a/xslt/docbook/html/db2html-cmdsynopsis.xsl b/xslt/docbook/html/db2html-cmdsynopsis.xsl index 0f541334..ccdca501 100644 --- a/xslt/docbook/html/db2html-cmdsynopsis.xsl +++ b/xslt/docbook/html/db2html-cmdsynopsis.xsl @@ -14,7 +14,7 @@ <parameter xmlns="http://www.gnome.org/~shaunm/xsldoc"> <name>db2html.cmdsynopsis.sepchar</name> <purpose> - The default value for the <parameter>sepchar</parameter> paramter + The default value for the <parameter>sepchar</parameter> parameter </purpose> </parameter> @@ -26,7 +26,7 @@ <parameter xmlns="http://www.gnome.org/~shaunm/xsldoc"> <name>db2html.arg.choice</name> <purpose> - The default value of the <parameter>choice</parameter> paramter + The default value of the <parameter>choice</parameter> parameter for <xmltag>arg</xmltag> elements </purpose> </parameter> @@ -39,7 +39,7 @@ <parameter xmlns="http://www.gnome.org/~shaunm/xsldoc"> <name>db2html.arg.rep</name> <purpose> - The default value of the <parameter>rep</parameter> paramter + The default value of the <parameter>rep</parameter> parameter for <xmltag>arg</xmltag> elements </purpose> </parameter> @@ -52,7 +52,7 @@ <parameter xmlns="http://www.gnome.org/~shaunm/xsldoc"> <name>db2html.group.choice</name> <purpose> - The default value of the <parameter>choice</parameter> paramter + The default value of the <parameter>choice</parameter> parameter for <xmltag>group</xmltag> elements </purpose> </parameter> @@ -65,7 +65,7 @@ <parameter xmlns="http://www.gnome.org/~shaunm/xsldoc"> <name>db2html.group.rep</name> <purpose> - The default value of the <parameter>rep</parameter> paramter + The default value of the <parameter>rep</parameter> parameter for <xmltag>group</xmltag> elements </purpose> </parameter> diff --git a/xslt/docbook/html/db2html-funcsynopsis.xsl b/xslt/docbook/html/db2html-funcsynopsis.xsl index e1092ece..944d3690 100644 --- a/xslt/docbook/html/db2html-funcsynopsis.xsl +++ b/xslt/docbook/html/db2html-funcsynopsis.xsl @@ -73,32 +73,31 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA <xsl:choose> <xsl:when test="$style = 'KR'"> <xsl:for-each select="void | varargs | paramdef/parameter"> - <xsl:if test="position() != 1"> - <xsl:text>, </xsl:text> - </xsl:if> - <xsl:apply-templates select="."/> + <xsl:if test="position() != 1"> + <xsl:text>, </xsl:text> + </xsl:if> + <xsl:apply-templates select="."/> </xsl:for-each> <xsl:text>)</xsl:text> <xsl:apply-templates select="funcdef/following-sibling::modifier"/> <xsl:text>;</xsl:text> <xsl:for-each select="paramdef"> - <xsl:text>
 </xsl:text> - <xsl:apply-templates select="."/> - <xsl:text>;</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:apply-templates select="."/> + <xsl:text>;</xsl:text> </xsl:for-each> </xsl:when> <!-- ANSI is the default --> <xsl:otherwise> <xsl:variable name="indent" - select="2 + string-length( - funcdef | - funcdef/preceding-sibling::modifier)"/> + select="2 + string-length(funcdef | + funcdef/preceding-sibling::modifier)"/> <xsl:for-each select="void | varargs | paramdef"> - <xsl:if test="position() != 1"> - <xsl:text>,
</xsl:text> - <xsl:value-of select="str:padding($indent)"/> - </xsl:if> - <xsl:apply-templates select="."/> + <xsl:if test="position() != 1"> + <xsl:text>,
</xsl:text> + <xsl:value-of select="str:padding($indent)"/> + </xsl:if> + <xsl:apply-templates select="."/> </xsl:for-each> <xsl:text>)</xsl:text> <xsl:apply-templates select="funcdef/following-sibling::modifier"/> @@ -112,11 +111,11 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA <xsl:param name="style"> <xsl:choose> <xsl:when test="processing-instruction('db2html.funcsynopsis.style')"> - <xsl:value-of - select="processing-instruction('db2html.funcsynopsis.style')"/> + <xsl:value-of + select="processing-instruction('db2html.funcsynopsis.style')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$db2html.funcsynopsis.style"/> + <xsl:value-of select="$db2html.funcsynopsis.style"/> </xsl:otherwise> </xsl:choose> </xsl:param> diff --git a/xslt/docbook/html/db2html-media.xsl b/xslt/docbook/html/db2html-media.xsl index 65d80134..da742cd6 100644 --- a/xslt/docbook/html/db2html-media.xsl +++ b/xslt/docbook/html/db2html-media.xsl @@ -28,48 +28,33 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA <!-- == db2html.imagedata ================================================== --> <xsl:template name="db2html.imagedata"> + <xsl:param name="node" select="."/> <img> <xsl:attribute name="src"> - <xsl:choose> - <xsl:when test="@fileref"> - <!-- FIXME: do this less stupidly, or not at all --> - <xsl:choose> - <xsl:when test=" - @format = 'PNG' and - (substring(@fileref, string-length(@fileref) - 3) - != '.png')"> - <xsl:value-of select="concat(@fileref, '.png')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="@fileref"/> - </xsl:otherwise> - </xsl:choose> - </xsl:when> - <xsl:when test="@entityref"> - <xsl:value-of select="unparsed-entity-uri(@entityref)"/> - </xsl:when> - </xsl:choose> + <xsl:call-template name="db2html.imagedata.src"> + <xsl:with-param name="node" select="$node"/> + </xsl:call-template> </xsl:attribute> <xsl:choose> - <xsl:when test="@scale"> + <xsl:when test="$node/@scale"> <xsl:attribute name="width"> - <xsl:value-of select="concat(@scale, '%')"/> + <xsl:value-of select="concat($node/@scale, '%')"/> </xsl:attribute> </xsl:when> - <xsl:when test="@width"> + <xsl:when test="$node/@width"> <xsl:attribute name="width"> - <xsl:value-of select="@width"/> + <xsl:value-of select="$node/@width"/> </xsl:attribute> - <xsl:if test="@height"> + <xsl:if test="$node/@height"> <xsl:attribute name="height"> - <xsl:value-of select="@height"/> + <xsl:value-of select="$node/@height"/> </xsl:attribute> </xsl:if> </xsl:when> </xsl:choose> - <xsl:if test="@align"> + <xsl:if test="$node/@align"> <xsl:attribute name="align"> - <xsl:value-of select="@align"/> + <xsl:value-of select="$node/@align"/> </xsl:attribute> </xsl:if> <!-- FIXME @@ -84,30 +69,56 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA </xsl:template> +<!-- == db2html.imagedata.src ============================================== --> + +<xsl:template name="db2html.imagedata.src"> + <xsl:param name="node" select="."/> + <xsl:choose> + <xsl:when test="$node/@fileref"> + <!-- FIXME: do this less stupidly, or not at all --> + <xsl:choose> + <xsl:when test="$node/@format = 'PNG' and + (substring($node/@fileref, string-length($node/@fileref) - 3) + != '.png')"> + <xsl:value-of select="concat($node/@fileref, '.png')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$node/@fileref"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:when test="$node/@entityref"> + <xsl:value-of select="unparsed-entity-uri($node/@entityref)"/> + </xsl:when> + </xsl:choose> +</xsl:template> + + <!-- == db2html.mediaobject ================================================ --> <xsl:template name="db2html.mediaobject"> + <xsl:param name="node" select="."/> <xsl:choose> <!-- FIXME <xsl:when test="$text_only"> <xsl:apply-templates select="textobject[1]"/> </xsl:when> --> - <xsl:when test="imageobject[imagedata/@format = 'PNG']"> + <xsl:when test="$node/imageobject[imagedata/@format = 'PNG']"> <xsl:apply-templates - select="imageobject[imagedata/@format = 'PNG'][1]"> - <xsl:with-param name="textobject" select="textobject[1]"/> + select="$node/imageobject[imagedata/@format = 'PNG'][1]"> + <xsl:with-param name="textobject" select="$node/textobject[1]"/> </xsl:apply-templates> </xsl:when> - <xsl:when test="imageobjectco[imageobject/imagedata/@format = 'PNG']"> + <xsl:when test="$node/imageobjectco[imageobject/imagedata/@format = 'PNG']"> <xsl:apply-templates - select="imageobjectco[imageobject/imagedata/@format = 'PNG'][1]"> - <xsl:with-param name="textobject" select="textobject[1]"/> + select="$node/imageobjectco[imageobject/imagedata/@format = 'PNG'][1]"> + <xsl:with-param name="textobject" select="$node/textobject[1]"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> - <xsl:apply-templates select="(imageobject | imageobjectco)[1]"> - <xsl:with-param name="textobject" select="textobject[1]"/> + <xsl:apply-templates select="($node/imageobject | $node/imageobjectco)[1]"> + <xsl:with-param name="textobject" select="$node/textobject[1]"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> diff --git a/xslt/docbook/utils/Makefile.am b/xslt/docbook/utils/Makefile.am index 290e917d..c36a426b 100644 --- a/xslt/docbook/utils/Makefile.am +++ b/xslt/docbook/utils/Makefile.am @@ -1,6 +1,6 @@ xsldir=$(datadir)/xml/gnome/xslt/docbook/utils -xsl_DATA = chunks.xsl credits.xsl ids.xsl +xsl_DATA = chunks.xsl credits.xsl figures.xsl ids.xsl EXTRA_DIST=$(xsl_DATA) diff --git a/xslt/docbook/utils/figures.xsl b/xslt/docbook/utils/figures.xsl new file mode 100644 index 00000000..69aeba1b --- /dev/null +++ b/xslt/docbook/utils/figures.xsl @@ -0,0 +1,45 @@ +<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> +<!-- +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser 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 Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License +along with this program; see the file COPYING.LGPL. If not, write to the +Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +--> + +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + version="1.0"> + +<xsl:output method="text" encoding="utf-8"/> + +<xsl:include href="../html/db2html-media.xsl"/> + +<xsl:template match="/"> + <xsl:for-each select="//mediaobject"> + <xsl:call-template name="db2html.mediaobject"> + <xsl:with-param name="node" select="."/> + </xsl:call-template> + </xsl:for-each> +</xsl:template> + +<xsl:template match="imageobjectco"> + <xsl:apply-templates select="imageobject"/> +</xsl:template> + +<xsl:template match="imageobject"> + <xsl:call-template name="db2html.imagedata.src"> + <xsl:with-param name="node" select="imagedata"/> + </xsl:call-template> + <xsl:text>
</xsl:text> +</xsl:template> + +</xsl:stylesheet> |