#!/bin/sh #generates HTML man pages docs/html/index.html # Markus Neteler, 2003, 2004, 2005, 2006 ## TODO: better fix this in include/Make/Html.make, see bug #5361 #exclude following list of modules from help index: EXCLUDEMODS="\ v.topo.check \ i.ask \ i.find \ helptext.html \ r.watershed.ram \ r.watershed.seg \ wxGUI.*" # these modules don't use G_parser() check_for_desc_override() { case "$BASENAME" in g.parser) SHORTDESC="Provides automated parser, GUI, and help support for GRASS scipts." ;; r.li.daemon) SHORTDESC="Support module for r.li landscape index calculations." ;; esac } ############# nothing to configure below ############ # regex-proof module skip list EXCLUDEHTML="`echo "$EXCLUDEMODS" | tr ' ' '|' | sed -e 's+\.+\\\\.+g' -e 's+|+\\\\|+g'`" #fetch the ARCH for store the files: ARCH="`cat ../include/Make/Platform.make | grep '^ARCH' | sed 's+ ++g' | cut -d'=' -f2`" GEMDIR="../gem" HTMLDIR="../dist.$ARCH/docs/html" GRASSVERSION=`cat ../dist.$ARCH/etc/VERSIONNUMBER` GRASS_MMVER=`cut -d . -f 1-2 ../dist.$ARCH/etc/VERSIONNUMBER` MACOSX=`echo $ARCH | grep -i darwin` write_html_header() { # $1: not used # $2: page title # $3: is it main index cat < $2 EOF if [ "$3" ] && [ "$MACOSX" ] ; then cat < EOF fi cat < GRASS logo

GRASS GIS $GRASSVERSION Reference Manual

Geographic Resources Analysis Support System, commonly referred to as GRASS, 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 around the world, as well as by many governmental agencies and environmental consulting companies.

This reference manual details the use of modules distributed with Geographic Resources Analysis Support System (GRASS), an open source (GNU GPLed), image processing and geographic information system (GIS).



Quick Introduction

EOF } write_html_footer() { # $1: unused # $2: help index url cat <


Help Index | Full Index
© 2003-2008 GRASS Development Team

EOF } expand_module_class_name() { # $1: module class 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? if [ ! -f build_html_index.sh ] ; then echo "ERROR: this script must be run from the tools/ directory" >&2 exit 1 fi FULLINDEX=full_index.html ################ #copy over CSS: cp -f grassdocs.css $HTMLDIR/ mkdir -p $HTMLDIR/nviz/ cp -f grassdocs.css $HTMLDIR/nviz/ chmod a+r $HTMLDIR/grassdocs.css $HTMLDIR/nviz/grassdocs.css #copy over GRASS logo: cp -f grass_logo.png $HTMLDIR/ cp -f grass_logo.png $HTMLDIR/nviz/ chmod a+r $HTMLDIR/grass_logo.png $HTMLDIR/nviz/grass_logo.png if [ "$MACOSX" ] ; then cp -f grass_icon.png $HTMLDIR/ chmod a+r $HTMLDIR/grass_icon.png fi #copy over GEM docs: mkdir -p $HTMLDIR/gem cp -f $GEMDIR/docs/GEM-Manual/*.html $HTMLDIR/gem/ cp -f $GEMDIR/docs/GEM-Manual/img* $HTMLDIR/gem/ chmod a+r $HTMLDIR/gem/*.html $HTMLDIR/gem/img* #process all HTML pages: cd "$HTMLDIR" #get list of available GRASS modules: CMDLIST=`ls -1 *.*.html | grep -v "$FULLINDEX" | grep -v index.html | \ grep -v "\($EXCLUDEHTML\)" | cut -d'.' -f1 | sort -u` CMDLISTNO=`echo $CMDLIST | wc -w | awk '{print $1}'` echo "Generating HTML manual pages index (help system)..." >&2 ############################################################################### #begin full index: ( write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: Full index" cat <

Full command index:

  d.* display commands
  db.* database commands
  g.* general commands
  i.* imagery commands
  m.* miscellaneous commands
  ps.* postscript commands
  r.* raster commands
  r3.* raster3D commands
  v.* vector commands
  nviz visualization suite
  wxGUI wxPython-based GUI frontend
  xganim raster map slideshow
EOF #generate main index of all modules: echo "

[ " k=0 for i in $CMDLIST do k=`expr $k + 1` echo -n "$i.*" if [ $k -lt $CMDLISTNO ] ; then echo -n " | " fi done echo " ]" echo "
" echo "" #for all module groups: for i in $CMDLIST do cat <<-EOF

$i.* commands:

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 '' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`" check_for_desc_override echo "" done echo "
$BASENAME $SHORTDESC
" done 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 do MODCLASS=`expand_module_class_name $k` FILENAME="$MODCLASS.html" ( write_html_header - "GRASS GIS $GRASSVERSION Reference Manual: $MODCLASS" echo "$MODCLASS commands:" echo "" #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 '' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`" check_for_desc_override echo "" done echo "
$BASENAME $SHORTDESC
" write_html_footer - index.html ) > "$FILENAME.tmp" replace_file "$FILENAME" done ############################################################################### #next write main page: FILENAME=index.html ( write_html_header - "GRASS GIS $GRASSVERSION Reference Manual" 1 #modules: echo "

Manual sections:

" echo "
    " #for all module groups: for k in $CMDLIST do MODCLASS=`expand_module_class_name $k` echo "
  • $MODCLASS commands
  • " done #extra stuff for 'nviz' and 'xganim' and GUI: cat <nviz visualization and animation tool
  • wxGUI wxPython-based GUI frontend
  • xganim tool for animating a raster map series
EOF 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:" for i in `find . -name "*.*.html" | sort | grep -v "$FULLINDEX" | grep -v 'index.html' | grep -v "$EXCLUDEHTML"` do if grep 'DESCRIPTION' $i >/dev/null 2>&1 ; then : else echo `echo $i | sed 's?./??' | sed 's/.html//'` fi done echo "----------------------------------------------------------------------"