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