Home | History | Annotate | Download | only in dbus
      1 #! /bin/sh
      2 
      3 ## This script cleans up private/internal API from the man pages
      4 ## generated by Doxygen.  This brings the man pages down from 7 megs
      5 ## to 2 megs and avoids namespace-polluting man pages.  It's probably
      6 ## pretty specific to GNU utilities. Patches gladly accepted to make
      7 ## it work without them.
      8 
      9 ## You would run this after building dbus and after running "doxygen
     10 ## Doxyfile"
     11 
     12 die() {
     13     echo "$*" 1>&2
     14     exit 1
     15 }
     16 
     17 MANDIR=$1
     18 if test x"$MANDIR" = x ; then
     19     MANDIR=doc/api/man/man3dbus
     20 fi
     21 
     22 cd "$MANDIR" || die "Could not cd to $MANDIR"
     23 
     24 test -d keep || mkdir keep || die "Could not create $MANDIR/keep directory"
     25 test -d nuke || mkdir nuke || die "Could not create $MANDIR/nuke directory"
     26 
     27 ## blacklist
     28 (find . -maxdepth 1 -name "_*" | xargs -I ITEMS /bin/mv ITEMS nuke) || die "could not move all underscore-prefixed items"
     29 (find . -maxdepth 1 -name "DBus*Internal*" | xargs -I ITEMS /bin/mv ITEMS nuke) || die "could not move all internal-containing items"
     30 (find . -maxdepth 1 -name "dbus_*_internal_*" | xargs -I ITEMS /bin/mv ITEMS nuke) || die "could not move all internal-containing items"
     31 
     32 ## this is kind of unmaintainable, but I guess it's no huge disaster if we miss something.
     33 ## this list should only contain man pages with >1 line, i.e. with real content; the 
     34 ## one-line cross-references get cleaned up next.
     35 for I in DBusCounter.* DBusCredentials.* DBusDataSlot.* DBusDataSlotAllocator.* DBusDataSlotList.* \
     36     DBusDirIter.* DBusFakeMutex.* DBusFreedElement.* DBusGroupInfo.* DBusGUID.* DBusHashEntry.* \
     37     DBusHashIter.* DBusHashTable.* DBusHeader.* DBusHeaderField.* DBusKey.* DBusKeyring.* DBusList.* \
     38     DBusMarshal.* DBusMD5* DBusMemBlock.* DBusMemPool.* DBusMessageGenerator.* DBusMessageLoader.* \
     39     DBusMessageRealIter.* DBusObjectSubtree.* DBusObjectTree.* DBusPollFD.* DBusReal* \
     40     DBusResources.* DBusServerDebugPipe.* DBusServerSocket.* DBusServerUnix.* \
     41     DBusServerVTable.* DBusSHA.* DBusSHAContext.* DBusSignatureRealIter.* DBusStat.* DBusString.* \
     42     DBusSysdeps.* DBusSysdepsUnix.* DBusTimeoutList.* DBusTransport* DBusTypeReader* DBusTypeWriter* \
     43     DBusUserInfo.* DBusWatchList.* ; do 
     44     if test -f "$I" ; then
     45         /bin/mv "$I" nuke || die "could not move $I to $MANDIR/nuke"
     46     fi
     47 done
     48 
     49 ## many files just contain ".so man3dbus/DBusStringInternals.3dbus" or the like, 
     50 ## if these point to something we nuked, we want to also nuke the pointer.
     51 for I in * ; do
     52     if test -f "$I" ; then
     53         LINES=`wc -l "$I" | cut -d ' ' -f 1`
     54         if test x"$LINES" = x1 ; then
     55             REF_TO=`cat "$I" | sed -e 's/\.so man3dbus\///g'`
     56             ## echo "$I points to $REF_TO"
     57             if ! test -f "$REF_TO" ; then
     58                 /bin/mv "$I" nuke || die "could not move $I to $MANDIR/nuke"
     59             fi
     60         fi
     61     fi
     62 done
     63 
     64 ## whitelist
     65 (find . -maxdepth 1 -name "dbus_*" | xargs -I ITEMS /bin/mv ITEMS keep) || die "could not move all dbus-prefixed items"
     66 (find . -maxdepth 1 -name "DBUS_*" | xargs -I ITEMS /bin/mv ITEMS keep) || die "could not move all DBUS_-prefixed items"
     67 (find . -maxdepth 1 -name "DBus*" | xargs -I ITEMS /bin/mv ITEMS keep) || die "could not move all DBus-prefixed items"
     68 
     69 ## everything else is assumed irrelevant, this is mostly struct fields
     70 ## from the public headers
     71 (find . -maxdepth 1 -type f | xargs -I ITEMS /bin/mv ITEMS nuke) || die "could not move remaining items"
     72 
     73 NUKE_COUNT=`find nuke -type f -name "*" | wc -l`
     74 KEEP_COUNT=`find keep -type f -name "*" | wc -l`
     75 MISSING_COUNT=`find . -maxdepth 1 -type f -name "*" | wc -l`
     76 
     77 echo "$KEEP_COUNT man pages kept and $NUKE_COUNT man pages to remove"
     78 echo "$MISSING_COUNT not handled"
     79 
     80 (find keep -type f -name "*" | xargs -I ITEMS /bin/mv ITEMS .) || die "could not move kept items back"
     81 
     82 rmdir keep || die "could not remove $MANDIR/keep"
     83 
     84 echo "Man pages to be installed are in $MANDIR and man pages to ignore are in $MANDIR/nuke"
     85 
     86 exit 0
     87