[GRASS-SVN] r33016 - grass/trunk/tools

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 23 07:05:05 EDT 2008


Author: glynn
Date: 2008-08-23 07:05:05 -0400 (Sat, 23 Aug 2008)
New Revision: 33016

Modified:
   grass/trunk/tools/build_html_index.sh
Log:
Don't replace indices if unchanged
Simplify; use here documents in preference to many "echo"s


Modified: grass/trunk/tools/build_html_index.sh
===================================================================
--- grass/trunk/tools/build_html_index.sh	2008-08-23 11:04:59 UTC (rev 33015)
+++ grass/trunk/tools/build_html_index.sh	2008-08-23 11:05:05 UTC (rev 33016)
@@ -39,34 +39,38 @@
 
 write_html_header()
 {
-# $1: filename
+# $1: not used
 # $2: page title
 # $3: is it main index
-
-echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
+cat <<EOF
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html>
 <head>
  <title>$2</title>
- <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
- <meta name=\"Author\" content=\"GRASS Development Team\">" > "$1"
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="GRASS Development Team">
+EOF
 if [ "$3" ] && [ "$MACOSX" ] ; then
-	echo " <meta name=\"AppleTitle\" content=\"GRASS GIS $GRASSVERSION Help\">
- <meta name=\"AppleIcon\" content=\"GRASS-$GRASS_MMVER/grass_icon.png\">
- <meta name=\"robots\" content=\"anchors\">" >> "$1"
+cat <<EOF
+ <meta name="AppleTitle" content="GRASS GIS $GRASSVERSION Help">
+ <meta name="AppleIcon" content="GRASS-$GRASS_MMVER/grass_icon.png">
+ <meta name="robots" content="anchors">
+EOF
 fi
-echo " <link rel=\"stylesheet\" href=\"grassdocs.css\" type=\"text/css\">
+cat <<EOF
+ <link rel="stylesheet" href="grassdocs.css" type="text/css">
 </head>
-<body bgcolor=\"#FFFFFF\">
+<body bgcolor="#FFFFFF">
 
 <!-- this file is generated by tools/build_html_index.sh -->
 
-<img src=\"grass_logo.png\" alt=\"GRASS logo\"><hr align=center size=6 noshade>
+<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
 
 <h2>GRASS GIS $GRASSVERSION Reference Manual</h2>
 
 <p>
 <em>Geographic Resources Analysis Support System</em>, commonly referred to as
-<a href=\"http://grass.osgeo.org\">GRASS</a>, 
+<a href="http://grass.osgeo.org">GRASS</a>, 
 is a Geographic Information System (GIS) used for geospatial data management
 and analysis, image processing, graphics/maps production, spatial modeling,
 and visualization. GRASS is currently used in academic and commercial settings
@@ -75,80 +79,81 @@
 
 <p>This reference manual details the use of modules distributed with
 Geographic Resources Analysis Support System (GRASS), an open source (GNU
-GPL'ed), image processing and geographic information system (GIS).</p>
+GPLed), image processing and geographic information system (GIS).</p>
 
 <BR><BR>
 <h3>Quick Introduction</h3>
 
 <!-- the files grass7.html & helptext.html file live in lib/init/ -->
 <ul>
-<li><a href=\"grass7.html\">GRASS startup manual page</a></li>
-<li><a href=\"helptext.html\">How to start with GRASS</a></li>
+<li><a href="grass7.html">GRASS startup manual page</a></li>
+<li><a href="helptext.html">How to start with GRASS</a></li>
 <li>Introductions
  <ul>
-  <li><a href=\"rasterintro.html\">2D raster map processing</a></li>
-  <li><a href=\"raster3dintro.html\">3D raster map (voxel) processing</a></li>
-  <li><a href=\"imageryintro.html\">Image processing</a></li>
-  <li><a href=\"databaseintro.html\">Database management</a></li>
-  <li><a href=\"vectorintro.html\">Vector map processing and network analysis</a></li>
-  <li><a href=\"projectionintro.html\">Projections and spatial transformations</a></li>
-  <li><a href=\"sql.html\">SQL support</a></li>
-  <li><a href=\"displaydrivers.html\">Display drivers</a></li>
-  <li><a href=\"variables.html\">GRASS variables and environment variables</a></li>
+  <li><a href="rasterintro.html">2D raster map processing</a></li>
+  <li><a href="raster3dintro.html">3D raster map (voxel) processing</a></li>
+  <li><a href="imageryintro.html">Image processing</a></li>
+  <li><a href="databaseintro.html">Database management</a></li>
+  <li><a href="vectorintro.html">Vector map processing and network analysis</a></li>
+  <li><a href="projectionintro.html">Projections and spatial transformations</a></li>
+  <li><a href="sql.html">SQL support</a></li>
+  <li><a href="displaydrivers.html">Display drivers</a></li>
+  <li><a href="variables.html">GRASS variables and environment variables</a></li>
  </ul>
- <li><a href=\"gem/index.html\">The GRASS Extensions Manager (GEM)</a></li>
+ <li><a href="gem/index.html">The GRASS Extensions Manager (GEM)</a></li>
 </ul>
 <P>
 
-" >> "$1"
+
+EOF
 }
 
 write_html_footer()
 {
-# $1: filename
+# $1: unused
 # $2: help index url
-echo "<BR><BR>
+cat <<EOF
+<BR><BR>
 <hr>
-<p><a href=\"$2\">Help Index</a> | <a href=\"full_index.html\">Full Index</a><br>
-&copy; 2003-2008 <a href=\"http://grass.osgeo.org\">GRASS Development Team</a></p>
+<p><a href="$2">Help Index</a> | <a href="full_index.html">Full Index</a><br>
+&copy; 2003-2008 <a href="http://grass.osgeo.org">GRASS Development Team</a></p>
 </body>
-</html>" >> "$1"
+</html>
+EOF
 }
 
 expand_module_class_name()
 {
 # $1: module class
- if [ "$1" = "d" ]  ; then 
-    echo "display"  
-  elif [ "$1" = "db" ] ; then 
-    echo "database" 
-  elif [ "$1" = "g" ]  ; then 
-    echo "general" 
-  elif [ "$1" = "i" ]  ; then 
-    echo "imagery" 
-  elif [ "$1" = "m" ]  ; then 
-    echo "misc" 
-  elif [ "$1" = "ps" ] ; then 
-    echo "postscript" 
-  elif [ "$1" = "p" ]  ; then 
-    echo "paint" 
-  elif [ "$1" = "r" ]  ; then 
-    echo "raster" 
-  elif [ "$1" = "r3" ]  ; then 
-    echo "raster3D" 
-  elif [ "$1" = "s" ]  ; then 
-    echo "sites" 
-  elif [ "$1" = "v" ]  ; then 
-    echo "vector" 
-  else 
-    echo "$1"
- fi
+case "$1" in
+    d)    echo "display"        ;;
+    db)   echo "database"       ;;
+    g)    echo "general"        ;;
+    i)    echo "imagery"        ;;
+    m)    echo "misc"           ;;
+    ps)   echo "postscript"     ;;
+    p)    echo "paint"          ;;
+    r)    echo "raster"         ;;
+    r3)   echo "raster3D"       ;;
+    s)    echo "sites"          ;;
+    v)    echo "vector"         ;;
+    *)    echo "$1"             ;;
+esac
 }
 
