1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#!/bin/bash
function write_tags
{
cd "$basedoc"
echo "<?xml version='1.0' encoding='ISO-8859-1' standalone='yes'?>"
echo "<tagfile>"
for d in $docdirs
do
for f in $(find $d -name Reference.html)
do
xmllint --html --format $f 2> /dev/null | awk -v htmlfile=$f '
function compound( kind )
{
if ( match( $0, /title="[^"]*"/) )
{
cl = substr($0, RSTART+7, RLENGTH-8);
print "<compound kind=\"" kind "\" objc=\"yes\">" ;
if ( kind == "protocol" )
print "<name>" cl "-p</name>" ;
else
print "<name>" cl "</name>" ;
print "<filename>" htmlfile "</filename>" ;
inCompound = 1;
}
}
function inherit( trail )
{
if ( inCompound &&
match( $0, /logicalPath="\/\/apple_ref\/occ\/cl\/[^"]*"/) )
{
cl = substr($0, RSTART+32, RLENGTH-33);
print( " <base>" cl "</base>" );
}
}
BEGIN { inCompound = 0 }
END \
{
if ( inCompound )
print "</compound>";
inCompound = 0;
}
/<a name="\/\/apple_ref\/occ\/cl\// { compound( "class" ) }
/<a name="\/\/apple_ref\/occ\/cat\// { compound( "category" ) }
/<a name="\/\/apple_ref\/occ\/intf\// { compound( "protocol" ) }
/^from:.*logicalPath="\/\/apple_ref\/occ\/cl\// { inherit( "" ) }
'
done
done
echo "</tagfile>"
}
if [ $# -lt 3 ]
then
echo "Usage $0 tagfile base dir [dir ...]"
exit 1
fi
export tagfile=$1
shift
export basedoc="$1"
shift
export docdirs=$*
echo -n > $tagfile
write_tags >> $tagfile
|