#!/bin/tcsh
# This script generates a doxygen style index file for C applications.
# It will work on all C files in a directory.

set fn = tmp1.doc
set idx = tmp2.doc

if ($#argv < 1) then
  echo "Usage: appdoc output_filename"
  exit
endif

set main = $1

echo "/** \page wrappage Wrappers" > $idx

echo "\section wrap Wrapper Application" >> $idx

echo " " >> $idx
echo "<ul>" >> $idx

foreach i (*.c)

  echo "Processing $i"

  echo "<li>\ref $i:r</li>" >> $idx

  echo -n "\subsection " >> $fn
  echo $i:r $i:r >> $fn

  cat $i | mawk ' BEGIN { RS = "\*/" } { if ($1 == "/**") print $0 } ' | sed -e "s/\/\*\*//" | grep -v \class | grep -v Usage >> $fn

  echo "\verbatim" >> $fn
  ./$i:r -h >>& $fn
  echo "\endverbatim" >> $fn

  echo "More details: $i:r" >> $fn

  echo " " >> $fn

end

echo "</ul>" >> $idx
echo "<hr> " >> $idx

echo "*/" >> $fn

cat $idx $fn > $main
\rm -f $fn $idx 