+replace_file()
+{
+# $1: filename
+if [ -f $1 ] && cmp $1.tmp $1 >/dev/null ; then
+    rm $1.tmp
+else
+    mv $1.tmp $1
+fi
+}
+
 #are we in the tools/ dir?
-ls build_html_index.sh 2> /dev/null
-if [ $? -eq 1 ] ; then
- echo "ERROR: this script must be run from the tools/ directory"
+if [ ! -f build_html_index.sh ] ; then
+ echo "ERROR: this script must be run from the tools/ directory" >&2
  exit 1
 fi
 
@@ -183,63 +188,76 @@
   grep -v gis.m.html | grep -v "\($EXCLUDEHTML\)" | cut -d'.' -f1 | sort -u`
 CMDLISTNO=`echo $CMDLIST | wc -w | awk '{print $1}'`
 
-#write main index:
-echo "Generating HTML manual pages index (help system)..."
-write_html_header $FULLINDEX "GRASS GIS $GRASSVERSION Reference Manual: Full index"
-echo "<BR><h3>Full command index:</h3>" >> $FULLINDEX
-echo "<table border=0>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;d.*  </td><td>display commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;db.* </td><td>database commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;g.*  </td><td>general commands</td></tr>" >> $FULLINDEX
-#echo "<tr><td>&nbsp;&nbsp;g3.* </td><td>general3D commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;i.*  </td><td>imagery commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;m.*  </td><td>miscellaneous commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;ps.* </td><td>postscript commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;r.*  </td><td>raster commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;r3.* </td><td>raster3D commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;v.*  </td><td>vector commands</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;<a href=\"gis.m.html\">gis.m</a> </td><td>GUI frontend to GIS menus and display</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;<a href=\"nviz.html\">nviz</a> </td><td>visualization suite</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;<a href=\"wxGUI.html\">wxGUI</a> </td><td>wxPython-based GUI frontend</td></tr>" >> $FULLINDEX
-echo "<tr><td>&nbsp;&nbsp;<a href=\"xganim.html\">xganim</a> </td><td>raster map slideshow</td></tr>" >> $FULLINDEX
-echo "</table>" >> $FULLINDEX
+echo "Generating HTML manual pages index (help system)..." >&2
 
+###############################################################################
+
+#begin full index:
+(
+write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: Full index"
+
+cat <<EOF
+<BR><h3>Full command index:</h3>
+<table border=0>
+<tr><td>&nbsp;&nbsp;d.*  </td><td>display commands</td></tr>
+<tr><td>&nbsp;&nbsp;db.* </td><td>database commands</td></tr>
+<tr><td>&nbsp;&nbsp;g.*  </td><td>general commands</td></tr>
+<tr><td>&nbsp;&nbsp;i.*  </td><td>imagery commands</td></tr>
+<tr><td>&nbsp;&nbsp;m.*  </td><td>miscellaneous commands</td></tr>
+<tr><td>&nbsp;&nbsp;ps.* </td><td>postscript commands</td></tr>
+<tr><td>&nbsp;&nbsp;r.*  </td><td>raster commands</td></tr>
+<tr><td>&nbsp;&nbsp;r3.* </td><td>raster3D commands</td></tr>
+<tr><td>&nbsp;&nbsp;v.*  </td><td>vector commands</td></tr>
+<tr><td>&nbsp;&nbsp;<a href="gis.m.html">gis.m</a> </td><td>GUI frontend to GIS menus and display</td></tr>
+<tr><td>&nbsp;&nbsp;<a href="nviz.html">nviz</a> </td><td>visualization suite</td></tr>
+<tr><td>&nbsp;&nbsp;<a href="wxGUI.html">wxGUI</a> </td><td>wxPython-based GUI frontend</td></tr>
+<tr><td>&nbsp;&nbsp;<a href="xganim.html">xganim</a> </td><td>raster map slideshow</td></tr>
+</table>
+EOF
+
 #generate main index of all modules:
-echo "<BR><BR>[ " >> $FULLINDEX
+echo "<BR><BR>[ "
 k=0
 for i in $CMDLIST
 do
   k=`expr $k + 1`
-  echo -n "<b><a href=\"#$i\">$i.*</a></b>" >> $FULLINDEX
+  echo -n "<b><a href=\"#$i\">$i.*</a></b>"
   if [ $k -lt $CMDLISTNO ] ; then
-     echo -n " | " >> $FULLINDEX
+     echo -n " | "
   fi
 done
 
-echo " ]
-<BR>
-" >> $FULLINDEX
+echo " ]"
+echo "<BR>"
+echo ""
 
 #for all module groups:
 for i in $CMDLIST
 do 
-  echo "<a name=\"$i\"></a>" >> $FULLINDEX
-  echo "<BR><BR><h3>$i.* commands:</h3>" >> $FULLINDEX
-  echo "<table>" >> $FULLINDEX
+cat <<-EOF
+	<a name="$i"></a>
+	<BR><BR><h3>$i.* commands:</h3>
+	<table>
+EOF
 
   #for all modules:  
   for i in `ls -1 $i.*.html | grep -v "\($EXCLUDEHTML\)"`
   do
     BASENAME=`basename $i .html`
     SHORTDESC="`cat $i | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
