texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo ChangeLog util/gendocs.sh


From: karl
Subject: texinfo ChangeLog util/gendocs.sh
Date: Sat, 27 Oct 2012 18:26:39 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     karl <karl>     12/10/27 18:26:38

Modified files:
        .              : ChangeLog 
        util           : gendocs.sh 

Log message:
        include images in split HTML

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/ChangeLog?cvsroot=texinfo&r1=1.1429&r2=1.1430
http://cvs.savannah.gnu.org/viewcvs/texinfo/util/gendocs.sh?cvsroot=texinfo&r1=1.42&r2=1.43

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/texinfo/texinfo/ChangeLog,v
retrieving revision 1.1429
retrieving revision 1.1430
diff -u -b -r1.1429 -r1.1430
--- ChangeLog   23 Oct 2012 23:36:22 -0000      1.1429
+++ ChangeLog   27 Oct 2012 18:26:38 -0000      1.1430
@@ -1,7 +1,9 @@
-2012-10-23  Akim Demaille  <address@hidden>
+2012-10-27  Akim Demaille  <address@hidden>
+        and Karl Berry  <address@hidden>
 
-       * util/gendocs.sh (-I): new option, passed along to the tools.
-       (mail of 23 Oct 2012 16:27:19)
+       * util/gendocs.sh (copy_images): new function, Perl code to
+       extract images from output HTML and copy them to the output dir.
+       (mail of 26 Oct 2012 09:39:53).
 
 2012-09-23  Karl Berry  <address@hidden>
 

Index: util/gendocs.sh
===================================================================
RCS file: /sources/texinfo/texinfo/util/gendocs.sh,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- util/gendocs.sh     23 Oct 2012 23:36:22 -0000      1.42
+++ util/gendocs.sh     27 Oct 2012 18:26:38 -0000      1.43
@@ -2,7 +2,7 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2012-10-23.16
+scriptversion=2012-10-27.11
 
 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 # Free Software Foundation, Inc.
@@ -30,6 +30,13 @@
 #
 # An up-to-date copy is also maintained in Gnulib (gnu.org/software/gnulib).
 
+# TODO:
+# - image importation was only implemented for HTML generated by
+#   makeinfo.  But it should be simple enough to adjust.
+# - images are not imported in the source tarball.  All the needed
+#   formats (PDF, PNG, etc.) should be included.
+# - remove PS support (including in the doc templates)
+
 prog=`basename "$0"`
 srcdir=`pwd`
 
@@ -45,6 +52,7 @@
 : ${DOCBOOK2PS="docbook2ps"}
 : ${DOCBOOK2TXT="docbook2txt"}
 : ${GENDOCS_TEMPLATE_DIR="."}
+: ${PERL='perl'}
 : ${TEXI2HTML="texi2html"}
 unset CDPATH
 unset use_texi2html
@@ -108,8 +116,8 @@
 As implied above, by default monolithic Info files are generated.
 If you want split Info, or other Info options, use --info to override.
 
-You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML, and
-DVIPS to control the programs that get executed, and
+You can set the environment variables MAKEINFO, TEXI2DVI, TEXI2HTML,
+DVIPS, and PERL to control the programs that get executed, and
 GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is
 looked for.  With --docbook, the environment variables DOCBOOK2HTML,
 DOCBOOK2PDF, DOCBOOK2PS, and DOCBOOK2TXT are also respected.
@@ -122,16 +130,11 @@
 Email bug reports or enhancement requests to address@hidden
 "
 
-calcsize()
-{
-  size=`ls -ksl $1 | awk '{print $1}'`
-  echo $size
-}
-
 MANUAL_TITLE=
 PACKAGE=
 address@hidden  # please override with --email
 commonarg= # Options passed to all the tools (-I dir).
+dirs=      # -I's directories.
 htmlarg=
 infoarg=--no-split
 outdir=manual
@@ -144,7 +147,7 @@
     --version) echo "$version"; exit 0;;
     -s) shift; srcfile=$1;;
     -o) shift; outdir=$1;;
-    -I) shift; commonarg="$commonarg -I '$1'";;
+    -I) shift; commonarg="$commonarg -I '$1'"; dirs="$dirs $1";;
     --docbook) docbook=yes;;
     --html) shift; htmlarg=$1;;
     --info) shift; infoarg=$1;;
@@ -193,6 +196,55 @@
   exit 1
 fi
 
+# Function to return size of $1 in something resembling kilobytes.
+calcsize()
+{
+  size=`ls -ksl $1 | awk '{print $1}'`
+  echo $size
+}
+
+# copy_images OUTDIR HTML-FILE...
+# -------------------------------
+# Copy all the images needed by the HTML-FILEs into OUTDIR.  Look
+# for them in the -I directories.
+copy_images()
+{
+  local odir
+  odir=$1
+  shift
+  $PERL -n -e "
+BEGIN {
+  \$me = '$prog';
+  \$odir = '$odir';
+  @dirs = qw($dirs);
+}
+" -e '
+/<img src="(.*?)"/g && ++$need{$1};
+
+END {
+  #print "$me: @{[keys %need]}\n";  # for debugging, show images found.
+  FILE: for my $f (keys %need) {
+    for my $d (@dirs) {
+      if (-f "$d/$f") {
+        use File::Basename;
+        my $dest = dirname ("$odir/$f");
+        #
+        use File::Path;
+        -d $dest || mkpath ($dest)
+          || die "$me: cannot mkdir $dest: $!\n";
+        #
+        use File::Copy;
+        copy ("$d/$f", $dest)
+          || die "$me: cannot copy $d/$f to $dest: $!\n";
+        next FILE;
+      }
+    }
+    die "$me: $ARGV: cannot find image $f\n";
+  }
+}
+' -- "$@" || exit 1
+}
+
 case $outdir in
   /*) abs_outdir=$outdir;;
   *)  abs_outdir=$srcdir/$outdir;;
@@ -268,6 +320,7 @@
   html_mono_size=`calcsize $PACKAGE.html`
   gzip -f -9 -c $PACKAGE.html >"$outdir/$PACKAGE.html.gz"
   html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
+  copy_images "$outdir/" $PACKAGE.html
   mv $PACKAGE.html "$outdir/"
 
   opt="--html -o $PACKAGE.html $commonarg $htmlarg"
@@ -275,15 +328,14 @@
   echo "Generating html by node... ($cmd)"
   eval "$cmd"
   split_html_dir=$PACKAGE.html
+  copy_images $split_html_dir/ $split_html_dir/*.html
   (
-   cd ${split_html_dir} || exit 1
-   tar -czf "$abs_outdir/${PACKAGE}.html_node.tar.gz" -- *.html
+    cd $split_html_dir || exit 1
+    tar -czf "$abs_outdir/$PACKAGE.html_node.tar.gz" -- *
   )
-  html_node_tgz_size=`calcsize "$outdir/${PACKAGE}.html_node.tar.gz"`
-  rm -f "$outdir"/html_node/*.html
-  mkdir -p "$outdir/html_node/"
-  mv ${split_html_dir}/*.html "$outdir/html_node/"
-  rmdir ${split_html_dir}
+  html_node_tgz_size=`calcsize "$outdir/$PACKAGE.html_node.tar.gz"`
+  rm -rf "$outdir/html_node/"
+  mv $split_html_dir "$outdir/html_node/"
 else
   opt="--output $PACKAGE.html $commonarg $htmlarg"
   cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""



reply via email to

[Prev in Thread] Current Thread [Next in Thread]