Made clicking and dragging on scrollbar seek boxes scroll the widget.
[xuni.git] / doc / percentdoc.pl
blob9bc63e6b946cb89c74bcad510c108d6acfe711c7
1 #!/usr/bin/perl
2 # A script to calculate the number and percentage of entities and functions
3 # that are documented (with Doxygen documentation comments).
5 # It operates by parsing the output of Doxygen. It could break for different
6 # versions of Doxygen -- it is known to work with version 1.5.5.
8 # Written by DWK
10 use strict;
11 use warnings;
13 &process_files('html/*_8c.html');
15 sub process_files {
16 my $pattern = shift;
17 my %total = &new_list();
19 &print_header();
21 foreach my $file (glob $pattern) {
22 my ($srcfile, %count) = &parse_file($file);
23 &print_line($srcfile, %count);
25 foreach my $group (keys %total) {
26 $total{$group}->{'total'} += $count{$group}->{'total'};
27 $total{$group}->{'documented'} += $count{$group}->{'documented'};
31 &print_line(" *** Total ***", %total);
34 sub new_list {
35 my %list = (
36 'all' => {'documented' => 0, 'total' => 0},
37 'static' => {'documented' => 0, 'total' => 0},
38 'normal' => {'documented' => 0, 'total' => 0}
41 return %list;
44 sub parse_file {
45 my $file = shift;
46 my $line = '';
47 my $srcfile = '';
48 my $mode = 'initial';
49 my $name = '';
50 my $section = '';
52 my %count = &new_list();
54 open(FILE, "<$file");
56 while($line = <FILE>) {
57 chomp($line);
59 if($line =~ m|^<title>\w+: (.*) File Reference</title>$|) {
60 $srcfile = $1;
62 elsif($line =~ m|^<hr><h2>(\w+) Documentation</h2>$|) {
63 $section = $1;
66 if($mode eq 'initial') {
67 if($line eq '<div class="memproto">') {
68 $mode = 'findname';
71 elsif($mode eq 'findname') {
72 if($line =~ m|<td class="memname">([^<]+)|) {
73 $name = $1;
74 $name =~ s/^\s+//;
75 $name =~ s/\s+$//;
77 $mode = 'finddoc';
80 elsif($mode eq 'finddoc') {
81 if($line eq '<div class="memdoc">') {
82 $mode = 'findp';
85 elsif($mode eq 'findp') {
86 if($line eq '<p>') {
87 $mode = 'findline';
90 elsif($mode eq 'findline') {
91 my $documented = 0;
92 if($line =~ /\S/) {
93 $documented = 1;
96 $count{'all'}->{'total'} ++;
97 $count{'all'}->{'documented'} ++ if $documented;
99 if($section eq 'Function') {
100 if($name =~ /^static/) {
101 $count{'static'}->{'total'} ++;
102 $count{'static'}->{'documented'} ++ if $documented;
104 else {
105 $count{'normal'}->{'total'} ++;
106 $count{'normal'}->{'documented'} ++ if $documented;
110 $mode = 'initial';
114 close(FILE);
116 return ($srcfile, %count);
119 sub print_header {
120 print " *** Number and percentage of entities and functions "
121 . "that are documented ***\n";
122 printf("%-25s | %-15s | %-15s | %-15s\n",
123 "Source file name", "All entities", "Normal funcs", "Static funcs");
126 sub print_line {
127 my $file = shift;
128 my %count = @_;
130 printf("%-25s", $file);
132 # Do not use a foreach loop because a specific order is desired
133 &print_group('all', %count);
134 &print_group('normal', %count);
135 &print_group('static', %count);
137 print "\n";
140 sub print_group {
141 my $group = shift;
142 my %count = @_;
144 printf(" | %3d/%3d",
145 $count{$group}->{'documented'}, $count{$group}->{'total'});
146 if($count{$group}->{'total'}) {
147 printf(" %6.2f%%",
148 $count{$group}->{'documented'} / $count{$group}->{'total'}
149 * 100.0);
151 else {
152 print " 100.00%";