updates.
[silc.git] / scripts / silcdoc / silcdoc
1 #!/bin/sh
2 #
3 # Author: Pekka Riikonen <priikone@silcnet.org>
4 #
5 # Copyright (C) GNU GPL 2001 Pekka Riikonen
6 #
7 # SILC Toolkit Reference Manual documentation script.  This will automatically
8 # generate documentation from the source tree.  This will require the 
9 # robodoc compiled in util/robodoc and php utility installed in your system.
10 #
11 # This will tarverse the given directory and all subdirectories for the
12 # SILC style header files.  All header files starting with prefix `silc' 
13 # will be checked.  For example, silcpkcs.h.
14 #
15 # Usage: ./sildoc <type> <source directory> <destination directory> <robodoc>
16 #
17 # The <source directory> is the directory where this starts checking for
18 # the headers and will traverse all subdirectories.  The <destination
19 # directory> is the directory to where the documentation is generated.
20 #
21
22 # Arguments checking
23 if [ $# -lt "4" ]; then
24   echo "Usage: ./silcdoc <type> <source directory> <destination directory> <robodoc>"
25   echo "Supported types: HTML"
26 #  echo "Supported types: HTML, ASCII, LATEX or RTF"
27   exit 1
28 fi
29
30 TYPE=$1
31 SRC=$2
32 DST=$3
33 ROBO=$4
34
35 # Get all headers in the source directory
36 headers=`find $SRC -name "silc*.h"`
37
38 #
39 # HTML documentation
40 #
41 if [ "$TYPE" = "HTML" ]; then
42   mkdir /tmp/silcdoc.html
43   cp $headers /tmp/silcdoc.html
44
45   # Generate the first pass of the documentation. This will generate
46   # the HTML from the headers.
47   path=`pwd`
48   cd /tmp/silcdoc.html
49   headers=`find . -name "silc*.h" |cut -d/  -f2 |cut -d.  -f1`
50   cd $path
51   for i in $headers
52   do
53     $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html $TYPE
54
55     # Generate the TOC file
56     sh gen.sh gen_toc.php $DST/$i.html $DST/$i.html
57
58     # Generate the details
59     files=`find $DST -name "silc_*.html"`
60     for k in $files
61     do
62       sh gen.sg gen_detail.php $k $k
63     done
64   done
65
66   # Make the second pass to create the actual layout for the files
67   rm -f $DST/*.tmpl
68   files=`find $DST -name "silc*.html"`
69   for i in $files
70   do
71     sh gen.sh index.php $i $i
72   done
73
74   rm -rf /tmp/silcdoc.html
75   rm -f $DST/tmp.php
76 fi