Annotation of doc/help/usage.pl, revision 1.2
1.1 albertel 1: #!/usr/bin/perl
2: use strict;
3:
4: use HTML::TokeParser;
5: use Getopt::Long;
6:
7: my ($help) = (0,0,0);
8: &GetOptions( "help" => \$help);
9:
10: sub get_all_files {
11: my $dir="../../loncom/html/adm/help/tex/";
12: opendir(DIR,$dir);
13: my @files=sort {uc($a) cmp uc($b)} (readdir(DIR));
14: return @files;
15: }
16:
17: sub get_usage {
18: my ($which)=@_;
19: my @files;
20: my $p = HTML::TokeParser->new("$which.manual.texxml");
21: while (my $token = $p->get_token()) {
22: if ($token->[0] eq 'S' && $token->[1] eq 'file') {
23: push(@files,$token->[2]{'name'});
24: }
25: }
26: return @files;
27: }
28:
29: sub print_unused {
30: my ($all,$usage)=@_;
31: my %all;
32: my %no_exist;
1.2 ! albertel 33: foreach my $file (@{ $all }) {$all{$file}=[];}
! 34: my @order=('author','course','developer');
1.1 albertel 35: foreach my $list (@{ $usage }) {
36: foreach my $file (@{ $list }) {
1.2 ! albertel 37: if (exists($all{$file})) {
! 38: push(@{$all{$file}},$order[0]);
! 39: } else {
! 40: push(@{$no_exist{$file}},$order[0]);
! 41: }
1.1 albertel 42: }
1.2 ! albertel 43: shift(@order);
1.1 albertel 44: }
45: print("Usage count for existing Files:\n");
46: foreach my $file (sort {uc($a) cmp uc($b)} (keys(%all))) {
1.2 ! albertel 47: if (scalar(@{ $all{$file} }) ne 0) {
! 48: printf("%-50s: %s in %s\n",$file,scalar(@{$all{$file}}),
! 49: join(',',@{$all{$file}}));
! 50: } else {
! 51: printf("%-50s: %s\n",$file,scalar(@{$all{$file}}));
! 52: }
1.1 albertel 53: }
54: print("Usage count for nonexistint Files:\n");
55: foreach my $file (sort {uc($a) cmp uc($b)} (keys(%no_exist))) {
1.2 ! albertel 56: printf("%-50s: %s in %s\n",$file,scalar(@{$no_exist{$file}}),
! 57: join(',',@{$no_exist{$file}}));
1.1 albertel 58: }
59: }
60:
61: sub main {
62: my @all_files=&get_all_files();
63: my @author_usage=&get_usage('author');
64: my @course_usage=&get_usage('course');
65: my @developer_usage=&get_usage('developer');
66:
67: &print_unused(\@all_files,[\@author_usage,\@course_usage,
68: \@developer_usage]);
69: }
70:
71: &main;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>