Merge -r 127928:132243 from trunk
[official-gcc.git] / libstdc++-v3 / doc / doxygen / run_doxygen
blob775a0361fb16e94c2f86540ed0e41784ae08d62a
1 #!/bin/bash
3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
6 # Synopsis: run_doxygen --mode=[html|man] --host_alias=<alias> \
7 # v3srcdir v3builddir
9 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
12 # We can check now that the version of doxygen is >= this variable.
13 DOXYVER=1.5.4
15 find_doxygen() {
16 local -r v_required=`echo $DOXYVER | \
17 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
18 local testing_version doxygen maybedoxy v_found
19 # thank you goat book
20 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
21 for dir
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
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
39 # We need to use other tools from the same package/version.
40 echo :: Using Doxygen tools from ${dir}.
41 PATH=$dir:$PATH
42 hash -r
45 print_usage() {
46 cat 1>&2 <<EOF
47 Usage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
48 <v3-src-dir> <v3-build-dir>
49 MODE is one of:
50 html Generate user-level HTML library documentation.
51 man Generate user-level man pages.
53 BUILD_ALIAS is the GCC build alias set at configure time.
55 Note: Requires Doxygen ${DOXYVER} or later; get it at
56 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
58 EOF
59 exit 1
62 parse_options() {
63 for o
65 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
66 # on the shoulders of those giants who have gone before us."
67 case "$o" in
68 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
69 *) arg= ;;
70 esac
72 case "$o" in
73 --mode=*)
74 mode=$arg ;;
75 --host_alias=*)
76 host_alias=$arg ;;
77 --mode | --host_alias | --help | -h)
78 print_usage ;;
80 # this turned out to be a mess, maybe change to --srcdir=, etc
81 if test $srcdir = unset; then
82 srcdir=$o
83 elif test $outdir = unset; then
84 builddir=${o}
85 outdir=${o}/doc/doxygen
86 else
87 echo run_doxygen error: Too many arguments 1>&2
88 exit 1
91 esac
92 done
96 # script begins here
97 mode=unset
98 host_alias=unset
99 srcdir=unset
100 outdir=unset
101 do_html=false
102 do_man=false
103 enabled_sections=
104 generate_tagfile=
105 DATEtext=`date '+%Y-%m-%d'`
107 # Show how this script is called.
108 echo run_doxygen $*
110 parse_options $*
111 find_doxygen
113 if test $srcdir = unset || test $outdir = unset || test $mode = unset || test $host_alias = unset; then
114 # this could be better
115 echo run_doxygen error: You have not given enough information...! 1>&2
116 print_usage
119 case x"$mode" in
120 xhtml)
121 do_html=true
122 enabled_sections=maint
123 generate_tagfile="$outdir/html/libstdc++.tag"
125 xman)
126 do_man=true
129 echo run_doxygen error: $mode is an invalid mode 1>&2
130 exit 1 ;;
131 esac
133 mkdir -p $outdir
134 chmod u+w $outdir
136 # work around a stupid doxygen bug
137 if $do_man; then
138 mkdir -p $outdir/man/man3/ext
139 chmod -R u+w $outdir/man/man3/ext
143 set -e
144 cd $builddir
145 sed -e "s=@outdir@=${outdir}=g" \
146 -e "s=@srcdir@=${srcdir}=g" \
147 -e "s=@builddir@=${builddir}=g" \
148 -e "s=@host_alias@=${host_alias}=g" \
149 -e "s=@html_output_dir@=html=" \
150 -e "s=@enabled_sections@=${enabled_sections}=" \
151 -e "s=@do_html@=${do_html}=" \
152 -e "s=@do_man@=${do_man}=" \
153 -e "s=@generate_tagfile@=${generate_tagfile}=" \
154 ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
155 echo :: NOTE that this may take some time...
156 echo doxygen ${outdir}/${mode}.cfg
157 doxygen ${outdir}/${mode}.cfg
158 echo :: Finished, exit code was $?
160 ret=$?
161 test $ret -ne 0 && exit $ret
163 if $do_html; then
164 cd ${outdir}/html
166 #doxytag -t libstdc++.tag . > /dev/null 2>&1
167 sed -e '/<path>/d' libstdc++.tag > TEMP
168 mv TEMP libstdc++.tag
170 sed -e "s=@DATE@=${DATEtext}=" \
171 ${srcdir}/doc/doxygen/mainpage.html > index.html
173 # The following bit of line noise changes annoying
174 # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
175 # to user-friendly
176 # std::foo
177 # in the major "Compound List" page.
178 sed -e 's=\(::[[:alnum:]_]*\)&lt; .* &gt;=\1=' annotated.html > annstrip.html
179 mv annstrip.html annotated.html
181 # Work around a bug in doxygen 1.3.
182 for f in class*html struct*html; do
183 sed '1,10s!^<title> Template!<title>Template !' $f > TEMP
184 mv TEMP $f
185 done
187 cp ${srcdir}/doc/doxygen/tables.html tables.html
188 echo ::
189 echo :: HTML pages begin with
190 echo :: ${outdir}/html/index.html
193 # Mess with the man pages. We don't need documentation of the internal
194 # headers, since the man pages for those contain nothing useful anyhow. The
195 # man pages for doxygen modules need to be renamed (or deleted). And the
196 # generated #include lines need to be changed from the internal names to the
197 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
198 if $do_man; then
199 echo ::
200 echo :: Fixing up the man pages...
201 cd $outdir/man/man3
203 # here's the other end of the "stupid doxygen bug" mentioned above
204 rm -rf ext
206 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
207 find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
209 # can leave SGIextensions.3 alone, it's an okay name
210 mv s20_3_1_base.3 Intro_functors.3
211 mv s20_3_2_arithmetic.3 Arithmetic_functors.3
212 mv s20_3_3_comparisons.3 Comparison_functors.3
213 mv s20_3_4_logical.3 Logical_functors.3
214 mv s20_3_5_negators.3 Negation_functors.3
215 #mv s20_3_6_binder.3 Binder_functors.3
216 mv s20_3_7_adaptors.3 Func_ptr_functors.3
217 mv s20_3_8_memadaptors.3 Member_ptr_functors.3
218 mv iterator_tags.3 Iterator_types.3
219 mv std.3 Namespace_std.3
220 mv __gnu_cxx.3 Namespace___gnu_cxx.3
222 # man pages are for functions/types/other entities, not source files
223 # directly. who the heck would type "man foo.h" anyhow?
224 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
225 rm -f *.h.3 *config* *.cc.3 *.tcc.3 *_t.3
226 # this is used to examine what we would have deleted, for debugging
227 #mkdir trash
228 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
229 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
231 # Standardize the displayed header names. If anyone who knows perl cares
232 # enough to rewrite all this, feel free. This only gets run once a century,
233 # and I'm off getting coffee then anyhow, so I didn't care enough to make
234 # this super-fast.
235 g++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader
236 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
237 for f in $problematic; do
238 # this is also slow, but safe and easy to debug
239 oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
240 newh=`echo $oldh | ./stdheader`
241 sed "s=${oldh}=${newh}=" $f > TEMP
242 mv TEMP $f
243 done
244 rm stdheader
246 # Some of the pages for generated modules have text that confuses certain
247 # implementations of man(1), e.g., Linux's. We need to have another top-level
248 # *roff tag to /stop/ the .SH NAME entry.
249 #problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
250 problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
251 for f in $problematic; do
252 sed '/^\.SH NAME/{
256 .SH SYNOPSIS
257 }' $f > TEMP
258 mv TEMP $f
259 done
261 # Also, break this (generated) line up. It's ugly as sin.
262 problematic=`grep -l '[^^]Definition at line' *.3`
263 for f in $problematic; do
264 sed 's/Definition at line/\
265 .PP\
266 &/' $f > TEMP
267 mv TEMP $f
268 done
270 cp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3
272 # Why didn't I do this at the start? Were rabid weasels eating my brain?
273 # Who the fsck would "man std_vector" when the class isn't named that?
275 # First, deal with nested namespaces.
276 for f in *__detail_*; do
277 newname=`echo $f | sed 's/__detail_/__detail::/'`
278 mv $f $newname
279 done
280 for f in *__parallel_*; do
281 newname=`echo $f | sed 's/__parallel_/__parallel::/'`
282 mv $f $newname
283 done
285 # Then, clean up other top-level namespaces.
286 for f in std_tr1_*; do
287 newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
288 mv $f $newname
289 done
290 for f in std_*; do
291 newname=`echo $f | sed 's/^std_/std::/'`
292 mv $f $newname
293 done
294 for f in __gnu_cxx_*; do
295 newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
296 mv $f $newname
297 done
298 for f in __gnu_debug_*; do
299 newname=`echo $f | sed 's/^__gnu_debug_/__gnu_debug::/'`
300 mv $f $newname
301 done
302 for f in __gnu_parallel_*; do
303 newname=`echo $f | sed 's/^__gnu_parallel_/__gnu_parallel::/'`
304 mv $f $newname
305 done
307 # Generic removal bits, where there are things in the generated man
308 # pages that need to be killed.
309 for f in *_libstdc__-v3_*; do
310 rm $f
311 done
313 for f in *_src_*; do
314 rm $f
315 done
318 # Also, for some reason, typedefs don't get their own man pages. Sigh.
319 for f in ios streambuf istream ostream iostream stringbuf \
320 istringstream ostringstream stringstream filebuf ifstream \
321 ofstream fstream string;
323 echo ".so man3/std::basic_${f}.3" > std::${f}.3
324 echo ".so man3/std::basic_${f}.3" > std::w${f}.3
325 done
327 echo ::
328 echo :: Man pages in ${outdir}/man
331 # all done
332 echo ::
334 exit 0