]> gcc.gnu.org Git - gcc.git/blob - libstdc++-v3/docs/doxygen/run_doxygen
ec1a9b4e5e1cc42bfda18c44b11365edb3a50bb1
[gcc.git] / libstdc++-v3 / docs / doxygen / run_doxygen
1 #!/bin/bash
2
3 # Runs doxygen and massages the output files.
4 # Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 #
6 # Synopsis: run_doxygen --mode=[user|maint|man] --build_alias=<alias> \
7 # v3srcdir v3builddir
8 #
9 # Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
10
11
12 # We can check now that the version of doxygen is >= this variable.
13 DOXYVER=1.3.9
14
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
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 # 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
43 }
44
45 print_usage() {
46 cat 1>&2 <<EOF
47 Usage: run_doxygen --mode=MODE --build_alias=BUILD_ALIAS [<options>]
48 <v3-src-dir> <v3-build-dir>
49 MODE is one of:
50 user Generate user-level HTML library documentation.
51 maint Generate maintainers' HTML documentation (lots more;
52 exposes non-public members, etc).
53 man Generate user-level man pages.
54
55 BUILD_ALIAS is the GCC build alias set at configure time.
56
57 more options when i think of them
58
59 Note: Requires Doxygen ${DOXYVER} or later; get it at
60 ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
61
62 EOF
63 exit 1
64 }
65
66 parse_options() {
67 for o
68 do
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
75
76 case "$o" in
77 --mode=*)
78 mode=$arg ;;
79 --build_alias=*)
80 build_alias=$arg ;;
81 --mode | --build_alias | --help | -h)
82 print_usage ;;
83 *)
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}/docs/doxygen
90 else
91 echo run_doxygen error: Too many arguments 1>&2
92 exit 1
93 fi
94 ;;
95 esac
96 done
97 }
98
99
100 # script begins here
101 mode=unset
102 build_alias=unset
103 srcdir=unset
104 outdir=unset
105 do_html=false
106 do_man=false
107 enabled_sections=
108 generate_tagfile=
109 DATEtext=`date '+%Y-%m-%d'`
110
111 parse_options $*
112 find_doxygen
113
114 if test $srcdir = unset || test $outdir = unset || test $mode = unset || test $build_alias = unset; then
115 # this could be better
116 echo run_doxygen error: You have not given enough information...! 1>&2
117 print_usage
118 fi
119
120 case x"$mode" in
121 xuser)
122 do_html=true
123 LEVELtext='User'
124 generate_tagfile="$outdir/html_$mode/libstdc++.tag"
125 ;;
126 xmaint)
127 do_html=true
128 enabled_sections=maint
129 LEVELtext='Maintainer'
130 generate_tagfile="$outdir/html_$mode/libstdc++.tag"
131 ;;
132 xman)
133 do_man=true
134 ;;
135 *)
136 echo run_doxygen error: $mode is an invalid mode 1>&2
137 exit 1 ;;
138 esac
139
140 #rm -rf $outdir
141 mkdir -p $outdir
142 chmod u+w $outdir
143
144 # work around a stupid doxygen bug
145 if $do_man; then
146 mkdir -p $outdir/man/man3/ext
147 chmod -R u+w $outdir/man/man3/ext
148 fi
149
150 (
151 set -e
152 cd $builddir
153 sed -e "s=@outdir@=${outdir}=g" \
154 -e "s=@srcdir@=${srcdir}=g" \
155 -e "s=@build_alias@=${build_alias}=g" \
156 -e "s=@html_output_dir@=html_${mode}=" \
157 -e "s=@enabled_sections@=${enabled_sections}=" \
158 -e "s=@do_html@=${do_html}=" \
159 -e "s=@do_man@=${do_man}=" \
160 -e "s=@generate_tagfile@=${generate_tagfile}=" \
161 ${srcdir}/docs/doxygen/user.cfg.in > ${outdir}/${mode}.cfg
162 echo :: NOTE that this may take some time...
163 echo doxygen ${outdir}/${mode}.cfg
164 doxygen ${outdir}/${mode}.cfg
165 echo :: Finished, exit code was $?
166 )
167 ret=$?
168 test $ret -ne 0 && exit $ret
169
170 if $do_html; then
171 cd ${outdir}/html_${mode}
172
173 #doxytag -t libstdc++.tag . > /dev/null 2>&1
174 sed -e '/<path>/d' libstdc++.tag > TEMP
175 mv TEMP libstdc++.tag
176
177 sed -e "s=@LEVEL@=${LEVELtext}=" \
178 -e "s=@DATE@=${DATEtext}=" \
179 ${srcdir}/docs/doxygen/mainpage.html > index.html
180
181 # The following bit of line noise changes annoying
182 # std::foo < typename _Ugly1, typename _Ugly2, .... _DefaultUgly17 >
183 # to user-friendly
184 # std::foo
185 # in the major "Compound List" page.
186 sed -e 's=\(::[[:alnum:]_]*\)&lt; .* &gt;=\1=' annotated.html > annstrip.html
187 mv annstrip.html annotated.html
188
189 # Work around a bug in doxygen 1.3.
190 for f in class*html struct*html; do
191 sed '1,10s!^<title> Template!<title>Template !' $f > TEMP
192 mv TEMP $f
193 done
194
195 cp ${srcdir}/docs/doxygen/tables.html tables.html
196 echo ::
197 echo :: HTML pages begin with
198 echo :: ${outdir}/html_${mode}/index.html
199 fi
200
201 # Mess with the man pages. We don't need documentation of the internal
202 # headers, since the man pages for those contain nothing useful anyhow. The
203 # man pages for doxygen modules need to be renamed (or deleted). And the
204 # generated #include lines need to be changed from the internal names to the
205 # standard ones (e.g., "#include <stl_tempbuf.h>" -> "#include <memory>").
206 if $do_man; then
207 echo ::
208 echo :: Fixing up the man pages...
209 cd $outdir/man/man3
210
211 # here's the other end of the "stupid doxygen bug" mentioned above
212 rm -rf ext
213
214 # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
215 find . -name "* *" -print0 | xargs -0r rm # requires GNU tools
216
217 # can leave SGIextensions.3 alone, it's an okay name
218 mv s20_3_1_base.3 Intro_functors.3
219 mv s20_3_2_arithmetic.3 Arithmetic_functors.3
220 mv s20_3_3_comparisons.3 Comparison_functors.3
221 mv s20_3_4_logical.3 Logical_functors.3
222 mv s20_3_5_negators.3 Negation_functors.3
223 mv s20_3_6_binder.3 Binder_functors.3
224 mv s20_3_7_adaptors.3 Func_ptr_functors.3
225 mv s20_3_8_memadaptors.3 Member_ptr_functors.3
226 mv iterator_tags.3 Iterator_types.3
227 mv std.3 Namespace_std.3
228 mv __gnu_cxx.3 Namespace___gnu_cxx.3
229
230 # man pages are for functions/types/other entities, not source files
231 # directly. who the heck would type "man foo.h" anyhow?
232 find . -name "[a-z]*" -a ! -name "std_*" -print | xargs rm
233 rm -f *.h.3 *config* *.cc.3 *.tcc.3 *_t.3
234 # this is used to examine what we would have deleted, for debugging
235 #mkdir trash
236 #find . -name "[a-z]*" -a ! -name "std_*" -print | xargs -i mv {} trash
237 #mv *.h.3 *config* *.cc.3 *.tcc.3 *_t.3 trash
238
239 # Standardize the displayed header names. If anyone who knows perl cares
240 # enough to rewrite all this, feel free. This only gets run once a century,
241 # and I'm off getting coffee then anyhow, so I didn't care enough to make
242 # this super-fast.
243 g++ ${srcdir}/docs/doxygen/stdheader.cc -o ./stdheader
244 problematic=`egrep -l '#include <.*_.*>' [a-z]*.3`
245 for f in $problematic; do
246 # this is also slow, but safe and easy to debug
247 oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
248 newh=`echo $oldh | ./stdheader`
249 sed "s=${oldh}=${newh}=" $f > TEMP
250 mv TEMP $f
251 done
252 rm stdheader
253
254 # Some of the pages for generated modules have text that confuses certain
255 # implementations of man(1), e.g., Linux's. We need to have another top-level
256 # *roff tag to /stop/ the .SH NAME entry.
257 #problematic=`egrep --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
258 problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
259 for f in $problematic; do
260 sed '/^\.SH NAME/{
261 n
262 a\
263 \
264 .SH SYNOPSIS
265 }' $f > TEMP
266 mv TEMP $f
267 done
268
269 # Also, break this (generated) line up. It's ugly as sin.
270 problematic=`grep -l '[^^]Definition at line' *.3`
271 for f in $problematic; do
272 sed 's/Definition at line/\
273 .PP\
274 &/' $f > TEMP
275 mv TEMP $f
276 done
277
278 cp ${srcdir}/docs/doxygen/Intro.3 C++Intro.3
279
280 # Why didn't I do this at the start? Were rabid weasels eating my brain?
281 # Who the fsck would "man std_vector" when the class isn't named that?
282 for f in std_*; do
283 newname=`echo $f | sed 's/^std_/std::/'`
284 mv $f $newname
285 done
286 for f in __gnu_cxx_*; do
287 newname=`echo $f | sed 's/^__gnu_cxx_/__gnu_cxx::/'`
288 mv $f $newname
289 done
290
291 # Generic reoval bits, where there are things in the generated man
292 # pages that need to be killed.
293 for f in *_libstdc__-v3_*; do
294 rm $f
295 done
296
297 for f in *_src_*; do
298 rm $f
299 done
300
301
302 # Also, for some reason, typedefs don't get their own man pages. Sigh.
303 for f in ios streambuf istream ostream iostream stringbuf \
304 istringstream ostringstream stringstream filebuf ifstream \
305 ofstream fstream string;
306 do
307 echo ".so man3/std::basic_${f}.3" > std::${f}.3
308 echo ".so man3/std::basic_${f}.3" > std::w${f}.3
309 done
310
311 echo ::
312 echo :: Man pages in ${outdir}/man
313 fi
314
315 # all done
316 echo ::
317
318 exit 0
319
320 # vim:ts=4:et:
This page took 0.0568070000000001 seconds and 4 git commands to generate.