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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#!@PERL_PATH@
# -*- perl -*-
#
# Script that checks which functions are documented in the manual.
#
# $Id: checkdoc.in,v 1.7 1998/07/16 15:55:21 ssb Exp $
#
# Author: Stig Bakken <ssb@guardian.no>
#
$dir = "functions";
$funclist = "funclist.txt";
@sgml_files = &glob($dir, "\\.sgml\$");
&check_functions(@sgml_files);
if ($ARGV[0] eq '-m') {
foreach $function (sort @functions) {
next if ($func_in_file{$function});
print "$function\n";
}
} else {
printf("%-32s %s\n", "FUNCTION NAME", "DOCUMENTED IN");
print "-" x 70, "\n";
foreach $function (sort @functions) {
printf("%-32s %s\n", $function, $func_in_file{$function});
}
@fif = keys %func_in_file;
$n_functions = $#functions + 1;
$n_documented = $#fif + 1;
$percent_done = int(($n_documented * 100) / $n_functions);
printf("\n%d of %d functions documented (%d%% done, %d%% remaining).\n",
$n_documented, $n_functions, $percent_done, 100-$percent_done);
}
foreach $func (@functions) {
$in_funclist{$func}++;
}
foreach $func (sort keys %func_in_file) {
next if $in_funclist{$func};
print STDERR "possibly missing in $funclist: $func (documented in ".
$func_in_file{$func} . ")\n";
}
### Subroutines:
sub glob {
my $dir = shift;
my $pattern = shift;
my @f = ();
if (opendir(DIR, $dir)) {
foreach $file (readdir(DIR)) {
next unless ($file =~ m/$pattern/);
push(@f, $file);
}
close DIR;
}
return @f;
}
sub check_functions {
foreach $sgml_file (@_) {
$path = "$dir/$sgml_file";
if (open(SGML, $path)) {
while (<SGML>) {
next unless (m!(^|\s+)id\s*=\s*(['\"])([^\2]*?)\2\s*!);
$func = $3;
next unless ($func =~ s!^(function|class)\.!!);
$func =~ s/-/_/g;
$func_in_file{$func} = $sgml_file;
}
} else {
warn "Could not open $path\n";
}
}
if (open(FUNCLIST, $funclist)) {
while (<FUNCLIST>) {
next if /^#/;
s!\s*!!g;
$len = length($_);
$longest = $len if ($len > $longest);
push(@functions, $_);
}
}
}
|