Intro.3: Date tweak.
[gcc.git] / libstdc++-v3 / docs / doxygen / run_doxygen
1 #!/bin/sh
2
3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002 Free Software Foundation, Inc.
5 #
6 # Synopsis: run_doxygen --mode=[user|maint|man] v3srcdir v3builddir
7 #
8 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
9
10
11 # We can check now that the version of doxygen is >= this variable.
12 DOXYVER=1.2.14
13 doxygen=
14
15 find_doxygen() {
16 v_required=`echo $DOXYVER | \
17 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
18 testing_version=
19 # thank you goat book
20 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
21 for dir
22 do
23 # AC_EXEEXT could come in useful here
24 maybedoxy="$dir/doxygen"
25 test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
26 if test -n "$testing_version"; then
27 v_found=`echo $testing_version | \
28 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
29 if test $v_found -ge $v_required; then
30 doxygen="$maybedoxy"
31 break
32 fi
33 fi
34 done
35 if test -z "$doxygen"; then
36 echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
37 print_usage
38 fi
39 }
40
41 print_usage() {
42 cat 1>&2 <<EOF
43 Usage: run_doxygen --mode=MODE [<options>] <v3-src-dir> <v3-build-dir>
44 MODE is one of:
45 user Generate user-level HTML library documentation.
46 maint Generate maintainers' HTML documentation (lots more;
47 exposes non-public members, etc).
48 man Generate user-level man pages.
49
50 more options when i think of them
51
52 Note: Requires Doxygen ${DOXYVER} or later; get it at
53 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
54
55 EOF
56 exit 1
57 }
58
59 parse_options() {
60 for o
61 do
62 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
63 # on the shoulders of those giants who have gone before us."
64 case "$o" in
65 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
66 *) arg= ;;
67 esac
68
69 case "$o" in
70 --mode=*)
71 mode=$arg ;;
72 --mode | --help | -h)
73 print_usage ;;
74 *)
75 # this turned out to be a mess, maybe change to --srcdir=, etc
76 if test $srcdir = unset; then
77 srcdir=$o
78 elif test $outdir = unset; then
79 builddir=${o}
80 outdir=${o}/docs/doxygen
81 else
82 echo run_doxygen error: Too many arguments 1>&2
83 exit 1
84 fi
85 ;;
86 esac
87 done
88 }
89
90
91 # script begins here
92 mode=unset
93 srcdir=unset
94 outdir=unset
95 do_html=no
96 do_man=no
97 enabled_sections=
98
99 parse_options $*
100 find_doxygen
101
102 if test $srcdir = unset || test $outdir = unset || test $mode = unset; then
103 # this could be better
104 echo run_doxygen error: You have not given enough information...! 1>&2
105 print_usage
106 fi
107
108 case x"$mode" in
109 xuser) do_html=yes
110 ;;
111 xmaint) do_html=yes
112 enabled_sections=maint
113 ;;
114 xman) do_man=yes
115 ;;
116 *)
117 echo run_doxygen error: $mode is an invalid mode 1>&2
118 exit 1 ;;
119 esac
120
121 #rm -rf $outdir
122 mkdir -p $outdir
123 chmod u+w $outdir
124
125 # work around a stupid doxygen bug
126 test $do_man = yes && {
127 mkdir -p $outdir/man/man3/ext
128 chmod -R u+w $outdir/man/man3/ext
129 }
130
131 set -e
132 (
133 set -e
134 cd $builddir
135 sed -e "s=@outdir@=${outdir}=" \
136 -e "s=@srcdir@=${srcdir}=" \
137 -e "s=@html_output_dir@=html_${mode}=" \
138 -e "s=@enabled_sections@=${enabled_sections}=" \
139 -e "s=@do_html@=${do_html}=" \
140 -e "s=@do_man@=${do_man}=" \
141 ${srcdir}/docs/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
142 echo :: NOTE that this may take some time...
143 echo $doxygen ${outdir}/${mode}.cfg
144 $doxygen ${outdir}/${mode}.cfg
145 echo :: Finished, exit code was $?
146 )
147 set +e
148
149 test $do_html = yes && {
150 cp ${srcdir}/docs/doxygen/mainpage.html ${outdir}/html_${mode}/index.html
151 cp ${srcdir}/docs/doxygen/tables.html ${outdir}/html_${mode}/tables.html
152 echo ::
153 echo :: HTML pages begin with
154 echo :: ${outdir}/html_${mode}/index.html
155 }
156
157 # Mess with the man pages. We don't need documentation of the internal
158 # headers, since the man pages for those contain nothing useful anyhow. The
159 # man pages for doxygen modules need to be renamed (or deleted). And the
160 # generated #include lines need to be changed from the internal names to the
161 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
162 test $do_man = yes && {
163 echo ::
164 echo :: Fixing up the man pages...
165 cd $outdir/man/man3
166
167 # here's the other end of the "stupid doxygen bug" mentioned above
168 rm -rf ext
169
170 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
171 find . -name "* *" -print0 | xargs -0 rm # requires GNU tools
172
173 # can leave SGIextensions.3 alone, it's an okay name
174 mv s20_3_1_base.3 Intro_functors.3
175 mv s20_3_2_arithmetic.3 Arithmetic_functors.3
176 mv s20_3_3_comparisons.3 Comparison_functors.3
177 mv s20_3_4_logical.3 Logical_functors.3
178 mv s20_3_5_negators.3 Negation_functors.3
179 mv s20_3_6_binder.3 Binder_functors.3
180 mv s20_3_7_adaptors.3 Func_ptr_functors.3
181 mv s20_3_8_memadaptors.3 Member_ptr_functors.3
182 mv std.3 Namespace_Std.3
183 mv iterator_tags.3 Iterator_types.3
184
185 # man pages are for functions/types/other entities, not source files
186 # directly. who the heck would type "man foo.h" anyhow?
187 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
188 rm -f *.h.3 *config* *.cc.3 *.tcc.3
189 rm -f *_t.3 # workaround doxygen template parsing bug for now
190 # this is used to examine what we would have deleted, for debugging
191 #mkdir trash
192 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
193 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
194
195 # Standardize the displayed header names. If anyone who knows perl cares
196 # enough to rewrite all this, feel free. This only gets run once a century,
197 # and I'm off getting coffee then anyhow, so I didn't care enough to make
198 # this super-fast.
199 g++ ${srcdir}/docs/doxygen/stdheader.cc -o ./stdheader
200 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
201 for f in $problematic; do
202 # this is also slow, but safe and easy to debug
203 oldh=`sed -n '/#include </s/.*<\(.*\)>.*/\1/p' $f`
204 newh=`echo $oldh | ./stdheader`
205 sed "s=${oldh}=${newh}=" $f > TEMP
206 mv TEMP $f
207 done
208 rm stdheader
209
210 # Some of the pages for generated modules have text that confuses certain
211 # implementations of man(1), e.g., Linux's. We need to have another top-level
212 # *roff tag to /stop/ the .SH NAME entry.
213 #problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
214 problematic='Containers.3 Sequences.3 Assoc_containers.3 Allocators.3'
215 for f in $problematic; do
216 sed '/^\.SH NAME/{
217 n
218 a\
219 \
220 .SH SYNOPSIS
221 }' $f > TEMP
222 mv TEMP $f
223 done
224
225 cp ${srcdir}/docs/doxygen/Intro.3 .
226
227 echo ::
228 echo :: Man pages in ${outdir}/man
229 }
230
231 # all done
232 echo ::
233
234 exit 0
235
236 # vim:ts=4:et:
237