3
# doxygen.sh Copyright (C) 2005 by Adriaan de Groot
4
# Based on some code from Doxyfile.am, among other things.
5
# License: GPL version 2.
6
# See file COPYING in kdelibs for details.
10
# Recurse handling is a little complicated, since normally
11
# subdir (given on the command-line) processing doesn't recurse
12
# but you can force it to do so.
18
while test -n "$1" ; do
38
echo "doxygen.sh usage:"
39
echo "doxygen.sh [--no-recurse] [--no-modulename] <srcdir> [<subdir>]"
43
DOXDATA=`echo $1 | sed -e 's+--doxdatadir=++'`
46
PREFIX=`echo $1 | sed -e 's+--installdir=++'`
49
echo "Unknown option: $1"
61
### Sanity check the mandatory "top srcdir" argument.
62
if test -z "$top_srcdir" ; then
63
echo "Usage: doxygen.sh <top_srcdir>"
66
if ! test -d "$top_srcdir" ; then
67
echo "top_srcdir ($top_srcdir) is not a directory."
71
### Normalize top_srcdir so it is an absolute path.
72
if ! expr "x$top_srcdir" : "x/" > /dev/null ; then
73
top_srcdir=`cd "$top_srcdir" 2> /dev/null && pwd`
74
if ! test -d "$top_srcdir" ; then
75
echo "top_srcdir ($top_srcdir) is not a directory."
82
### Sanity check and guess QTDOCDIR.
83
if test -z "$QTDOCDIR" ; then
84
if test -z "$QTDIR" ; then
85
for i in /usr/X11R6/share/doc/qt/html
88
test -d "$QTDOCDIR" && break
91
for i in share/doc/qt/html doc/html
94
test -d "$QTDOCDIR" && break
98
if test -z "$QTDOCDIR" || test \! -d "$QTDOCDIR" ; then
99
if test -z "$QTDOCDIR" ; then
100
echo "* QTDOCDIR could not be guessed."
102
echo "* QTDOCDIR does not name a directory."
104
if test -z "$QTDOCTAG" ; then
105
echo "* QTDOCDIR set to \"\""
108
echo "* But I'll use $QTDOCDIR anyway because of QTDOCTAG."
112
### Get the "top srcdir", also its name, and handle the case that subdir "."
113
### is given (which would be top_srcdir then, so it's equal to none-given
114
### but no recursion either).
116
# top_srcdir="$1" # Already set by options processing
117
module_name=`basename "$top_srcdir"`
119
if test "x." = "x$subdir" ; then
121
if test "x$recurse_given" = "xNO" ; then
125
if test "x" != "x$subdir" ; then
126
# If no recurse option given explicitly, default to
127
# no recurse when processing subdirs given on the command-line.
128
if test "x$recurse_given" = "xNO" ; then
133
if test -z "$DOXDATA" || test ! -d "$DOXDATA" ; then
134
if test -n "$DOXDATA" ; then
135
echo "* \$DOXDATA is '$DOXDATA' which does not name a directory"
137
DOXDATA="$top_srcdir/doc/common"
140
if ! test -d "$DOXDATA" ; then
141
echo "* \$DOXDATA does not name a directory ( or is unset ), tried \"$DOXDATA\""
145
if test -n "$PREFIX" && test ! -d "$PREFIX" ; then
146
echo "* \$PREFIX does not name a directory, tried \"$PREFIX\""
147
echo "* \$PREFIX is disabled."
151
### We need some values from top-level files, which
152
### are not preserved between invocations of this
153
### script, so factor it out for easy use.
156
eval `grep 'VERSION="' "$top_srcdir/admin/cvs.sh"`
157
echo "PROJECT_NUMBER = $VERSION" > Doxyfile.in
158
grep ^KDE_INIT_DOXYGEN "$top_srcdir/configure.in.in" | \
159
sed -e 's+[^[]*\[\([^]]*\)+PROJECT_NAME = "\1"+' \
160
-e 's+].*++' >> Doxyfile.in
163
apidoxdir="$module_name"-apidocs
164
test "x$use_modulename" = "x0" && apidoxdir="apidocs"
166
### If we're making the top subdir, create the structure
167
### for the apidox and initialize it. Otherwise, just use the
168
### structure assumed to be there.
169
if test -z "$subdir" ; then
170
if ! test -d "$apidoxdir" ; then
171
mkdir "$apidoxdir" > /dev/null 2>&1
173
if ! cd "$apidoxdir" > /dev/null 2>&1 ; then
174
echo "Cannot create and cd into $apidoxdir"
178
test -f "Doxyfile.in" || create_doxyfile_in
180
# Copy in logos and the like
181
for i in "favicon.ico" "kde_gear_64.png"
183
cp "$DOXDATA/$i" . > /dev/null 2> /dev/null
185
for i in "$top_srcdir/doc/api/Dox-"*.png
187
T=`basename "$i" | sed -e 's+Dox-++'`
188
test -f "$i" && cp "$i" "./$T" > /dev/null 2> /dev/null
195
if ! cd "$apidoxdir" > /dev/null 2>&1 ; then
196
echo "Cannot cd into $apidoxdir -- maybe you need to"
197
echo "build the top-level dox first."
201
if test "x1" = "x$recurse" ; then
202
# OK, so --recurse was requested
203
if ! test -f "subdirs.top" ; then
204
echo "* No subdirs.top available in the $apidoxdir."
205
echo "* The --recurse option will be ignored."
211
### Read a single line (TODO: support \ continuations) from the Makefile.am.
212
### Used to extract variable assignments from it.
215
file="$2" ; test -z "$file" && file="$srcdir/Makefile.am"
216
pattern=`echo "$1" | tr + .`
217
grep "^$1" "$file" | \
218
sed -e "s+$pattern.*=\s*++"
221
### Handle the COMPILE_{FIRST,LAST,BEFORE,AFTER} part of Makefile.am
222
### in the toplevel. Copied from admin/cvs.sh. Licence presumed LGPL).
225
echo "* Sorting top-level subdirs"
228
if test -f "$top_srcdir/inst-apps"; then
229
idirs=`cat "$top_srcdir/"inst-apps`
231
idirs=`cd "$top_srcdir" && ls -1 | sort`
236
if test -f "$top_srcdir/"Makefile.am.in ; then
237
compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1`
238
compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1`
241
if test -f "$top_srcdir/$i"/Makefile.am; then
242
case " $compilefirst $compilelast " in
251
for d in $compilefirst; do
252
echo $d >> ./_SUBDIRS
257
if test -f "$top_srcdir/"Makefile.am.in ; then
258
list=`sed -ne "s#^COMPILE_BEFORE_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1`
264
if test -f "$top_srcdir/"Makefile.am.in ; then
265
list=`sed -ne "s#^COMPILE_AFTER_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1`
271
done ) | tsort >> ./_SUBDIRS
273
for d in $compilelast; do
274
echo $d >> ./_SUBDIRS
277
test -r _SUBDIRS && mv _SUBDIRS subdirs.top || true
281
### Add HTML header, footer, CSS tags to Doxyfile.
282
### Assumes $subdir is set. Argument is a string
283
### to stick in front of the file if needed.
286
dox_header="$top_srcdir/doc/api/$1header.html"
287
dox_footer="$top_srcdir/doc/api/$1footer.html"
288
dox_css="$top_srcdir/doc/api/doxygen.css"
289
test -f "$dox_header" || dox_header="$DOXDATA/$1header.html"
290
test -f "$dox_footer" || dox_footer="$DOXDATA/$1footer.html"
291
test -f "$dox_css" || dox_css="$DOXDATA/doxygen.css"
293
echo "HTML_HEADER = $dox_header" >> "$subdir/Doxyfile" ; \
294
echo "HTML_FOOTER = $dox_footer" >> "$subdir/Doxyfile" ; \
295
echo "HTML_STYLESHEET = $dox_css" >> "$subdir/Doxyfile"
300
line=`extract_line DOXYGEN_PROJECTNAME "$1"`
301
test -n "$line" && echo "PROJECT_NAME = \"$line\"" >> "$2"
306
for i in "$top_srcdir/doc/api/Doxyfile.local"
308
if test -f "$i" ; then
309
cat "$i" >> "$subdir/Doxyfile"
315
### Post-process HTML files by substituting in the menu files
317
# In non-top directories, both <!-- menu --> and <!-- gmenu -->
318
# are calculated and replaced. Top directories get an empty <!-- menu -->
322
# Special case top-level to have an empty MENU.
323
if test "x$subdir" = "x." ; then
326
htmltop="$top_builddir" # Just ., presumably
327
echo "* Post-processing top-level files"
330
htmldir="$subdir/html"
331
htmltop="$top_builddir.." # top_builddir ends with /
332
echo "* Post-processing files in $htmldir"
334
# Build a little PHP file that maps class names to file
335
# names, for the quick-class-picker functionality.
336
# (The quick-class-picker is disabled due to styling
337
# problems in IE & FF).
339
echo "<?php \$map = array("; \
340
for htmlfile in `find $htmldir/ -type f -name "class[A-Z]*.html" | grep -v "\-members.html$"`; do
341
classname=`echo $htmlfile | sed -e "s,.*/class\\(.*\\).html,\1," -e "s,_1_1,::,g" -e "s,_01, ,g" -e "s,_4,>,g" -e "s+_00+,+g" -e "s+_3+<+g" | tr "[A-Z]" "[a-z]"`
342
echo " \"$classname\" => \"$htmlfile\","
345
) > "$subdir/classmap.inc"
347
# This is a list of pairs, with / separators so we can use
348
# basename and dirname (a crude shell hack) to split them
349
# into parts. For each, if the file part exists (as a html
350
# file) tack it onto the MENU variable as a <li> with link.
351
for i in "Main Page/index" \
353
"Namespace List/namespaces" \
354
"Class Hierarchy/hierarchy" \
355
"Alphabetical List/classes" \
356
"Class List/annotated" \
359
"Namespace Members/namespacemembers" \
360
"Class Members/functions" \
361
"Related Pages/pages"
365
test -f "$htmldir/$FILE.html" && MENU="$MENU<li><a href=\"$FILE.html\">$NAME</a></li>"
372
# Get the list of global Menu entries.
373
GMENU=`cat subdirs | tr -d '\n'`
375
PMENU=`grep '<!-- pmenu' "$htmldir/index.html" | sed -e 's+.*pmenu *++' -e 's+ *-->++' | awk '{ c=split($0,a,"/"); for (j=1; j<=c; j++) { printf " / <a href=\""; if (j==c) { printf("."); } for (k=j; k<c; k++) { printf "../"; } if (j<c) { printf("../html/index.html"); } printf "\">%s</a>\n" , a[j]; } }' | tr -d '\n'`
377
# Map the PHP file into HTML options so that
378
# it can be substituted in for the quick-class-picker.
380
# For now, leave the CMENU disabled
384
if test "x$subdir" = "x." ; then
385
# Disable CMENU on toplevel anyway
389
test -f "$subdir/classmap.inc" && \
390
CMENU=`grep '=>' "$subdir/classmap.inc" | sed -e 's+"\([^"]*\)" => "'"$subdir/html/"'\([^"]*\)"+<option value="\2">\1<\/option>+' | tr -d '\n'`
392
if ! test -f "$subdir/classmap.inc" || ! grep "=>" "$subdir/classmap.inc" > /dev/null 2>&1 ; then
398
# Now substitute in the MENU in every file. This depends
399
# on HTML_HEADER (ie. header.html) containing the
400
# <!-- menu --> comment.
401
for i in "$htmldir"/*.html
403
if test -f "$i" ; then
404
sed -e "s+<!-- menu -->+$MENU+" \
405
-e "s+<!-- gmenu -->+$GMENU+" \
406
-e "s+<!-- pmenu.*-->+$PMENU+" \
407
-e "s+<!-- cmenu.begin -->+$CMENUBEGIN+" \
408
-e "s+<!-- cmenu.end -->+$CMENUEND+" \
409
< "$i" | sed -e "s+@topdir@+$htmltop+g" > "$i.new" && mv "$i.new" "$i"
410
sed -e "s+<!-- cmenu -->+$CMENU+" < "$i" > "$i.new"
411
test -s "$i.new" && mv "$i.new" "$i"
421
### Handle the Doxygen processing of a toplevel directory.
425
echo "*** Creating API documentation main page for $module_name"
428
for i in "$top_srcdir/doc/api/Doxyfile.global" \
429
"$top_srcdir/admin/Doxyfile.global" \
430
"$DOXDATA/Doxyfile.global"
432
if test -f "$i" ; then
438
if test ! -f "Doxyfile" ; then
439
echo "* Cannot create Doxyfile."
443
cat "$top_builddir/Doxyfile.in" >> Doxyfile
446
echo "INPUT = $top_srcdir" >> Doxyfile
447
echo "OUTPUT_DIRECTORY = $top_builddir" >> Doxyfile ; \
448
echo "FILE_PATTERNS = *.dox" >> Doxyfile ; \
449
echo "RECURSIVE = NO" >> Doxyfile ; \
450
echo "ALPHABETICAL_INDEX = NO" >> Doxyfile ; \
451
echo "HTML_OUTPUT = ." >> Doxyfile ; \
452
apidox_htmlfiles "main"
454
# KDevelop has a top-level Makefile.am with settings.
455
for i in "$top_srcdir/Makefile.am.in" "$top_srcdir/Makefile.am"
457
if test -f "$i" ; then
458
grep '^DOXYGEN_SET_' "$i" | \
459
sed -e 's+DOXYGEN_SET_++' -e "s+@topdir@+$top_srcdir+" >> Doxyfile
460
apidox_specials "$srcdir/Makefile.am" "$subdir/Doxyfile"
470
( cd "$top_srcdir" && grep -l ^include.*Doxyfile.am `find . -name Makefile.am` ) | sed -e 's+/Makefile.am$++' -e 's+^\./++' | sort > subdirs.in
471
for i in `cat subdirs.in`
473
test "x." = "x$i" && continue;
477
if test "x." = "x$dir" ; then
482
indent=`echo "$dir" | sed -e 's+[^/]*/+\ \ +g' | sed -e 's+&+\\\&+g'`
483
entryname=`extract_line DOXYGEN_SET_PROJECT_NAME "$top_srcdir/$dir/$file/Makefile.am"`
484
test -z "$entryname" && entryname="$file"
486
if grep DOXYGEN_EMPTY "$top_srcdir/$dir/$file/Makefile.am" > /dev/null 2>&1 ; then
487
echo "<li>$indent$file</li>"
489
echo "<li>$indent<a href=\"@topdir@/$dir$file/html/index.html\">$entryname</a></li>"
496
### Handle the Doxygen processing of a non-toplevel directory.
500
echo "*** Creating apidox in $subdir"
502
rm -f "$subdir/Doxyfile"
503
if ! test -d "$top_srcdir/$subdir" ; then
504
echo "* No source (sub)directory $subdir"
507
for i in "$top_srcdir/doc/api/Doxyfile.global" \
508
"$top_srcdir/admin/Doxyfile.global" \
509
"$DOXDATA/Doxyfile.global"
511
if test -f "$i" ; then
512
cp "$i" "$subdir/Doxyfile"
518
test -f "Doxyfile.in" || create_doxyfile_in
519
cat "Doxyfile.in" >> "$subdir/Doxyfile"
521
echo "PROJECT_NAME = \"$subdir\"" >> "$subdir/Doxyfile"
522
echo "INPUT = $srcdir" >> "$subdir/Doxyfile"
523
echo "OUTPUT_DIRECTORY = ." >> "$subdir/Doxyfile"
524
if grep -l "$subdir/" subdirs.in > /dev/null 2>&1 ; then
525
echo "RECURSIVE = NO" >> "$subdir/Doxyfile"
527
echo "HTML_OUTPUT = $subdir/html" >> "$subdir/Doxyfile"
528
echo "GENERATE_TAGFILE = $subdir/$subdirname.tag" >> "$subdir/Doxyfile"
529
test -d "$top_srcdir/doc/api" && \
530
echo "IMAGE_PATH = $top_srcdir/doc/api" >> "$subdir/Doxyfile"
534
# Makefile.ams may contain overrides to our settings,
536
grep '^DOXYGEN_SET_' "$srcdir/Makefile.am" | \
537
sed -e 's+DOXYGEN_SET_++' >> "$subdir/Doxyfile"
538
apidox_specials "$srcdir/Makefile.am" "$subdir/Doxyfile"
540
excludes=`extract_line DOXYGEN_EXCLUDE`
541
if test -n "$excludes"; then
544
for item in `echo "$excludes"`; do
545
if test -d "$top_srcdir/$subdir/$item"; then
546
dirs="$dirs $top_srcdir/$subdir/$item/"
548
patterns="$patterns $item"
551
echo "EXCLUDE_PATTERNS += $patterns" >> "$subdir/Doxyfile"
552
echo "EXCLUDE += $dirs" >> "$subdir/Doxyfile"
555
echo "TAGFILES = \\" >> "$subdir/Doxyfile"
556
## For now, don't support \ continued references lines
557
tags=`extract_line DOXYGEN_REFERENCES`
558
for i in $tags qt ; do
559
tagsubdir=`dirname $i` ; tag=`basename $i`
563
if test "x$tagsubdir" = "x." ; then
566
tagsubdir="$tagsubdir/"
569
# Find location of tag file
570
if test -f "$tagsubdir$tag/$tag.tag" ; then
571
file="$tagsubdir$tag/$tag.tag"
572
loc="$tagsubdir$tag/html"
574
# This checks for dox built with_out_ --no-modulename
575
# in the same build dir as this dox run was started in.
576
file=`ls -1 ../*-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
578
if test -n "$file" ; then
579
loc=`echo "$file" | sed -e "s/$tag.tag\$/html/"`
581
# If the tag file doesn't exist yet, but should
582
# because we have the right dirs here, queue
583
# this directory for re-processing later.
584
if test -d "$top_srcdir/$tagsubdir$tag" ; then
585
echo "* Need to re-process $subdir for tag $i"
586
echo "$subdir" >> "subdirs.later"
588
# Re-check in $PREFIX if needed.
589
test -n "$PREFIX" && \
590
file=`cd "$PREFIX" && \
591
ls -1 *-apidocs/"$tagsubdir$tag/$tag.tag" 2> /dev/null`
593
# If something is found, patch it up. The location must be
594
# relative to the installed location of the dox and the
595
# file must be absolute.
596
if test -n "$file" ; then
597
loc=`echo "../$file" | sed -e "s/$tag.tag\$/html/"`
599
echo "* Tags for $tagsubdir$tag will only work when installed."
605
if test "$tag" = "qt" ; then
606
if test -z "$QTDOCDIR" ; then
607
echo " $file" >> "$subdir/Doxyfile"
609
if test -z "$file" ; then
611
echo "" >> "$subdir/Doxyfile"
613
echo " $file=$QTDOCDIR" >> "$subdir/Doxyfile"
617
if test -n "$file" ; then
618
test -z "$not_found" && echo "* Found tag $file"
619
echo " $file=../$top_builddir$loc \\" >> "$subdir/Doxyfile"
626
if ! grep '^DOXYGEN_EMPTY' "$srcdir/Makefile.am" > /dev/null 2>&1 ; then
627
doxygen "$subdir/Doxyfile"
632
### Run a given subdir by setting up global variables first.
635
subdir=`echo "$1" | sed -e 's+/$++'`
636
srcdir="$top_srcdir/$subdir"
637
subdirname=`basename "$subdir"`
638
mkdir -p "$subdir" 2> /dev/null
639
if ! test -d "$subdir" ; then
640
echo "Can't create dox subdirectory $subdir"
643
top_builddir=`echo "/$subdir" | sed -e 's+/[^/]*+../+g'`
648
### Create installdox-slow in the toplevel
651
# Fix up the installdox script so it accepts empty args
653
# This code is copied from the installdox generated by Doxygen,
654
# copyright by Dimitri van Heesch and released under the GPL.
655
# This does a _slow_ update of the dox, because it loops
656
# over the given substitutions instead of assuming all the
657
# needed ones are given.
665
if (open(F,"search.cfg"))
667
$_=<F> ; s/[ \t\n]*$//g ; $subst{"_doc"} = $_;
668
$_=<F> ; s/[ \t\n]*$//g ; $subst{"_cgi"} = $_;
675
$v = ($1 eq "") ? shift @ARGV : $1;
676
($v =~ /\/$/) || ($v .= "/");
678
if ( /(.+)\@(.+)/ ) {
681
print STDERR "Argument $_ is invalid for option -l\n";
692
print STDERR "Illegal option -$_\n";
703
if (opendir(D,".")) {
704
foreach $file ( readdir(D) ) {
706
next if ( $file =~ /^\.\.?$/ );
707
($file =~ /$match/) && (push @files, $file);
708
($file =~ "tree.js") && (push @files, $file);
715
print STDERR "Warning: No input files given and none found!\n";
721
print "Editing: $f...\n";
725
unless (rename $oldf,$f) {
726
print STDERR "Error: cannot rename file $oldf\n";
730
unless (open(G,">$oldf")) {
731
print STDERR "Error: opening file $oldf for writing\n";
734
if ($oldf ne "tree.js") {
736
foreach $sub (keys %subst) {
737
s/doxygen\=\"$sub\:([^ \"\t\>\<]*)\" (href|src)=\"\1/doxygen\=\"$sub:$subst{$sub}\" \2=\"$subst{$sub}/g;
744
foreach $sub (keys %subst) {
745
s/\"$sub\:([^ \"\t\>\<]*)\", \"\1/\"$sub:$subst{$sub}\" ,\"$subst{$sub}/g;
752
print STDERR "Warning file $f does not exist\n";
758
print STDERR "Usage: installdox [options] [html-file [html-file ...]]\n";
759
print STDERR "Options:\n";
760
print STDERR " -l tagfile\@linkName tag file + URL or directory \n";
761
print STDERR " -q Quiet mode\n\n";
767
# Do only the subdirs that match the RE passed in as $1
770
RE=`echo "$1" | sed -e 's+/$++'`
772
# Here's a queue of dirs to re-process later when
773
# all the rest have been done already.
776
# subdirs.top lists _all_ subdirs of top in the order they
777
# should be handled; subdirs.in lists those dirs that contain
778
# dox. So the intersection of the two is the ordered list
779
# of top-level subdirs that contain dox.
781
# subdirs.top also doesn't contain ".", so that special
782
# case can be ignored in the loop.
786
for i in `grep "^$RE" subdirs.top`
788
if test "x$i" = "x." ; then
791
# Calculate intersection of this element and the
793
if grep "^$i\$" subdirs.in > /dev/null 2>&1 ; then
795
mkdir -p "$i" 2> /dev/null
797
# Handle the subdirs of this one
798
for j in `grep "$i/" subdirs.in`
801
mkdir -p "$j" 2> /dev/null
806
# Now we still need to handle whatever is left
807
for i in `cat subdirs.in`
809
test -d "$i" || echo "$i"
810
mkdir -p "$i" 2> /dev/null
813
for i in `cat subdirs.sort`
818
if test -s "subdirs.later" ; then
819
sort subdirs.later | uniq > subdirs.sort
820
for i in `cat subdirs.sort`
823
echo "*** Reprocessing $i"
825
test -s "subdirs.later" && echo "* Some tag files were still not found."
830
if test "x." = "x$top_builddir" ; then
833
create_installdox > installdox-slow
834
if test "x$recurse" = "x1" ; then
835
if test "x$module_name" = "xkdelibs" ; then
836
if test -z "$QTDOCTAG" && test -d "$QTDOCDIR" && \
837
test ! -f "qt/qt.tag" ; then
838
# Special case: create a qt tag file.
839
echo "*** Creating a tag file for the Qt library:"
841
doxytag -t qt/qt.tag "$QTDOCDIR" > /dev/null 2>&1
844
if test -n "$QTDOCTAG" && test -r "$QTDOCTAG" ; then
845
echo "*** Copying tag file for the Qt library:"
847
cp "$QTDOCTAG" qt/qt.tag
854
if test "x$recurse" = "x1" ; then
855
do_subdirs_re "$subdir"
862
# At the end of a run, clean up stuff.
863
if test "YES" = "$cleanup" ; then
864
rm -f subdirs.in subdirs.later subdirs.sort subdirs.top Doxyfile.in
865
rm -f `find . -name Doxyfile`
867
rmdir qt > /dev/null 2>&1