📄 doxygen.sh
字号:
#! /bin/sh## doxygen.sh Copyright (C) 2005 by Adriaan de Groot# Based on some code from Doxyfile.am, among other things.# License: GPL version 2.# See file COPYING in kdelibs for details.echo "*** doxygen.sh"# Recurse handling is a little complicated, since normally# subdir (given on the command-line) processing doesn't recurse# but you can force it to do so.recurse=1recurse_given=NOuse_modulename=1cleanup=YESwhile test -n "$1" ; docase "x$1" in"x--no-cleanup" ) cleanup=NO ;;"x--no-recurse" ) recurse=0 recurse_given=YES ;;"x--recurse" ) recurse=1 recurse_given=YES ;;"x--no-modulename" ) use_modulename=0 ;;"x--modulename" ) use_modulename=1 ;;"x--help" ) echo "doxygen.sh usage:" echo "doxygen.sh [--no-recurse] [--no-modulename] <srcdir> [<subdir>]" exit 2 ;;x--doxdatadir=* ) DOXDATA=`echo $1 | sed -e 's+--doxdatadir=++'` ;;x--installdir=*) PREFIX=`echo $1 | sed -e 's+--installdir=++'` ;;x--* ) echo "Unknown option: $1" exit 1 ;;* ) top_srcdir="$1" break ;;esacshiftdone### Sanity check the mandatory "top srcdir" argument.if test -z "$top_srcdir" ; then echo "Usage: doxygen.sh <top_srcdir>" exit 1fiif test ! -d "$top_srcdir" ; then echo "top_srcdir ($top_srcdir) is not a directory." exit 1fi### Normalize top_srcdir so it is an absolute path.if expr "x$top_srcdir" : "x/" > /dev/null ; then # top_srcdir is absolute already :else top_srcdir=`cd "$top_srcdir" 2> /dev/null && pwd` if test ! -d "$top_srcdir" ; then echo "top_srcdir ($top_srcdir) is not a directory." exit 1 fifi### Sanity check and guess QTDOCDIR.if test -z "$QTDOCDIR" ; then if test -z "$QTDIR" ; then for i in /usr/X11R6/share/doc/qt/html do QTDOCDIR="$i" test -d "$QTDOCDIR" && break done else for i in share/doc/qt/html doc/html do QTDOCDIR="$QTDIR/$i" test -d "$QTDOCDIR" && break done fifiif test -z "$QTDOCDIR" || test ! -d "$QTDOCDIR" ; then if test -z "$QTDOCDIR" ; then echo "* QTDOCDIR could not be guessed." else echo "* QTDOCDIR does not name a directory." fi if test -z "$QTDOCTAG" ; then echo "* QTDOCDIR set to \"\"" QTDOCDIR="" else echo "* But I'll use $QTDOCDIR anyway because of QTDOCTAG." fifi### Get the "top srcdir", also its name, and handle the case that subdir "."### is given (which would be top_srcdir then, so it's equal to none-given### but no recursion either).#### top_srcdir="$1" # Already set by options processingmodule_name=`basename "$top_srcdir"`subdir="$2"if test "x." = "x$subdir" ; then subdir="" if test "x$recurse_given" = "xNO" ; then recurse=0 fifiif test "x" != "x$subdir" ; then # If no recurse option given explicitly, default to # no recurse when processing subdirs given on the command-line. if test "x$recurse_given" = "xNO" ; then recurse=0 fifiif test -z "$DOXDATA" || test ! -d "$DOXDATA" ; then if test -n "$DOXDATA" ; then echo "* \$DOXDATA is '$DOXDATA' which does not name a directory" fi DOXDATA="$top_srcdir/doc/common"fiif test ! -d "$DOXDATA" ; then echo "* \$DOXDATA does not name a directory ( or is unset ), tried \"$DOXDATA\"" exit 1fiif test -n "$PREFIX" && test ! -d "$PREFIX" ; then echo "* \$PREFIX does not name a directory, tried \"$PREFIX\"" echo "* \$PREFIX is disabled." PREFIX=""fi### We need some values from top-level files, which### are not preserved between invocations of this### script, so factor it out for easy use.create_doxyfile_in() { eval `grep 'VERSION="' "$top_srcdir/admin/cvs.sh"` echo "PROJECT_NUMBER = $VERSION" > Doxyfile.in grep '^KDE_INIT_DOXYGEN' "$top_srcdir/configure.in.in" | \ sed -e 's+[^[]*\[\([^]]*\)+PROJECT_NAME = "\1"+' \ -e 's+].*++' >> Doxyfile.in}apidoxdir="$module_name"-apidocstest "x$use_modulename" = "x0" && apidoxdir="apidocs"### If we're making the top subdir, create the structure### for the apidox and initialize it. Otherwise, just use the### structure assumed to be there.if test -z "$subdir" ; then if test ! -d "$apidoxdir" ; then mkdir "$apidoxdir" > /dev/null 2>&1 fi cd "$apidoxdir" > /dev/null 2>&1 || { echo "Cannot create and cd into $apidoxdir" exit 1 } test -f "Doxyfile.in" || create_doxyfile_in # Copy in logos and the like for i in "favicon.ico" "kde_gear_64.png" do cp "$DOXDATA/$i" . > /dev/null 2> /dev/null done for i in "$top_srcdir/doc/api/Dox-"*.png do T=`basename "$i" | sed -e 's+Dox-++'` test -f "$i" && cp "$i" "./$T" > /dev/null 2> /dev/null done top_builddir="." srcdir="$1" subdir="."else cd "$apidoxdir" > /dev/null 2>&1 || { echo "Cannot cd into $apidoxdir -- maybe you need to" echo "build the top-level dox first." exit 1 } if test "x1" = "x$recurse" ; then # OK, so --recurse was requested if test ! -f "subdirs.top" ; then echo "* No subdirs.top available in the $apidoxdir." echo "* The --recurse option will be ignored." recurse=0 fi fifi### Read a single line (TODO: support \ continuations) from the Makefile.am.### Used to extract variable assignments from it.extract_line(){ file="$2" ; test -z "$file" && file="$srcdir/Makefile.am" pattern=`echo "$1" | tr + .` grep "^$1" "$file" | \ sed -e "s+$pattern.*=\s*++"}### Handle the COMPILE_{FIRST,LAST,BEFORE,AFTER} part of Makefile.am### in the toplevel. Copied from admin/cvs.sh. Licence presumed LGPL).create_subdirs(){echo "* Sorting top-level subdirs"dirs=idirs=if test -f "$top_srcdir/inst-apps"; then idirs=`cat "$top_srcdir/"inst-apps`else idirs=`cd "$top_srcdir" && ls -1 | sort`ficompilefirst=""compilelast=""if test -f "$top_srcdir/"Makefile.am.in ; then compilefirst=`sed -ne 's#^COMPILE_FIRST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1` compilelast=`sed -ne 's#^COMPILE_LAST[ ]*=[ ]*##p' "$top_srcdir/"Makefile.am.in | head -n 1`fifor i in $idirs; do if test -f "$top_srcdir/$i"/Makefile.am; then case " $compilefirst $compilelast " in *" $i "*) ;; *) dirs="$dirs $i" esac fidone: > ./_SUBDIRSfor d in $compilefirst; do echo $d >> ./_SUBDIRSdone(for d in $dirs; do list="" if test -f "$top_srcdir/"Makefile.am.in ; then list=`sed -ne "s#^COMPILE_BEFORE_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1` fi for s in $list; do echo $s $d done list="" if test -f "$top_srcdir/"Makefile.am.in ; then list=`sed -ne "s#^COMPILE_AFTER_$d""[ ]*=[ ]*##p" "$top_srcdir/"Makefile.am.in | head -n 1` fi for s in $list; do echo $d $s done echo $d $ddone ) | tsort >> ./_SUBDIRSfor d in $compilelast; do echo $d >> ./_SUBDIRSdonetest -r _SUBDIRS && mv _SUBDIRS subdirs.top || true}### Add HTML header, footer, CSS tags to Doxyfile.### Assumes $subdir is set. Argument is a string### to stick in front of the file if needed.apidox_htmlfiles(){ dox_header="$top_srcdir/doc/api/$1header.html" dox_footer="$top_srcdir/doc/api/$1footer.html" dox_css="$top_srcdir/doc/api/doxygen.css" test -f "$dox_header" || dox_header="$DOXDATA/$1header.html" test -f "$dox_footer" || dox_footer="$DOXDATA/$1footer.html" test -f "$dox_css" || dox_css="$DOXDATA/doxygen.css" echo "HTML_HEADER = $dox_header" >> "$subdir/Doxyfile" ; \ echo "HTML_FOOTER = $dox_footer" >> "$subdir/Doxyfile" ; \ echo "HTML_STYLESHEET = $dox_css" >> "$subdir/Doxyfile"}apidox_specials(){ line=`extract_line DOXYGEN_PROJECTNAME "$1"` test -n "$line" && echo "PROJECT_NAME = \"$line\"" >> "$2"}apidox_local(){ for i in "$top_srcdir/doc/api/Doxyfile.local" do if test -f "$i" ; then cat "$i" >> "$subdir/Doxyfile" break fi done}### Post-process HTML files by substituting in the menu files## In non-top directories, both <!-- menu --> and <!-- gmenu --># are calculated and replaced. Top directories get an empty <!-- menu --># if any.doxyndex(){ # Special case top-level to have an empty MENU. if test "x$subdir" = "x." ; then MENU="" htmldir="." htmltop="$top_builddir" # Just ., presumably echo "* Post-processing top-level files" else MENU="<ul>" htmldir="$subdir/html" htmltop="$top_builddir.." # top_builddir ends with / echo "* Post-processing files in $htmldir" # Build a little PHP file that maps class names to file # names, for the quick-class-picker functionality. # (The quick-class-picker is disabled due to styling # problems in IE & FF). ( echo "<?php \$map = array("; \ for htmlfile in `find $htmldir/ -type f -name "class[A-Z]*.html" | grep -v "\-members.html$"`; do 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]"` echo " \"$classname\" => \"$htmlfile\"," done | sort ; \ echo ") ?>" ) > "$subdir/classmap.inc" # This is a list of pairs, with / separators so we can use # basename and dirname (a crude shell hack) to split them # into parts. For each, if the file part exists (as a html # file) tack it onto the MENU variable as a <li> with link. for i in "Main Page/index" \ "Modules/modules" \ "Namespace List/namespaces" \ "Class Hierarchy/hierarchy" \ "Alphabetical List/classes" \ "Class List/annotated" \ "File List/files" \ "Directories/dirs" \ "Namespace Members/namespacemembers" \ "Class Members/functions" \ "Related Pages/pages" do NAME=`dirname "$i"` FILE=`basename "$i"` test -f "$htmldir/$FILE.html" && MENU="$MENU<li><a href=\"$FILE.html\">$NAME</a></li>" done MENU="$MENU</ul>" fi # Get the list of global Menu entries. GMENU=`cat subdirs | tr -d '\n'` 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'` # Map the PHP file into HTML options so that # it can be substituted in for the quick-class-picker. CMENU="" # For now, leave the CMENU disabled CMENUBEGIN="<!--" CMENUEND="-->" if test "x$subdir" = "x." ; then # Disable CMENU on toplevel anyway CMENUBEGIN="<!--" CMENUEND="-->" else test -f "$subdir/classmap.inc" && \ CMENU=`grep '=>' "$subdir/classmap.inc" | sed -e 's+"\([^"]*\)" => "'"$subdir/html/"'\([^"]*\)"+<option value="\2">\1<\/option>+' | tr -d '\n'` if test -f "$subdir/classmap.inc" && grep "=>" "$subdir/classmap.inc" > /dev/null 2>&1 ; then # Keep the menu, it's useful : else CMENUBEGIN="<!--" CMENUEND="-->" fi fi # Now substitute in the MENU in every file. This depends # on HTML_HEADER (ie. header.html) containing the # <!-- menu --> comment. for i in "$htmldir"/*.html do if test -f "$i" ; then sed -e "s+<!-- menu -->+$MENU+" \ -e "s+<!-- gmenu -->+$GMENU+" \ -e "s+<!-- pmenu.*-->+$PMENU+" \ -e "s+<!-- cmenu.begin -->+$CMENUBEGIN+" \ -e "s+<!-- cmenu.end -->+$CMENUEND+" \ < "$i" | sed -e "s+@topdir@+$htmltop+g" > "$i.new" && mv "$i.new" "$i" sed -e "s+<!-- cmenu -->+$CMENU+" < "$i" > "$i.new" test -s "$i.new" && mv "$i.new" "$i" fi done}### Handle the Doxygen processing of a toplevel directory.apidox_toplevel(){ echo "" echo "*** Creating API documentation main page for $module_name" echo "*" rm -f "Doxyfile" for i in "$top_srcdir/doc/api/Doxyfile.global" \ "$top_srcdir/admin/Doxyfile.global" \ "$DOXDATA/Doxyfile.global" do if test -f "$i" ; then cp "$i" Doxyfile break fi done
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -