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
87 #if [ "$TYPE" = "ASCII" ]; then
94 if [ "$TYPE" = "HTML" ]; then
95 rm -rf /tmp/silcdoc.html
96 rm -rf /tmp/silcdoc_html.html
97 mkdir /tmp/silcdoc.html
98 mkdir /tmp/silcdoc_html.html
99 cp $headers /tmp/silcdoc.html
101 # Generate index template from the DIRECTORY files. The template for
102 # the generated index template is INDEX.tmpl.
103 dfiles=`find $SRC -name "DIRECTORY"`
107 name=`grep "@LIBRARY=" $i |cut -d= -f2`
108 fname=`grep "@FILENAME=" $i |cut -d= -f2`
109 links=`grep "@LINK=" $i |cut -d= -f2 |cut -d: -f1`
111 # Generate links to template file that can be included into various
112 # places on the webpage.
113 echo "<a href="$fname"><img src="box.gif" border="0" alt="">$name</a><br />" >>$DST/index.tmpl
116 n=`grep $k $i |cut -d= -f2 |cut -d: -f2`
117 echo "<li><a href="$k">$n</a>" >>$DST/$fname.links
118 echo " <a href="$k"><img src="box2.gif" border="0" alt="">$n</a><br />" >>$DST/index.tmpl
121 # Now get the template for the link template, and generate the final index
123 temp=`find $SRC -name "INDEX.tmpl"`
124 sed -e "/@BODY@/ r $DST/index.tmpl" -e s/@BODY@//g $temp >$DST/index.tmpl.tmp
125 mv $DST/index.tmpl.tmp $DST/index.tmpl
127 # Copy all HTML files to destination
128 htmlfiles=`find $SRC -name "*.html"`
131 cp $i /tmp/silcdoc_html.html
134 cd /tmp/silcdoc_html.html
135 htmlfiles=`find . -name "*.html" | cut -d/ -f2`
139 # Generate the details and the layout
140 f="/tmp/silcdoc_html.html/$i"
141 sh gen.sh $DST gen_index.php 1 $f $f
142 cp /tmp/silcdoc_html.html/$i $DST
145 # Generate cross reference files
148 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
150 touch $DST/silcdoc_xref
153 $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html $TYPE GENXREF $DST/$i.xref
154 echo $DST/$i.xref >>$DST/silcdoc_xref
157 # Generate the actual detailed documentation
160 headers=`find . -name "silc*.h" |cut -d/ -f2 |cut -d. -f1`
164 $ROBO /tmp/silcdoc.html/$i.h $DST/$i.html XREF $DST/silcdoc_xref $TYPE
166 # Generate the TOC file
167 sh gen.sh $DST gen_index.php 1 $DST/$i.html $DST/$i.html
169 # Generate the details and the layout
170 files=`find $DST -name ""$i"-*.html"`
173 sh gen.sh $DST gen_index.php 0 $k $k
176 rm -f $DST/$i-index.tmpl
179 # Generate the index and TOC files from the DIRECTORY files
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 $DST/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