#!/bin/sh
#generates user addon HTML man pages docs/html/index.html
# Markus Neteler, 2003, 2004, 2005, 2006
# William Kyngesburye:
# This one builds the addon index, from both the global
# /Library/GRASS/$GRASS_MMVER/Modules and the user's
# $HOME/Library/$GRASS_MMVER/GRASS/Modules
# Each is in their own section, in the same index file.
#
# global help pages are symlinked to the user dir, so user doesn't need perms
# to write there for redirects.
# main and section indexes from GRASS.app are redirected from user dir, not
# symlinked, so relative paths stay valid.
############# nothing to configure below ############
# $1 is current path to GRASS.app/Contents/MacOS, defaults to /Applications
if [ "$1" != "" ] ; then
GISBASE=$1
else
GISBASE="/Applications/GRASS-$GRASS_MMVER.app/Contents/MacOS"
fi
GRASS_MMVER=`cut -d . -f 1-2 "$GISBASE/etc/VERSIONNUMBER"`
GRASSVERSION=`cat "$GISBASE/etc/VERSIONNUMBER"`
HTMLDIR="$GISBASE_USER/Modules/docs/html"
HTMLDIRG="$GISBASE_SYSTEM/Modules/docs/html"
write_html_header()
{
# $1: filename
# $2: page title
# $3: is it main index
echo "
$2
" > $1
if [ "$3" ] ; then
echo "
" >> $1
fi
echo "
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
GPL'ed), image processing and geographic information system (GIS).
" >> $1
echo "" >> $1
echo "" >> $1
}
FULLINDEX=addon_index.html
################
echo "Rebuilding Addon HTML manual pages index..."
#copy over CSS:
cp -f "$GISBASE/docs/html/grassdocs.css" "$HTMLDIR/"
#copy over GRASS logo:
cp -f "$GISBASE/docs/html/grass_logo.png" "$HTMLDIR/"
cp -f "$GISBASE/docs/html/grass_icon.png" "$HTMLDIR/"
#process all global HTML pages:
if [ -d "$HTMLDIRG" ] ; then
cd "$HTMLDIRG"
#get list of available GRASS modules:
CMDLISTG=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
else
CMDLISTG=""
fi
#process all user HTML pages:
cd "$HTMLDIR"
# don't really need to delete these, as removed global modules won't get indexed,
# though old symlinks will accumulate. I'm just worried about wildcard deletes.
#rm -f global_*.html
#get list of available GRASS modules:
CMDLIST=`ls -1 *.*.html 2> /dev/null | grep -v index.html | cut -d'.' -f1 | sort -u`
#write main index:
#echo "Generating HTML manual pages index (help system)..."
write_html_header $FULLINDEX "GRASS GIS $GRASSVERSION Addon Reference Manual" 1
echo "
Command guide:
" >> $FULLINDEX
echo "
" >> $FULLINDEX
echo "
d.*
display commands
ps.*
postscript commands
" >> $FULLINDEX
echo "
db.*
database commands
r.*
raster commands
" >> $FULLINDEX
echo "
g.*
general commands
r3.*
raster3D commands
" >> $FULLINDEX
echo "
i.*
imagery commands
v.*
vector commands
" >> $FULLINDEX
echo "
m.*
miscellaneous commands
" >> $FULLINDEX
echo "
" >> $FULLINDEX
# global commands:
echo "
Global addon command index:
" >> $FULLINDEX
echo "
" >> $FULLINDEX
if [ "$CMDLISTG" = "" ] ; then
echo "
[There are no global addon help pages.]
" >> $FULLINDEX
else
for i in $CMDLISTG
do
cd "$HTMLDIRG"
CMDLISTI="`ls -1 $i.*.html`"
cd "$HTMLDIR"
for i in $CMDLISTI
do
BASENAME=`basename $i .html`
SHORTDESC="`cat "$HTMLDIRG/$i" | awk '/NAME/,/SYNOPSIS/' | grep '' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
# echo "
" >> $FULLINDEX
if [ "$CMDLIST" = "" ] ; then
echo "
[There are no user addon help pages.]
" >> $FULLINDEX
else
for i in $CMDLIST
do
for i in `ls -1 $i.*.html`
do
BASENAME=`basename $i .html`
SHORTDESC="`cat $i | awk '/NAME/,/SYNOPSIS/' | grep '' | cut -d'-' -f2- | sed 's+^ ++g' | grep -vi 'SYNOPSIS' | head -n 1`"
echo "
" >> $FULLINDEX
write_html_footer $FULLINDEX
# done full index
# user redirects to app dir for main index files
for i in index full_index display database general imagery misc postscript raster raster3D vector
do
echo "
" > $i.html
done
# add Help Viewer links in user docs folder
mkdir -p $HOME/Library/Documentation/Help/
ln -sfh ../../GRASS/$GRASS_MMVER/Modules/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER-addon
ln -sfh $GISBASE/docs/html $HOME/Library/Documentation/Help/GRASS-$GRASS_MMVER