OSDN Git Service

(split) LDP: (Makefile) Make draft/release/stats per-po file processing
[linuxjm/LDP_man-pages.git] / tools / generate-list.pl
1 #!/usr/bin/env perl
2
3 use File::Basename qw/basename/;
4
5 $debug = 0;
6 $page_count = 0;
7
8 sub print_header {
9     print <<EOF;
10 <HTML>
11 <HEAD><TITLE>Translation status of LDP man-pages</TITLE>
12 <STYLE type="text/css">
13 <!--
14  tr.over80 { background-color: #AAFFAA; }
15  tr.over70 { background-color: #FFAAFF; }
16 -->
17 </STYLE>
18 </HEAD>
19 <BODY>
20 <TABLE BORDER=1>
21 <TR class=\"over80\"><TD COLSPAN=3>Released pages but not completed (released if &gt;=80%)</TD></TR>
22 <TR class=\"over70\"><TD COLSPAN=3>Near release pages (&gt;= 70%)</TD></TR>
23 <TR><TH>page name</TH><TH>remaining</TH><TH>comp. %</TH></TR>
24 EOF
25 }
26
27 sub print_footer {
28     print <<EOF;
29 <TR><TD COLSPAN=3>Total $page_count pages</TD></TR>
30 </TABLE>
31 </BODY></HTML>
32 EOF
33 }
34
35 sub print_poname {
36     my $poname = shift;
37     printf("<TR><TD ALIGN=\"center\" COLSPAN=3 BGCOLOR=\"Yellow\">" .
38            "<B>%s</B></TD></TR>\n", $poname);
39 }
40
41 sub print_manpage {
42     my ($page, $all, $remaining, $ratio) = @_;
43     if ($ratio >= 80) {
44         print '<TR class="over80">';
45     } elsif ($ratio >= 70) {
46         print '<TR class="over70">';
47     } else {
48         print '<TR>';
49     }
50     printf("<TD>%s</TD><TD>%d/%d</TD><TD>%.2f</TD>",
51            $page, $remaining, $all, $ratio);
52     print "</TR>\n";
53 }
54
55 sub process_postat {
56     my $postat = shift;
57     my $poname = basename($postat);
58     my $poname_print = 1;
59
60     open(POSTAT, $postat);
61     while (<POSTAT>) {
62         next if /^#/;
63         # format: pagename, #complete, #remaining, #total
64         my ($page, $comp, $remaining, $total) = split(',');
65         $ratio = $comp / $total * 100;
66         if ($poname_print) {
67             print_poname($poname);
68             $poname_print = 0;
69         }
70         print_manpage($page, $total, $remaining, $ratio);
71         $page_count++;
72     }
73 }
74
75 print_header();
76 foreach my $name (@ARGV) {
77     print STDERR "$name...\n" if $debug;
78     process_postat($name);
79 }
80 print_footer();