Merge release-4-6 into master
[alexxy/gromacs.git] / admin / mkhtml
1 #!/bin/csh -f
2
3 if ( $#argv < 2 ) then
4   echo "Error: provide the binary directory as first argument,"
5   echo "and the location of programs.txt as the second."
6   echo "A html subdirectory will be created in the current dir."
7   exit
8 endif
9
10 set GMXBINDIR   = $1
11 set PROGFILE    = $2
12
13 set dir = $cwd
14
15 set VER         = 4.6
16 set MANDIR      = online
17 set HTML        = $cwd/html
18 set HTMLOL      = $HTML/$MANDIR
19 set HTMLIDX     = $HTML/$MANDIR.html
20
21 set GENERAL     = "getting_started:Getting_Started flow:Flow_Chart files:File_Formats mdp_opt:mdp_options"
22
23 cd $GMXBINDIR
24 set PROGRAMS = [a-z]*
25 cd $dir
26
27 echo ""
28 echo "Generating table of contents in $HTMLIDX"
29 echo "-------------------------------------------"
30
31 if ( ! -d $HTML ) mkdir $HTML
32 if ( ! -d $HTMLOL ) mkdir $HTMLOL
33
34 if ( -f $HTMLIDX ) \rm $HTMLIDX
35 touch $HTMLIDX
36
37 cat > $HTMLIDX << EOD
38 <HTML>
39 <HEAD>
40 <TITLE>GROMACS $VER Online Reference </TITLE>
41 </HEAD>
42 <LINK rel=stylesheet href="online/style.css" type="text/css">
43 <BODY text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990000" alink="#FF0000">
44
45 <table WIDTH="98%" NOSAVE NOBORDER >
46 <TR><TD WIDTH=400>
47 <TABLE WIDTH=400 NOBORDER>
48 <TD WIDTH=116>
49 <a href="http://www.gromacs.org/">
50 <img SRC="images/gmxlogo_small.jpg" BORDER=0 height=133 width=116></a></td>
51 <td ALIGN=LEFT VALIGN=TOP WIDTH=280>
52 <br><br>
53 <h2>
54 GROMACS 4.6<br>
55 Online Reference</h2>
56 </td>
57 </TABLE></TD>
58 <td ALIGN=RIGHT VALIGN=BOTTOM WIDTH="*" NOSAVE>
59 <B>VERSION 4.6<br>
60 Sat 19 Jan 2013</B></td>
61 </tr>
62 </table>
63
64 <hr>
65
66 <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10>
67 <TR>
68 <TD VALIGN=top WIDTH="25%">
69 <h3>General</h3>
70 EOD
71 foreach i ( $GENERAL )
72   set file = `echo $i | cut -d: -f1`
73   set desc = `echo $i | cut -d: -f2 | sed 's/_/ /g'`
74   echo "<A HREF="\""$MANDIR/"$file".html"\"">"$desc"</a>" >> $HTMLIDX
75   echo "<br><br>" >> $HTMLIDX
76 end
77 cat >> $HTMLIDX <<EOD
78 <A HREF="gmxfaq.html">FAQ</a>
79 <br>
80 </TD>
81 <TD VALIGN=top WIDTH=75%>
82 <h3>Programs</h3>
83 <multicol cols=5> 
84 <A HREF="$MANDIR/options.html">Options</a>
85 <br>
86 EOD
87 foreach program ( $PROGRAMS )
88   if ( ( -x $GMXBINDIR/$program ) && ( $program != "my_dssp" ) && ( $program != "GMXRC" ) && ( $program != "completion.csh" ) && ( $program != "completion.zsh" ) && ( $program != "average" ) && ( $program != "completion.bash" ) && ( $program != "demux.pl" ) && ( $program != "xplor2gmx.pl" ) ) then  
89     echo "<br><a href="$MANDIR/$program.html">$program</a>" >> $HTMLIDX
90   endif
91 end
92 cat >> $HTMLIDX << EOD
93 </multicol>
94 </TD>
95 </TR>
96 </TABLE>
97 <HR>
98 <h3>Programs by Topic</h3>
99 <multicol cols=3>
100 EOD
101 awk -F '|' -v mandir=$MANDIR '{\
102   if (NF) {\
103     if ( $1 == "HEAD" ) {\
104       hnr++;\
105       printf("<A HREF=\"#HNR%d\">%s</A><br>\n",hnr,$2);\
106     }\
107   }\
108 }' $PROGFILE >> $HTMLIDX
109 echo "</multicol> " >> $HTMLIDX
110 awk -F '|' -v mandir=$MANDIR '{\
111   if (NF) {\
112     if ( $1 == "HEAD" ) {\
113       hnr++;\
114       printf("\n<A NAME=\"HNR%d\">\n",hnr);\
115       printf("<TABLE CELLSPACING=1>\n<TR><TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n");\
116       printf("<TR><TD COLSPAN=2><b>%s</b>\n",$2);\
117     } else if ( $1 == "END" ) {\
118       printf("</TABLE>\n");\
119     } else {\
120       printf("<TR><TD><A HREF=\"%s/%s.html\">%s</A></TD><TD>%s</TD>\n",mandir,$1,$1,$2);\
121     }\
122   }\
123 }' $PROGFILE >> $HTMLIDX
124 cat >> $HTMLIDX <<EOD
125 <p>
126 <hr>
127 <div ALIGN=RIGHT>
128 <font size="-1"><a href="http://www.gromacs.org">http://www.gromacs.org</a></font><br>
129 </body>
130 </html>
131 EOD
132
133 echo "Generating html manual for GROMACS programs"
134 echo "-------------------------------------------"
135
136 cd $dir
137
138 foreach program ( $PROGRAMS )
139   if ( ( -x $GMXBINDIR/$program ) && ( $program != "my_dssp" ) && ( $program != "GMXRC" ) && ( $program != "completion.csh" ) && ( $program != "completion.zsh" ) && ( $program != "average" ) && ( $program != "completion.bash" ) ) then
140     echo -n "$program "
141     cd $HTMLOL
142     $GMXBINDIR/$program -quiet -man html >& /dev/null
143     endif
144   endif
145 end
146
147 #last line