16a905c6e1ad5d8bad4273e06aaa669c48f33057
[kai/samba.git] / source / script / makeyodldocs.sh
1 #!/bin/sh -v
2 SRCDIR=$1
3
4 YODLDIR=$SRCDIR/../docs/yodldocs
5 MANPAGEDIR=$SRCDIR/../docs/manpages
6 HTMLDIR=$SRCDIR/../docs/htmldocs
7
8 echo "Re-creating man pages and HTML pages from YODL sources..."
9
10 if [ ! -d $MANPAGEDIR ]; then
11   echo "directory $MANPAGEDIR does not exist, are we in the right place?"
12   exit 1
13 fi
14
15 if [ ! -d $HTMLDIR ]; then
16   echo "directory $HTMLDIR does not exist, are we in the right place?"
17   exit 1
18 fi
19
20 if [ ! -d $YODLDIR ]; then
21   echo "directory $YODLDIR does not exist, are we in the right place?"
22   exit 1
23 fi
24
25 cd $YODLDIR
26
27 for d in *.yo
28 do
29
30 #
31 # Create the basename from the YODL manpage
32 #
33     bn=`echo $d | sed -e 's/\.yo//'`
34
35         case "$d"
36         in
37                 *.[0-9].yo)
38                         echo "Creating man pages..."
39                         echo $d
40                         rm -f $bn.man
41                         yodl2man $d
42                         if [ ! -f $bn.man ]; then
43                                 echo "Failed to make man page for $d"
44                                 exit 1
45                         fi
46                         cp $bn.man ../manpages/$bn || echo "Cannot create $YODLDIR/../manpages/$bn"
47                         rm -f $bn.man
48
49                         echo "Creating html versions of man pages..."
50                         echo $d
51                         rm -f $bn.html
52                         yodl2html $d
53                         if [ ! -f $bn.html ]; then
54                                 echo "Failed to make html page for $d"
55                                 exit 1
56                         fi
57                         cp $bn.html ../htmldocs || echo "Cannot create $YODLDIR/../htmldocs/$bn.html"
58 #
59 # Copy to SWAT directory.
60 #
61                         if [ $bn = "smb.conf.5" ]; then
62                                 rm -f ../../swat/help/smb.conf.5.html || echo "Cannot remove ../../swat/help/smb.conf.5.html"
63
64                                 cp $bn.html ../../swat/help || echo "Cannot copy smb.conf.5.html to ../../swat/help/smb.conf.5.html"
65                         fi
66                         rm -f $bn.html
67                         ;;
68                 *)
69 #
70 # Non man-page YODL docs - just make html.
71 #
72                         echo $d
73                         rm -f $bn.html
74                         yodl2html $d
75                         if [ ! -f $bn.html ]; then
76                 echo "Failed to make html page for $d"
77                 exit 1
78             fi
79                         cp $bn.html ../htmldocs || echo "Cannot create $YODLDIR/../htmldocs/$bn.html"
80                         rm -f $bn.html
81                 ;;
82         esac
83 done
84
85 echo "Remember to CVS check in your changes..."
86 exit 0