#!/bin/bash
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

# This script assumes it is located in the bin directory of Archetypes
# Copied from the Zope3 sources. Thx for this nice utility :)


PYTHON=`which python2.3`

PATTERN=' (XXX|TODO|BBB)[: ]'
TMPFILE=`mktemp -t /tmp` 
TARGET=${1:-XXXreport.html}
PRODUCTBASE=`dirname $0`/../
BASE=`dirname $0`

# find also finds hidden files
rm $TARGET
find $PRODUCTBASE -type f -and -not -name "*.pyc" -and -not -path "*/.svn/*" -and -not -path "*/CVS/*" -print0  | \
    xargs -0 grep -niIs -A 3 -E "$PATTERN" | \
    $PYTHON $BASE/XXXreport2html.py /dev/stdin $TARGET >/dev/null
    
rm -f $TMPFILE

