Added cross-reference support for document generator.
[silc.git] / scripts / silcdoc / silcdoc
index c66ba886503d2fa0ce9d6cd2ee4041f19a708218..61851b89030ffc15debb8ab8b41b55b9d72b05de 100755 (executable)
@@ -35,13 +35,79 @@ ROBO=$4
 # Get all headers in the source directory
 headers=`find $SRC -name "silc*.h"`
 
+#
+# ASCII documentation
+#
+#if [ "$TYPE" = "ASCII" ]; then
+#
+#fi
+
 #
 # HTML documentation
 #
 if [ "$TYPE" = "HTML" ]; then
+  rm -rf /tmp/silcdoc.html
+  rm -rf /tmp/silcdoc_html.html
   mkdir /tmp/silcdoc.html
+  mkdir /tmp/silcdoc_html.html
   cp $headers /tmp/silcdoc.html
 
+  # Generate index template from the DIRECTORY files. The template for
+  # the generated index template is INDEX.tmpl.
+  files=`find $SRC -name "DIRECTORY"`
+  for i in $files
+  do
+    # Get library name
+    name=`grep "@LIBRARY=" $i |cut -d=  -f2`
+    fname=`grep "@FILENAME=" $i |cut -d=  -f2`
+    links=`grep "@LINK=" $i |cut -d=  -f2 |cut -d:  -f1`
+
+    # Generate links to template file that can be included into various
+    # places on the webpage.
+    echo "<a href="$fname"><img src="box.gif" border="0" alt="">$name</a><br />" >>$DST/index.tmpl
+    for k in $links
+    do
+      n=`grep $k $i |cut -d=  -f2 |cut -d:  -f2`
+      echo "<li><a href="$k">$n</a>" >>$DST/$fname.links
+      echo "&nbsp;&nbsp;&nbsp; <a href="$k"><img src="box2.gif" border="0" alt="">$n</a><br />" >>$DST/index.tmpl
+    done
+  done
+  # Now get the template for the link template, and generate the final index
+  # template file
+  temp=`find $SRC -name "INDEX.tmpl"`
+  sed -e "/@BODY@/ r $DST/index.tmpl" -e s/@BODY@//g $temp >$DST/index.tmpl.tmp
+  mv $DST/index.tmpl.tmp $DST/index.tmpl
+
+  # Copy all HTML files to destination
+  htmlfiles=`find $SRC -name "*.html"`
+  for i in $htmlfiles
+  do
+    cp $i /tmp/silcdoc_html.html
+  done
+  path=`pwd`
+  cd /tmp/silcdoc_html.html
+  htmlfiles=`find . -name "*.html" | cut -d/  -f2`
+  cd $path
+  for i in $htmlfiles
+  do
+    # Generate the details and the layout
+    f="/tmp/silcdoc_html.html/$i"
+    sh gen.sh $DST gen_index.php 1 $f $f
+    cp /tmp/silcdoc_html.html/$i $DST
+  done
+
+  # Generate cross reference files
+  path=`pwd`
+  cd /tmp/silcdoc.html
+  headers=`find . -name "silc*.h" |cut -d/  -f2 |cut -d.  -f1`
+  cd $path
+  touch $DST/silcdoc_xref
+  for i in $headers
+  do
+    $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html $TYPE GENXREF $DST/$i.xref
+    echo $DST/$i.xref >>$DST/silcdoc_xref
+  done
+
   # Generate the actual detailed documentation
   path=`pwd`
   cd /tmp/silcdoc.html
@@ -49,62 +115,48 @@ if [ "$TYPE" = "HTML" ]; then
   cd $path
   for i in $headers
   do
-    $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html $TYPE
+    $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html XREF $DST/silcdoc_xref $TYPE
 
     # Generate the TOC file
-    sh gen.sh gen_toc.php $DST/$i.html $DST/$i.html
-    sh gen.sh index.php $DST/$i.html $DST/$i.html
+    sh gen.sh $DST gen_index.php 1 $DST/$i.html $DST/$i.html
 
-    # Generate the details and the layour
-    files=`find $DST -name ""$i"_*.html"`
+    # Generate the details and the layout
+    files=`find $DST -name ""$i"-*.html"`
     for k in $files
     do
-      sh gen.sh gen_detail.php $k $k
-      sh gen.sh index.php $k $k
+      sh gen.sh $DST gen_index.php 0 $k $k
     done
 
-    rm -f $DST/$i_index.tmpl
+    rm -f $DST/$i-index.tmpl
   done
 
   # Generate the index and TOC files from the DIRECTORY files
   files=`find $SRC -name "DIRECTORY"`
-  touch $DST/index.html.tmp
   for i in $files
   do
     # Get library name
     name=`grep "@LIBRARY=" $i |cut -d=  -f2`
     fname=`grep "@FILENAME=" $i |cut -d=  -f2`
-    links=`grep "@LINK=" $i |cut -d=  -f2 |cut -d:  -f1`
-
-    # Generate links to template file that can be included into various
-    # places on the webpage.
-    echo ">> <A HREF="$fname">$name</A>" >>$DST/index.tmpl
 
     # Generate links for this library
-    for k in $links
-    do
-      n=`grep $k $i |cut -d=  -f2 |cut -d:  -f2`
-      echo "<LI><A HREF="$k">$n</A>" >>$DST/$fname.links
-      echo "&nbps;&nbsp;> <A HREF="$k">$n</A>" >>$DST/index.tmpl
-    done
     sed -e "/@LINKS@/ r $DST/$fname.links" -e s/@LINKS@//g $i >$DST/$fname
 
     # Generate the TOC file for the library
-    sh gen.sh gen_toc.php $DST/$fname $DST/$fname
-    sh gen.sh index.php $DST/$fname $DST/$fname
+    sh gen.sh $DST gen_index.php 1 $DST/$fname $DST/$fname
 
     # Generate the link for the top index.html for this library
-    echo "<LI><A HREF="$fname">$name</A>" >>$DST/index.html.tmp
+    echo "<li><a href="$fname">$name</a>" >>$DST/index.html.tmp
     rm -f $DST/$fname.links
   done
 
   # Generate the top index.html file
   index=`find $SRC -name "LIBINDEX"`
+  version=`grep SILC_VERSION_STRING $SRC/../includes/version_internal.h |cut -d\"  -f2`
   curdate=`date`
-  sed -e "/@DATE@/s//$curdate/" -e "/@BODY@/ r $DST/index.html.tmp" -e s/@BODY@//g $index >$DST/index.html
-  sh gen.sh gen_toc.php $DST/index.html $DST/index.html
-  sh gen.sh index.php $DST/index.html $DST/index.html
+  sed -e "/@VERSION@/s//$version/" -e "/@DATE@/s//$curdate/" -e "/@BODY@/ r $DST/index.html.tmp" -e s/@BODY@//g $index >$DST/index.html
+  sh gen.sh $DST gen_index.php 2 $DST/index.html $DST/index.html
 
   rm -rf $DST/index.html.tmp
   rm -rf /tmp/silcdoc.html
+  rm -rf /tmp/silcdoc_html.html
 fi