#!/usr/local/bin/perl -w
#
# Examine the dictionary and note what remains to be done.
#

use APIdict;

$dict = new APIdict("api.list");

@items = $dict->entity_list();
foreach (@items) {
    push(@temp, $_)
        if ($dict->category($_) ne 'X');
}
@items = sort {uc($a) cmp uc($b)} (@temp);

#
# First, find out which ones don't even have definitions..
#
@missing_def = ();
foreach (@items) {
    push(@missing_def, $_)
        if (! $dict->definition($_));
}

#
# Now find out which ones need one or more examples.
#
@missing_example = ();
foreach (@items) {
    push(@missing_example, $_)
        if (! $dict->example($_));
}

#
# Finally, the ones that don't have a description.
#
@missing_desc = ();
@missing_dfile = ();
foreach (@items) {
    my($file) = $dict->description_file($_);
    if ($file && (! -r $file)) {
        push(@missing_dfile, $_);
    }
    elsif ((! $file) && (! $dict->description($_))) {
        push(@missing_desc, $_);
    }
}

#
# Now display the results.
#
if (@missing_def) {
    print "The following items need definitions:\n";
    foreach (@missing_def) {
        print " $_\n";
    }
}

if (@missing_example) {
    print "The following items need examples:\n";
    foreach (@missing_example) {
        print " $_\n";
    }
}

if (@missing_dfile) {
    print "The following items have defined detail files that don't exist:\n";
    foreach (@missing_dfile) {
        print " $_\n";
    }
}

if (@missing_desc) {
    my($reconnect) = 0;
    print "The following items have no descriptions nor detail files:\n";
    foreach (@missing_desc) {
        print " $_\n";
    }
    foreach (@missing_desc) {
        if (-r "dict-$_.html") {
            print "The following items have become disconnected from their "
                . "detail files:\n"
                    if (! $reconnect);
            $reconnect++;
            print " $_\n";
        }
    }
}
