home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / gnome-doc-tool < prev    next >
Encoding:
Text File  |  2010-04-28  |  20.0 KB  |  688 lines

  1. #!/bin/sh
  2. # gnome-doc-html - Convert documentation to HTML
  3. # gnome-doc-html.  Generated from gnome-doc-html.in by configure.
  4. # Copyright (C) 2006 Shaun McCance <shaunm@gnome.org>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14. # General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. #
  20. # As a special exception to the GNU General Public License, if you
  21. # distribute this file as part of a program that contains a
  22. # configuration script generated by Autoconf, you may include it under
  23. # the same distribution terms that you use for the rest of that program.
  24.  
  25. progname=`echo "$0" | sed 's%^.*/%%'`
  26.  
  27. PROGRAM=gnome-doc-html
  28. PACKAGE=gnome-doc-utils
  29. VERSION=0.20.1
  30. prefix=/usr
  31. datarootdir=${prefix}/share
  32. datadir=${datarootdir}
  33. pkgdatadir=${datarootdir}/gnome-doc-utils
  34. xsltdir=${datarootdir}/xml/gnome/xslt
  35.  
  36. # This is important to make sure string manipulation is handled
  37. # byte-by-byte.
  38. export LANG=C
  39.  
  40. XSL_ICONS='
  41. <xsl:stylesheet
  42.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  43.   xmlns:mal="http://projectmallard.org/1.0/"
  44.   version="1.0">
  45. <xsl:import href="'$xsltdir'/gettext/gettext.xsl"/>
  46. <xsl:output method="text" encoding="utf-8"/>
  47. <xsl:template match="*">
  48.   <xsl:apply-templates/>
  49. </xsl:template>
  50. <xsl:template match="text()"/>
  51. <xsl:template match="caution">
  52.   <xsl:text>admon-caution </xsl:text>
  53. </xsl:template>
  54. <xsl:template match="important">
  55.   <xsl:text>admon-important </xsl:text>
  56. </xsl:template>
  57. <xsl:template match="note">
  58.   <xsl:choose>
  59.     <xsl:when test="@role='\''bug'\''">
  60.       <xsl:text>admon-bug </xsl:text>
  61.     </xsl:when>
  62.     <xsl:otherwise>
  63.       <xsl:text>admon-note </xsl:text>
  64.     </xsl:otherwise>
  65.   </xsl:choose>
  66. </xsl:template>
  67. <xsl:template match="tip">
  68.   <xsl:text>admon-tip </xsl:text>
  69. </xsl:template>
  70. <xsl:template match="warning">
  71.   <xsl:text>admon-warning </xsl:text>
  72. </xsl:template>
  73. <xsl:template match="mal:note">
  74.   <xsl:choose>
  75.     <xsl:when test="contains(concat('\'' '\'', @style, '\'' '\''), '\''advanced'\'')">
  76.       <xsl:text>admon-important </xsl:text>
  77.     </xsl:when>
  78.     <xsl:when test="contains(concat('\'' '\'', @style, '\'' '\''), '\''bug'\'')">
  79.       <xsl:text>admon-bug </xsl:text>
  80.     </xsl:when>
  81.     <xsl:when test="contains(concat('\'' '\'', @style, '\'' '\''), '\''important'\'')">
  82.       <xsl:text>admon-important </xsl:text>
  83.     </xsl:when>
  84.     <xsl:when test="contains(concat('\'' '\'', @style, '\'' '\''), '\''tip'\'')">
  85.       <xsl:text>admon-tip </xsl:text>
  86.     </xsl:when>
  87.     <xsl:when test="contains(concat('\'' '\'', @style, '\'' '\''), '\''warning'\'')">
  88.       <xsl:text>admon-warning </xsl:text>
  89.     </xsl:when>
  90.     <xsl:otherwise>
  91.       <xsl:text>admon-note </xsl:text>
  92.     </xsl:otherwise>
  93.   </xsl:choose>
  94. </xsl:template>
  95. <xsl:template match="/FALSE">
  96.   <xsl:if test="//blockquote[1]">
  97.     <xsl:call-template name="l10n.gettext">
  98.       <xsl:with-param name="msgid" select="'\''blockquote-watermark-201C'\''"/>
  99.     </xsl:call-template>
  100.     <xsl:text> </xsl:text>
  101.   </xsl:if>
  102.   <xsl:if test="//classsynopsis[@language = '"'"'cpp'"'"'][1] or //programlisting[@language = '"'"'cpp'"'"']">
  103.     <xsl:text>watermark-code-cpp </xsl:text>
  104.   </xsl:if>
  105.   <xsl:if test="//classsynopsis[@language = '"'"'python'"'"'][1] or //programlisting[@language = '"'"'python'"'"']">
  106.     <xsl:text>watermark-code-python </xsl:text>
  107.   </xsl:if>
  108. </xsl:template>
  109. </xsl:stylesheet>'
  110.  
  111. XSL_CACHE_LS='
  112. <xsl:stylesheet
  113.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  114.   xmlns:cache="http://projectmallard.org/cache/1.0/"
  115.   xmlns:mal="http://projectmallard.org/1.0/"
  116.   version="1.0">
  117. <xsl:output method="text"/>
  118. <xsl:template match="/">
  119.   <xsl:for-each select="cache:cache/mal:page">
  120.     <xsl:value-of select="@cache:href"/>
  121.     <xsl:text> </xsl:text>
  122.   </xsl:for-each>
  123. </xsl:template>
  124. </xsl:stylesheet>'
  125.  
  126. XSL_DOCBOOK_MEDIA='
  127. <xsl:stylesheet
  128.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  129.   version="1.0">
  130. <xsl:output method="text" encoding="utf-8"/>
  131. <xsl:template match="/">
  132.   <xsl:for-each select="//audiodata|//imagedata|//videodata">
  133.     <xsl:choose>
  134.       <xsl:when test="@fileref">
  135.         <xsl:value-of select="@fileref"/>
  136.       </xsl:when>
  137.       <xsl:when test="@entityref">
  138.         <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
  139.       </xsl:when>
  140.     </xsl:choose>
  141.     <xsl:text> </xsl:text>
  142.   </xsl:for-each>
  143. </xsl:template>
  144. </xsl:stylesheet>'
  145.  
  146. XSL_MALLARD_CSS='
  147. <xsl:stylesheet
  148.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  149.   xmlns:mal="http://projectmallard.org/1.0/"
  150.   version="1.0">
  151. <xsl:import href="'$xsltdir'/gettext/gettext.xsl"/>
  152. <xsl:import href="'$xsltdir'/common/theme.xsl"/>
  153. <xsl:import href="'$xsltdir'/mallard/html/mal2html-css.xsl"/>
  154. <xsl:output method="text"/>
  155. <xsl:template match="/">
  156. <xsl:call-template name="mal2html.css.content"/>
  157. </xsl:template>
  158. </xsl:stylesheet>'
  159.  
  160. XSL_MALLARD_MEDIA='
  161. <xsl:stylesheet
  162.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  163.   xmlns:mal="http://projectmallard.org/1.0/"
  164.   version="1.0">
  165. <xsl:output method="text" encoding="utf-8"/>
  166. <xsl:template match="/">
  167.   <xsl:for-each select="//mal:media">
  168.     <xsl:value-of select="@src"/>
  169.     <xsl:text> </xsl:text>
  170.   </xsl:for-each>
  171. </xsl:template>
  172. </xsl:stylesheet>'
  173.  
  174. error() {
  175.     echo "$progname: $1" 1>&2;
  176.     exit 1;
  177. }
  178.  
  179. print_help() {
  180.     cat <<EOF
  181. Usage: $progname <COMMAND> [OPTIONS] FILES...
  182. Process a documentation file.
  183.  
  184. COMMAND is one of:
  185.   list-icons   list automatic icons and watermarks
  186.   list-media   list all referenced media files
  187.   html         convert the documents to HTML
  188.   xhtml        convert the documents to XHTML
  189.   css          create a CSS file for a Mallard document
  190.   help         display this help and exit
  191. EOF
  192. }
  193.  
  194. print_help_css() {
  195. cat <<EOF
  196. Usage $progname css [OPTIONS] [FILE]
  197. Create a CSS file for a Mallard document.
  198. If FILE is not supplied, uses index.page as input.
  199.  
  200. CSS Options:
  201.   -o, --output=PATH               the file to output to
  202.  
  203. Miscellaneous:
  204.   -v, --verbose                   print all the commands executed
  205.   -V, --version                   print version information and exit
  206.   -h, --help                      display this help and exit
  207. EOF
  208. }
  209.  
  210. print_help_html() {
  211.     format="$1"
  212.     upformat=`echo $format | tr a-z A-Z`
  213.     cat <<EOF
  214. Usage: $progname $format [OPTIONS] FILE
  215. Convert FILE into $upformat.
  216.  
  217. Basic Output Control:
  218.   -c, --css-file=FILE             file to output CSS to
  219.   -e, --extension=EXT             the extension to append to output files
  220.   -n, --no-figures                do not copy figures into the output directory
  221.   -o, --output=PATH               the file or directory to output to
  222.   -x, --custom-xslt=PATH          custom XSLT to include in the transform
  223.                                   (currently only for Mallard)
  224.  
  225. Automatic Graphics:
  226.   --copy-graphics                 copy graphics into the output directory
  227.   --admon-graphics-path=PATH      the path to the admonition graphics
  228.   --admon-graphics-size=INT       the size of the admonition graphics
  229.  
  230. Docbook Chunking:
  231.   -d, --chunk-depth=INT           how deep sections should be chunked
  232.  
  233. DocBook Styling:
  234.   --classsynopsis-language=LANG   the default programming language to be used
  235.                                   for classsynopsis elements
  236.   --funcsynopsis-style=STYLE      the style to be used to render funcsynopsis
  237.                                   elements, either 'KR' or 'ANSI'
  238.  
  239. Miscellaneous:
  240.   -v, --verbose                   print all the commands executed
  241.   -V, --version                   print version information and exit
  242.   -h, --help                      display this help and exit
  243. EOF
  244. }
  245.  
  246. echo_verbose() {
  247.     if [ "x$doc_verbose" = "x1" ]; then echo $1; fi
  248. }
  249.  
  250. mkdir_p() {
  251.     __dir__='';
  252.     echo $1 | sed -e 's/\//\n/g' | while read d; do
  253.     __dir__="$__dir__$d/"
  254.     if [ ! -d "$__dir__" ]; then
  255.         echo_verbose "mkdir \"$__dir__\""
  256.         mkdir "$__dir__" || error "Could not create directory"
  257.     fi
  258.     done || exit 1;
  259. }
  260.  
  261. urlencode() {
  262.     arg="$1"
  263.     i="0"
  264.     while [ "$i" -lt ${#arg} ]; do
  265.     c=${arg:$i:1}
  266.     if echo "$c" | grep -q '[a-zA-Z/:_\.\-]'; then
  267.         echo -n "$c"
  268.     else
  269.         echo -n "%"
  270.         printf "%X" "'$c'"
  271.     fi
  272.     i=$((i+1))
  273.     done
  274. }
  275.  
  276. urldecode() {
  277.     arg="$1"
  278.     i="0"
  279.     while [ "$i" -lt ${#arg} ]; do
  280.     c0=${arg:$i:1}
  281.     if [ "x$c0" = "x%" ]; then
  282.         c1=${arg:$((i+1)):1}
  283.         c2=${arg:$((i+2)):1}
  284.         printf "\x$c1$c2"
  285.         i=$((i+3))
  286.     else
  287.         echo -n "$c0"
  288.         i=$((i+1))
  289.     fi
  290.     done
  291. }
  292.  
  293. copy_icons() {
  294.     if [ "x$doc_copy_icons" = "x1" ]; then
  295.     if [ "x$doc_icons_admon_path" = "x" ]; then
  296.         p="$pkgdatadir/icons/hicolor/"
  297.         if [ "x$doc_icons_admon_size" != "x" ]; then
  298.         doc_icons_admon_path="${p}${doc_icons_admon_size}x${doc_icons_admon_size}/status"
  299.         else
  300.         doc_icons_admon_path="${p}48x48/status"
  301.         fi
  302.         unset p
  303.     fi
  304.     for doc_icon in $(echo $doc_icons_to_copy | tr ' ' '\n' | grep '^admon-' | sort | uniq); do
  305.         doc_icon_file="${doc_icon}.png"
  306.         cmd="cp \"$doc_icons_admon_path/$doc_icon_file\" \"$doc_outdir/$doc_icon_file\""
  307.         echo_verbose "$cmd"
  308.         eval "$cmd"
  309.     done
  310.     fi
  311. }
  312.  
  313. list_icons() {
  314.     while [ "$#" != "0" ]; do
  315.     if [ -d "$1" ]; then
  316.         list_icons "$1/"*.page
  317.     else
  318.         echo "$XSL_ICONS" | xsltproc --nonet --xinclude - "$1"
  319.     fi
  320.     shift
  321.     done | sort | uniq
  322. }
  323.  
  324. list_media() {
  325.     if [ "x$(echo "$1" | sed -e 's/.*\.//')" = "xpage" -o -d "$1" ]; then
  326.     XSL_MEDIA="$XSL_MALLARD_MEDIA"
  327.     else
  328.     XSL_MEDIA="$XSL_DOCBOOK_MEDIA"
  329.     fi
  330.     while [ "$#" != "0" ]; do
  331.     if [ -d "$1" ]; then
  332.         list_media "$1/"*.page
  333.     else
  334.         doc_indir=$(dirname "$1")
  335.         if [ "$doc_indir" = "." ]; then
  336.         doc_indir=""
  337.         else
  338.         doc_indir="$doc_indir/"
  339.         fi
  340.         echo "$XSL_MEDIA" | xsltproc --nonet --xinclude - "$1" \
  341.         | while read doc_media; do
  342.         echo "$doc_indir$doc_media"
  343.         done
  344.     fi
  345.     shift
  346.     done | sort | uniq
  347. }
  348.  
  349. convert_docbook2html() {
  350.     if [ "x$doc_extension" = "x" ]; then doc_extension=".$doc_format"; fi
  351.     if [ "x$doc_output" = "x" ]; then
  352.     doc_outdir=`pwd`
  353.     elif [ -d "$doc_output" -o $(echo "$doc_output" | sed -e 's/.*\/$/\//') = "/" ]; then
  354.     mkdir_p "$doc_output"
  355.     doc_outdir=`(cd "$doc_output" && pwd)`
  356.     else
  357.     if [ "$#" != "1" ]; then
  358.         error "With multiple input files, output must be a directory"
  359.     fi
  360.     dir=`dirname "$doc_output"`
  361.     mkdir_p "$dir"
  362.     doc_outdir=`(cd "$dir" && pwd)`
  363.     doc_outfile=`basename "$doc_output"`
  364.     doc_outfile_q="1"
  365.     if [ "x$doc_extension" = "x" ]; then
  366.         doc_extension=`echo "$doc_outfile" | grep -o '\..*'`
  367.     fi;
  368.     fi;
  369.     while [ "$#" != "0" ]; do
  370.     doc_input="$1"
  371.     shift
  372.  
  373.     if [ ! -f "$doc_input" ]; then error "$doc_input: No such file"; fi
  374.     doc_indir=$( (cd $(dirname "$doc_input") && pwd) )
  375.     doc_infile=$(basename "$doc_input")
  376.     doc_inbase=$(basename "$doc_infile" ".xml")
  377.     if [ "$doc_inbase" = "$doc_infile" ]; then
  378.         doc_inbase=$(basename "$doc_infile" ".docbook")
  379.     fi;
  380.  
  381.     if [ "x$doc_outfile_q" != "x1" ]; then
  382.         doc_outfile="${doc_inbase}${doc_extension}"
  383.     fi
  384.     doc_outbase=$(basename "$doc_outfile" "$doc_extension")
  385.  
  386.     params='--param db.chunk.chunk_top 0'
  387.     params="$params --stringparam db.chunk.basename \"$doc_outbase\""
  388.     params="$params --stringparam db.chunk.extension \"$doc_extension\""
  389.     if [ "x$doc_chunk_depth" != "x" ]; then
  390.         params="$params --param db.chunk.max_depth $doc_chunk_depth"
  391.     fi
  392.     if [ "x$doc_css_file" != "x" ]; then
  393.         params="$params --stringparam db2html.css.file \"$doc_css_file\""
  394.     fi
  395.  
  396.     if [ "x$doc_copy_icons" = "x1" ]; then
  397.         doc_icons=$(list_icons "$doc_indir/$doc_infile")
  398.         doc_icons_to_copy="$doc_icons $doc_icons_to_copy"
  399.         for doc_icon in $(echo $doc_icons | tr ' ' '\n' | grep '^admon-' | sort | uniq); do
  400.         param="theme.icon."$(echo $doc_icon | sed -e 's/-/./');
  401.         params="$params --stringparam $param \"$doc_icon\""
  402.         done
  403.     fi
  404.     if [ "x$doc_copy_icons" != "x1" -a "x$doc_icons_path" != "x" ]; then
  405.         params="$params --stringparam theme.icon.admon.path \"$doc_icons_admon_path\""
  406.     fi
  407.     if [ "x$doc_admon_graphics_size" != "x" ]; then
  408.         params="$params --stringparam theme.icon.admon.size \"$doc_icons_admon_size\""
  409.     fi
  410.     if [ "x$doc_classsynopsis_language" != "x" ]; then
  411.         params="$params --stringparam db2html.classsynopsis.language"
  412.         params="$params \"$doc_classsynopsis_language\""
  413.     fi
  414.     if [ "x$doc_funcsynopsis_style" != "x" ]; then
  415.         params="$params --stringparam db2html.funcsynopsis.style"
  416.         params="$params \"$doc_funcsynopsis_style\""
  417.     fi
  418.  
  419.     cmd="xmllint --nonet --xinclude \"$doc_indir/$doc_infile\" |\
  420.           xsltproc $params -o \"$doc_outdir/$doc_outfile\" \"$xsltdir/docbook/html/db2$doc_format.xsl\" -"
  421.     echo_verbose "$cmd"
  422.     eval "$cmd"
  423.     exit 0
  424.  
  425.     if [ "x$doc_no_figures" != "x1" -a "$doc_indir" != "$doc_outdir" ]; then
  426.         echo "$XSL_DOCBOOK_MEDIA" \
  427.         | xsltproc --nonet --xinclude - "$doc_indir/$doc_infile" \
  428.         | while read doc_media; do
  429.         mkdir_p "$doc_outdir/"`dirname "$fig"`
  430.         cmd="cp \"$doc_indir/$fig\" \"$doc_outdir/$fig\""
  431.         echo_verbose "$cmd"
  432.         eval "$cmd"
  433.         done
  434.     fi
  435.     done
  436.     copy_icons
  437. }
  438.  
  439. convert_mallard2html() {
  440.     if [ "x$doc_extension" = "x" ]; then doc_extension=".$doc_format"; fi
  441.     if [ "x$doc_output" = "x" ]; then
  442.     doc_outdir=`pwd`
  443.     elif [ -d "$doc_output" -o $(echo "$doc_output" | sed -e 's/.*\/$/\//') = "/" ]; then
  444.     mkdir_p "$doc_output"
  445.     doc_outdir=`(cd "$doc_output" && pwd)`
  446.     else
  447.     if [ "$#" != "1" -o -d "$1" ]; then
  448.         error "With multiple input files, output must be a directory"
  449.     fi
  450.     dir=`dirname "$doc_output"`
  451.     mkdir_p "$dir"
  452.     doc_outdir=`(cd "$dir" && pwd)`
  453.     doc_outfile=`basename "$doc_output"`
  454.     doc_outfile_q="1"
  455.     if [ "x$doc_extension" = "x" ]; then
  456.         doc_extension=`echo "$doc_outfile" | grep -o '\..*'`
  457.     fi;
  458.     fi;
  459.     doc_cache_in="$doc_outdir/index.cache.in"
  460.     doc_cache="$doc_outdir/index.cache"
  461.     doc_tmpfiles="$doc_tmpfiles doc_cache_in doc_cache_out"
  462.     (
  463.     echo '<cache:cache xmlns:cache="http://projectmallard.org/cache/1.0/"'
  464.     echo '             xmlns="http://projectmallard.org/1.0/">'
  465.     while [ "$#" != "0" ]; do
  466.         doc_input="$1"
  467.         shift
  468.         if [ -d "$doc_input" ]; then
  469.         doc_input_full=$(cd "$doc_input" && pwd)
  470.         for doc_input_file in "$doc_input_full/"*.page; do
  471.             echo "$doc_input_file"
  472.         done
  473.         unset doc_input_full
  474.         else
  475.         echo "$(pwd)/$doc_input"
  476.         fi
  477.     done | while read doc_input; do
  478.         doc_input_esc=$(urlencode "$doc_input" | sed -e 's/\&/\&/g' -e 's/</\</g' -e "s/'/\'/g")
  479.         echo "<page cache:href='file://$doc_input_esc'/>"
  480.     done
  481.     echo '</cache:cache>'
  482.     ) > "$doc_cache_in"
  483.     xsltproc -o "$doc_cache" "$xsltdir/mallard/cache/mal-cache.xsl" "$doc_cache_in"
  484.     rm "$doc_cache_in"
  485.     echo "$XSL_CACHE_LS" | xsltproc - "$doc_cache" | while read doc_input; do
  486.     doc_input=$(urldecode $(echo "$doc_input" | sed -e 's/^file:\/\///'))
  487.     doc_indir=$( (cd $(dirname "$doc_input") && pwd) )
  488.     doc_infile=$(basename "$doc_input")
  489.     doc_inbase=$(basename "$doc_infile" ".page")
  490.  
  491.     if [ "x$doc_outfile_q" != "x1" ]; then
  492.         doc_outfile="${doc_inbase}${doc_extension}"
  493.     fi
  494.  
  495.     params='--param mal.chunk.chunk_top 0'
  496.     params="$params --stringparam mal.cache.file \"$doc_cache\""
  497.  
  498.     if [ "x$doc_css_file" != "x" ]; then
  499.         params="$params --stringparam mal2html.css.file \"$doc_css_file\""
  500.     fi
  501.  
  502.     if [ "x$doc_copy_icons" = "x1" ]; then
  503.         doc_icons=$(list_icons "$doc_indir/$doc_infile")
  504.         doc_icons_to_copy="$doc_icons $doc_icons_to_copy"
  505.         for doc_icon in $(echo $doc_icons | tr ' ' '\n' | grep '^admon-' | sort | uniq); do
  506.         param="theme.icon."$(echo $doc_icon | sed -e 's/-/./');
  507.         params="$params --stringparam $param \"$doc_icon\""
  508.         done
  509.     fi
  510.     if [ "x$doc_copy_icons" != "x1" -a "x$doc_icons_path" != "x" ]; then
  511.         params="$params --stringparam theme.icon.admon.path \"$doc_icons_admon_path\""
  512.     fi
  513.     if [ "x$doc_admon_graphics_size" != "x" ]; then
  514.         params="$params --stringparam theme.icon.admon.size \"$doc_icons_admon_size\""
  515.     fi
  516.  
  517.     if [ "x$doc_custom_xslt" != "x" ]; then
  518.         cmd="echo '<stylesheet xmlns=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\
  519.                        <import href=\"$xsltdir/mallard/html/mal2$doc_format.xsl\"/>\
  520.                        <include href=\"$doc_custom_xslt\"/></stylesheet>' |\
  521.                  xsltproc --nonet --xinclude $params -o \"$doc_outdir/$doc_outfile\"\
  522.                  - \"$doc_indir/$doc_infile\""
  523.     else
  524.         cmd="xsltproc --nonet --xinclude $params -o \"$doc_outdir/$doc_outfile\"\
  525.                  \"$xsltdir/mallard/html/mal2$doc_format.xsl\" \"$doc_indir/$doc_infile\""
  526.     fi
  527.     echo_verbose "$cmd"
  528.     eval "$cmd"
  529.  
  530.     if [ "x$doc_no_figures" != "x1" -a "$doc_indir" != "$doc_outdir" ]; then
  531.         echo "$XSL_MALLARD_MEDIA" \
  532.         | xsltproc --nonet --xinclude - "$doc_indir/$doc_infile" \
  533.         | while read doc_media; do
  534.         mkdir_p "$doc_outdir/"`dirname "$doc_media"`
  535.         cmd="cp \"$doc_indir/$doc_media\" \"$doc_outdir/$doc_media\""
  536.         echo_verbose "$cmd"
  537.         eval "$cmd"
  538.         done
  539.     fi
  540.     done
  541.     copy_icons
  542. }
  543.  
  544. create_css() {
  545.     longopts='
  546.       -loutput:
  547.       -lverbose
  548.       -lversion
  549.       -lhelp
  550.     ';
  551.     options=`getopt -qn$progname $longopts -- o:vVh "$@"`
  552.     if [ "$?" != "0" ]; then print_help_css 1>&2; exit 1; fi
  553.     eval set -- "$options";
  554.     while [ "$1" != "--" ]; do
  555.     case "$1" in
  556.         -o | --output)
  557.         doc_output="$2";;
  558.  
  559.         -v | --verbose)
  560.         doc_verbose=1;;
  561.  
  562.         -V | --version)
  563.         echo "$PROGRAM ($PACKAGE) $VERSION"
  564.         exit 0;;
  565.         -h | --help)
  566.         print_help_css
  567.         exit 0;;
  568.         --)
  569.         print_help_css 1>&2
  570.         exit 1;;
  571.     esac
  572.     shift
  573.     done
  574.     shift
  575.  
  576.     doc_input_page="$1"
  577.     if [ "x$doc_input_page" = "x" ]; then
  578.     doc_input_page="index.page"
  579.     fi
  580.     if [ "x$doc_output" = "x" ]; then
  581.     doc_output="index.css"
  582.     fi
  583.  
  584.     echo_verbose "Creating $doc_output using $doc_input_page"
  585.     echo "$XSL_MALLARD_CSS" | xsltproc -o "$doc_output" - "$doc_input_page";
  586. }
  587.  
  588. convert_2html() {
  589.     doc_format="$1"
  590.     shift
  591.     longopts='
  592.       -lcss-file:
  593.       -lchunk-depth:
  594.       -lextension:
  595.       -lno-figures
  596.       -loutput:
  597.       -lcustom-xslt:
  598.       -lcopy-graphics
  599.       -ladmon-graphics-path:
  600.       -ladmon-graphics-size:
  601.       -lclasssynopsis-language:
  602.       -lfuncsynopsis-style:
  603.       -lverbose
  604.       -lversion
  605.       -lhelp
  606.     ';
  607.     options=`getopt -qn$progname $longopts -- c:d:e:o:x:nvVh "$@"`
  608.     if [ "$?" != "0" ]; then print_help_html $doc_format 1>&2; exit 1; fi
  609.     eval set -- "$options";
  610.     while [ "$1" != "--" ]; do
  611.     case "$1" in
  612.         -c | --css-file)
  613.         doc_css_file="$2";;
  614.         -d | --chunk-depth)
  615.         doc_chunk_depth="$2";;
  616.         -e | --extension)
  617.         doc_extension="$2";;
  618.         -n | --no-figures)
  619.         doc_no_figures="1";;
  620.         -o | --output)
  621.         doc_output="$2";;
  622.         -x | --custom-xslt)
  623.         doc_custom_xslt="$2";;
  624.  
  625.         --copy-graphics)
  626.         doc_copy_icons="1";;
  627.         --admon-graphics-path)
  628.         doc_icons_admon_path="$2";;
  629.         --admon-graphics-size)
  630.         doc_icons_admon_size="$2";;
  631.         --classsynopsis-language)
  632.         doc_classsynopsis_language="$2";;
  633.         --funcsynopsis-style)
  634.         doc_funcsynopsis_style="$2";;
  635.  
  636.         -v | --verbose)
  637.         doc_verbose=1;;
  638.  
  639.         -V | --version)
  640.         echo "$PROGRAM ($PACKAGE) $VERSION"
  641.         exit 0;;
  642.         -h | --help)
  643.         print_help_html $doc_format
  644.         exit 0;;
  645.         --)
  646.         print_help_html $doc_format 1>&2
  647.         exit 1;;
  648.     esac
  649.     shift
  650.     done
  651.     shift
  652.  
  653.     if [ "$#" = "0" ]; then print_help_html $doc_format 1>&2; exit 1; fi
  654.     if [ "x$(echo "$1" | sed -e 's/.*\.//')" = "xpage" -o -d "$1" ]; then
  655.     convert_mallard2html $@;
  656.     else
  657.     convert_docbook2html $@;
  658.     fi
  659.     exit 0
  660. }
  661.  
  662.  
  663. command="$1";
  664. if [ "x$command" = "x" ]; then
  665.     print_help 1>&2;
  666.     exit 1;
  667. fi;
  668. shift;
  669. if [ "$command" = "html" -o "$command" = "xhtml" ]; then
  670.     convert_2html "$command" $@;
  671. elif [ "$command" = "css" ]; then
  672.     create_css $@;
  673. elif [ "$command" = "list-icons" ]; then
  674.     list_icons $@;
  675. elif [ "$command" = "list-media" ]; then
  676.     list_media $@;
  677. elif [ "$command" = "-V" -o "$command" = "--version" ]; then
  678.     echo "$PROGRAM ($PACKAGE) $VERSION";
  679.     exit 0;
  680. elif [ "$command" = "help" ]; then
  681.     print_help;
  682.     exit 0;
  683. else
  684.     print_help 1>&2;
  685.     exit 1;
  686. fi;
  687.  
  688.