3 # Author: Pekka Riikonen <priikone@silcnet.org>
5 # Copyright (C) GNU GPL 2001 - 2002 Pekka Riikonen
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.
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.
15 # Usage: ./sildoc <type> <source directory> <destination directory> <robodoc>
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.
23 if [ $# -lt "4" ]; then
24 echo "Usage: ./silcdoc <type> <source directory> <destination directory/file> <robodoc>"
25 echo "Supported types: HTML PS"
26 # echo "Supported types: HTML, ASCII, LATEX or RTF"
35 # Get all headers in the source directory
36 headers=`find $SRC -name "silc*.h"`
39 # PS documentation (from LATEX)
41 if [ "$TYPE" = "PS" ]; then
43 rm -rf /tmp/silcdoc.tex
44 mkdir /tmp/silcdoc.tex
45 cp $headers /tmp/silcdoc.tex
50 # Generate cross reference files
51 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
55 $ROBO $i.h $i.h.tex $TYPE INTERNAL GENXREF $i.h.xref
56 echo $i.h.xref >>silcdoc_xref
59 # Generate the detailed documentation
60 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
65 $ROBO $i.h $i.h.tex XREF silcdoc_xref $TYPE C SORT NOSOURCE SINGLEDOC
69 $ROBO silcdoc_xref toolkit_mi INDEX $TYPE TITLE "SILC Toolkit Reference Manual"
71 # Generate the postscript
76 dvips toolkit_mi.dvi -o $DST
80 rm -rf /tmp/silcdoc.tex
86 #if [ "$TYPE" = "ASCII" ]; then
93 if [ "$TYPE" = "HTML" ]; then
94 rm -rf /tmp/silcdoc.html
95 rm -rf /tmp/silcdoc_html.html
96 mkdir /tmp/silcdoc.html
97 mkdir /tmp/silcdoc_html.html
98 cp $headers /tmp/silcdoc.html
100 # Generate index template from the DIRECTORY files. The template for
101 # the generated index template is INDEX.tmpl.
102 files=`find $SRC -name "DIRECTORY"`
106 name=`grep "@LIBRARY=" $i |cut -d= -f2`
107 fname=`grep "@FILENAME=" $i |cut -d= -f2`
108 links=`grep "@LINK=" $i |cut -d= -f2 |cut -d: -f1`
110 # Generate links to template file that can be included into various
111 # places on the webpage.
112 echo "<a href="$fname"><img src="box.gif" border="0" alt="">$name</a><br />" >>$DST/index.tmpl
115 n=`grep $k $i |cut -d= -f2 |cut -d: -f2`
116 echo "<li><a href="$k">$n</a>" >>$DST/$fname.links
117 echo " <a href="$k"><img src="box2.gif" border="0" alt="">$n</a><br />" >>$DST/index.tmpl
120 # Now get the template for the link template, and generate the final index
122 temp=`find $SRC -name "INDEX.tmpl"`
123 sed -e "/@BODY@/ r $DST/index.tmpl" -e s/@BODY@//g $temp >$DST/index.tmpl.tmp
124 mv $DST/index.tmpl.tmp $DST/index.tmpl
126 # Copy all HTML files to destination
127 htmlfiles=`find $SRC -name "*.html"`
130 cp $i /tmp/silcdoc_html.html
133 cd /tmp/silcdoc_html.html
134 htmlfiles=`find . -name "*.html" | cut -d/ -f2`
138 # Generate the details and the layout
139 f="/tmp/silcdoc_html.html/$i"
140 sh gen.sh $DST gen_index.php 1 $f $f
141 cp /tmp/silcdoc_html.html/$i $DST
144 # Generate cross reference files
147 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
149 touch $DST/silcdoc_xref
152 $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html $TYPE GENXREF $DST/$i.xref
153 echo $DST/$i.xref >>$DST/silcdoc_xref
156 # Generate the actual detailed documentation
159 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
163 $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html XREF $DST/silcdoc_xref $TYPE
165 # Generate the TOC file
166 sh gen.sh $DST gen_index.php 1 $DST/$i.html $DST/$i.html
168 # Generate the details and the layout
169 files=`find $DST -name ""$i"-*.html"`
172 sh gen.sh $DST gen_index.php 0 $k $k
175 rm -f $DST/$i-index.tmpl
178 # Generate the index and TOC files from the DIRECTORY files
179 files=`find $SRC -name "DIRECTORY"`
183 name=`grep "@LIBRARY=" $i |cut -d= -f2`
184 fname=`grep "@FILENAME=" $i |cut -d= -f2`
186 # Generate links for this library
187 sed -e "/@LINKS@/ r $DST/$fname.links" -e s/@LINKS@//g $i >$DST/$fname
189 # Generate the TOC file for the library
190 sh gen.sh $DST gen_index.php 1 $DST/$fname $DST/$fname
192 # Generate the link for the top index.html for this library
193 echo "<li><a href="$fname">$name</a>" >>$DST/index.html.tmp
194 rm -f $DST/$fname.links
197 # Generate the top index.html file
198 index=`find $SRC -name "LIBINDEX"`
199 version=`grep SILC_VERSION_STRING $SRC/../includes/version_internal.h |cut -d\" -f2`
201 sed -e "/@VERSION@/s//$version/" -e "/@DATE@/s//$curdate/" -e "/@BODY@/ r $DST/index.html.tmp" -e s/@BODY@//g $index >$DST/index.html
202 sh gen.sh $DST gen_index.php 2 $DST/index.html $DST/index.html
204 # Generate the index toolkit_index.html file
205 $ROBO /tmp/silcdoc.html/silcdoc_xref $DST/toolkit_index.html INDEX HTML TITLE "SILC Toolkit Index"
206 sh gen.sh $DST gen_index.php 2 $DST/toolkit_index.html $DST/toolkit_index.html
209 rm -rf $DST/index.html.tmp
210 rm -rf /tmp/silcdoc.html
211 rm -rf /tmp/silcdoc_html.html