Merged r156806 through r156977 into branch.
[official-gcc.git] / libstdc++-v3 / scripts / run_doxygen
blob9ea93b9d818010e5085bc6d44d27f5db8b98f968
1 #!/bin/bash
3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002, 2003, 2004, 2008, 2009
5 # Free Software Foundation, Inc.
7 # Synopsis: run_doxygen --mode=[html|man|xml] --host_alias=<alias> \
8 # v3srcdir \
9 # v3builddir \
10 # shortname
12 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
15 # We can check now that the version of doxygen is >= this variable.
16 DOXYVER=1.6.1
18 find_doxygen() {
19 local -r v_required=`echo $DOXYVER | \
20 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
21 local testing_version doxygen maybedoxy v_found
22 # thank you goat book
23 set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
24 for dir
26 # AC_EXEEXT could come in useful here
27 maybedoxy="$dir/doxygen"
28 test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
29 if test -n "$testing_version"; then
30 v_found=`echo $testing_version | \
31 awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
32 if test $v_found -ge $v_required; then
33 doxygen="$maybedoxy"
34 break
37 done
38 if test -z "$doxygen"; then
39 echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
40 print_usage
42 # We need to use other tools from the same package/version.
43 echo :: Using Doxygen tools from ${dir}.
44 PATH=$dir:$PATH
45 hash -r
48 print_usage() {
49 cat 1>&2 <<EOF
50 Usage: run_doxygen --mode=MODE --host_alias=BUILD_ALIAS [<options>]
51 <v3-src-dir> <v3-build-dir> <shortnamesp>
52 MODE is one of:
53 html Generate user-level HTML library documentation.
54 man Generate user-level man pages.
55 xml Generate user-level XML pages.
57 BUILD_ALIAS is the GCC build alias set at configure time.
59 Note: Requires Doxygen ${DOXYVER} or later; get it at
60 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
62 EOF
63 exit 1
66 parse_options() {
67 for o
69 # Blatantly ripped from autoconf, er, I mean, "gratefully standing
70 # on the shoulders of those giants who have gone before us."
71 case "$o" in
72 -*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
73 *) arg= ;;
74 esac
76 case "$o" in
77 --mode=*)
78 mode=$arg ;;
79 --host_alias=*)
80 host_alias=$arg ;;
81 --mode | --host_alias | --help | -h)
82 print_usage ;;
84 # this turned out to be a mess, maybe change to --srcdir=, etc
85 if test $srcdir = unset; then
86 srcdir=$o
87 elif test $outdir = unset; then
88 builddir=${o}
89 outdir=${o}/doc/doxygen
90 elif test $shortname = unset; then
91 shortname=$o
92 else
93 echo run_doxygen error: Too many arguments 1>&2
94 exit 1
97 esac
98 done
102 # script begins here
103 mode=unset
104 host_alias=unset
105 srcdir=unset
106 outdir=unset
107 shortname=unset
108 do_html=false
109 do_man=false
110 do_xml=false
111 enabled_sections=
112 generate_tagfile=
113 DATEtext=`date '+%Y-%m-%d'`
115 # Show how this script is called.
116 echo run_doxygen $*
118 parse_options $*
119 find_doxygen
121 if test $srcdir = unset || test $outdir = unset || test $mode = unset || test $shortname = unset || test $host_alias = unset; then
122 # this could be better
123 echo run_doxygen error: You have not given enough information...! 1>&2
124 print_usage
127 case x"$mode" in
128 xhtml)
129 do_html=true
130 enabled_sections=maint
131 generate_tagfile="$outdir/html/libstdc++.tag"
133 xman)
134 do_man=true
136 xxml)
137 do_xml=true
138 enabled_sections=maint
141 echo run_doxygen error: $mode is an invalid mode 1>&2
142 exit 1 ;;
143 esac
145 case x"$shortname" in
146 xYES)
148 xNO)
151 echo run_doxygen error: $shortname is invalid 1>&2
152 exit 1 ;;
153 esac
156 mkdir -p $outdir
157 chmod u+w $outdir
159 # work around a stupid doxygen bug
160 if $do_man; then
161 mkdir -p $outdir/man/man3/ext
162 chmod -R u+w $outdir/man/man3/ext
165 if $do_xml; then
166 mkdir -p $outdir/xml
170 set -e
171 cd $builddir
172 sed -e "s=@outdir@=${outdir}=g" \
173 -e "s=@srcdir@=${srcdir}=g" \
174 -e "s=@shortname@=${shortname}=g" \
175 -e "s=@builddir@=${builddir}=g" \
176 -e "s=@host_alias@=${host_alias}=g" \
177 -e "s=@enabled_sections@=${enabled_sections}=" \
178 -e "s=@do_html@=${do_html}=" \
179 -e "s=@do_man@=${do_man}=" \
180 -e "s=@do_xml@=${do_xml}=" \
181 -e "s=@generate_tagfile@=${generate_tagfile}=" \
182 ${srcdir}/doc/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
183 echo :: NOTE that this may take some time...
184 echo doxygen ${outdir}/${mode}.cfg
185 doxygen ${outdir}/${mode}.cfg
186 echo :: Finished, exit code was $?
188 ret=$?
189 test $ret -ne 0 && exit $ret
191 if $do_html; then
192 cd ${outdir}/html
194 #doxytag -t libstdc++.tag . > /dev/null 2>&1
195 sed -e '/<path>/d' libstdc++.tag > TEMP
196 mv TEMP libstdc++.tag
198 sed -e "s=@DATE@=${DATEtext}=" \
199 ${srcdir}/doc/doxygen/mainpage.html > index.html
201 # The following bit of line noise changes annoying
202 # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
203 # to user-friendly
204 # std::foo
205 # in the major "Compound List" page.
206 sed -e 's=\(::[[:alnum:]_]*\)&lt; .* &gt;=\1=' annotated.html > annstrip.html
207 mv annstrip.html annotated.html
209 # Work around a bug in doxygen 1.3.
210 # for f in class*html struct*html; do
211 for f in class*html; do
212 sed '1,10s!^<title> Template!<title>Template !' $f > TEMP
213 mv TEMP $f
214 done
216 cp ${srcdir}/doc/doxygen/tables.html tables.html
217 echo ::
218 echo :: HTML pages begin with
219 echo :: ${outdir}/html/index.html
222 # Mess with the man pages. We don't need documentation of the internal
223 # headers, since the man pages for those contain nothing useful anyhow. The
224 # man pages for doxygen modules need to be renamed (or deleted). And the
225 # generated #include lines need to be changed from the internal names to the
226 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
227 if $do_man; then
228 echo ::
229 echo :: Fixing up the man pages...
230 cd $outdir/man/man3
232 # here's the other end of the "stupid doxygen bug" mentioned above
233 rm -rf ext
235 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
236 find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
238 # man pages are for functions/types/other entities, not source files
239 # directly. who the heck would type "man foo.h" anyhow?
240 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
241 rm -f *.h.3 *.hpp.3 *config* *.cc.3 *.tcc.3 *_t.3
242 #rm ext_*.3 tr1_*.3 debug_*.3
244 # this is used to examine what we would have deleted, for debugging
245 #mkdir trash
246 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
247 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
249 # Standardize the displayed header names. If anyone who knows perl cares
250 # enough to rewrite all this, feel free. This only gets run once a century,
251 # and I'm off getting coffee then anyhow, so I didn't care enough to make
252 # this super-fast.
253 g++ ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader
254 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
255 for f in $problematic; do
256 # this is also slow, but safe and easy to debug
257 oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
258 newh=`echo $oldh | ./stdheader`
259 sed "s=${oldh}=${newh}=" $f > TEMP
260 mv TEMP $f
261 done
262 rm stdheader
264 # Some of the pages for generated modules have text that confuses certain
265 # implementations of man(1), e.g., Linux's. We need to have another top-level
266 # *roff tag to /stop/ the .SH NAME entry.
267 problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
268 #problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
270 for f in $problematic; do
271 sed '/^\.SH NAME/{
275 .SH SYNOPSIS
276 }' $f > TEMP
277 mv TEMP $f
278 done
280 # Also, break this (generated) line up. It's ugly as sin.
281 problematic=`grep -l '[^^]Definition at line' *.3`
282 for f in $problematic; do
283 sed 's/Definition at line/\
284 .PP\
285 &/' $f > TEMP
286 mv TEMP $f
287 done
289 cp ${srcdir}/doc/doxygen/Intro.3 C++Intro.3
291 # Why didn't I do this at the start? Were rabid weasels eating my brain?
292 # Who the fsck would "man std_vector" when the class isn't named that?
294 # First, deal with nested namespaces.
295 for f in *chrono_*; do
296 newname=`echo $f | sed 's/chrono_/chrono::/'`
297 mv $f $newname
298 done
299 for f in *__debug_*; do
300 newname=`echo $f | sed 's/__debug_/__debug::/'`
301 mv $f $newname
302 done
303 for f in *decimal_*; do
304 newname=`echo $f | sed 's/decimal_/decimal::/'`
305 mv $f $newname
306 done
307 for f in *__detail_*; do
308 newname=`echo $f | sed 's/__detail_/__detail::/'`
309 mv $f $newname
310 done
311 for f in *__parallel_*; do
312 newname=`echo $f | sed 's/__parallel_/__parallel::/'`
313 mv $f $newname
314 done
315 for f in *__profile_*; do
316 newname=`echo $f | sed 's/__profile_/__profile::/'`
317 mv $f $newname
318 done
319 for f in *__atomic0_*; do
320 newname=`echo $f | sed 's/__atomic0_/__atomic0::/'`
321 mv $f $newname
322 done
323 for f in *__atomic2_*; do
324 newname=`echo $f | sed 's/__atomic2_/__atomic2::/'`
325 mv $f $newname
326 done
328 # Then, clean up other top-level namespaces.
329 for f in std_tr1_*; do
330 newname=`echo $f | sed 's/^std_tr1_/std::tr1::/'`
331 mv $f $newname
332 done
333 for f in std_*; do
334 newname=`echo $f | sed 's/^std_/std::/'`
335 mv $f $newname
336 done
337 for f in __gnu_cxx_*; do
338 newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
339 mv $f $newname
340 done
341 for f in __gnu_debug_*; do
342 newname=`echo $f | sed 's/^__gnu_debug_/__gnu_debug::/'`
343 mv $f $newname
344 done
345 for f in __gnu_parallel_*; do
346 newname=`echo $f | sed 's/^__gnu_parallel_/__gnu_parallel::/'`
347 mv $f $newname
348 done
349 for f in __gnu_profile_*; do
350 newname=`echo $f | sed 's/^__gnu_profile_/__gnu_profile::/'`
351 mv $f $newname
352 done
353 for f in __gnu_pbds_*; do
354 newname=`echo $f | sed 's/^__gnu_pbds_/__gnu_pbds::/'`
355 mv $f $newname
356 done
357 for f in __cxxabiv1_*; do
358 newname=`echo $f | sed 's/^__cxxabiv1_/abi::/'`
359 mv $f $newname
360 done
362 # Then piecemeal nested classes
363 for f in *__future_base_*; do
364 newname=`echo $f | sed 's/__future_base_/__future_base::/'`
365 mv $f $newname
366 done
370 # Generic removal bits, where there are things in the generated man
371 # pages that need to be killed.
372 for f in *_libstdc__-v3_*; do
373 rm $f
374 done
376 for f in *_src_*; do
377 rm $f
378 done
381 # Also, for some reason, typedefs don't get their own man pages. Sigh.
382 for f in ios streambuf istream ostream iostream stringbuf \
383 istringstream ostringstream stringstream filebuf ifstream \
384 ofstream fstream string;
386 echo ".so man3/std::basic_${f}.3" > std::${f}.3
387 echo ".so man3/std::basic_${f}.3" > std::w${f}.3
388 done
390 echo ::
391 echo :: Man pages in ${outdir}/man
394 # all done
395 echo ::
397 exit 0