-    echo "<tr><td valign="top"><a href=\"$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FULLINDEX
+    echo "<tr><td valign=\"top\"><a href=\"$i\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>"
   done
-  echo "</table>" >> $FULLINDEX
+  echo "</table>"
 done
 
-write_html_footer $FULLINDEX index.html
+write_html_footer - index.html
+) > $FULLINDEX.tmp
+replace_file $FULLINDEX
+
 # done full index
 
+###############################################################################
+
 #next write separate module pages:
 #for all module groups:
 for k in $CMDLIST
@@ -247,54 +265,60 @@
   MODCLASS=`expand_module_class_name $k`
   FILENAME=$MODCLASS.html
 
-  write_html_header $FILENAME "GRASS GIS $GRASSVERSION Reference Manual: $MODCLASS"
-  echo "<b>$MODCLASS commands:</b>" >> $FILENAME
-  echo "<table>" >> $FILENAME
+  (
+  write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: $MODCLASS"
+  echo "<b>$MODCLASS commands:</b>"
+  echo "<table>"
   #for all modules:
   for k in `ls -1 $k.*.html | grep -v "\($EXCLUDEHTML\)"`
   do
     BASENAME=`basename $k .html`
     SHORTDESC="`cat $k | awk '/NAME/,/SYNOPSIS/' | grep '<em>' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
-    echo "<tr><td valign="top"><a href=\"$k\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>" >> $FILENAME
+    echo "<tr><td valign=\"top\"><a href=\"$k\">$BASENAME</a></td> <td>$SHORTDESC</td></tr>"
   done
   
-  echo "</table>" >> $FILENAME
+  echo "</table>"
 
-  write_html_footer $FILENAME index.html
+  write_html_footer - index.html
+  ) > $FILENAME.tmp
+  replace_file $FILENAME
 done
 
+###############################################################################
+
 #next write main page:
 FILENAME=index.html
-write_html_header $FILENAME "GRASS GIS $GRASSVERSION Reference Manual" 1
+(
+write_html_header - "GRASS GIS $GRASSVERSION Reference Manual" 1
 
 #modules:
-echo "<h3>Manual sections:</h3>" >> $FILENAME
-echo "<ul>" >> $FILENAME
+echo "<h3>Manual sections:</h3>"
+echo "<ul>"
 #for all module groups:
 for k in $CMDLIST
 do 
   MODCLASS=`expand_module_class_name $k`
-  echo "<li><a href=\"$MODCLASS.html\">$MODCLASS commands</a></li>" >> $FILENAME
+  echo "<li><a href=\"$MODCLASS.html\">$MODCLASS commands</a></li>"
 done
 
 #extra stuff for 'nviz' and 'xganim' and GUIs:
-echo "<li><a href=\"gis.m.html\">gis.m</a> and <a href=\"d.m.html\">d.m</a> GIS managers</li>" >> $FILENAME
-echo "<li><a href=\"nviz.html\">nviz</a> visualization and animation tool</li>" >> $FILENAME
-echo "<li><a href=\"wxGUI.html\">wxGUI</a> wxPython-based GUI frontend</li>" >> $FILENAME
-echo "<li><a href=\"xganim.html\">xganim</a> tool  for animating a raster map series</li>" >> $FILENAME
-	      
-echo "</ul>" >> $FILENAME
+cat <<EOF
+<li><a href="gis.m.html">gis.m</a> and <a href="d.m.html">d.m</a> GIS managers</li>
+<li><a href="nviz.html">nviz</a> visualization and animation tool</li>
+<li><a href="wxGUI.html">wxGUI</a> wxPython-based GUI frontend</li>
+<li><a href="xganim.html">xganim</a> tool  for animating a raster map series</li>
+</ul>
 
-#insert a special comment so that GEM will know where to merge docs of extensions
-echo >> "$FILENAME"
-echo "<!-- GEM Extensions StartHTML. Do not delete or change this comment! -->" >> "$FILENAME"
-echo >> "$FILENAME"
+<!-- GEM Extensions StartHTML. Do not delete or change this comment! -->
 
+EOF
 
-#############
-write_html_footer $FILENAME index.html
+write_html_footer - index.html
+) > $FILENAME.tmp
+replace_file $FILENAME
 
-#############
+###############################################################################
+
 echo "Generated HTML docs in $HTMLDIR/index.html"
 echo "----------------------------------------------------------------------"
 echo "Following modules are missing the 'description.html' file in src code:"



More information about the grass-commit mailing list