findAttr.pl 3.06 KB
Newer Older
1 2
#!/usr/bin/perl
use strict;
3

4 5 6
my $IGNORE = join(
    '|', qw(
      csr urldc cfgNum p (?:s|rS)essionInfo dn user mustRedirect password dbi\w+
Xavier Guimard's avatar
Xavier Guimard committed
7
      reVHosts stack timezone vident _\w+ lmConf table (?:st|db)h res id
8 9 10
      refLocalStorage User Password args conf generate mdone obj error
      authChoiceModules deleted entry macros modules notifObject menuModules
      mailSessionKey mail logoutServices ns service modified force menuError
Xavier Guimard's avatar
Xavier Guimard committed
11 12
      cookie SOAPMessage clean func local noQuotes categories noCache

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
      )
);

my ( $attr, $attrFile );

foreach my $module (qw(common handler manager portal)) {
    open CMD,
      "find lemonldap-ng-$module/lib/Lemonldap/NG -type f -name '*.pm'|";
    my @files;
    while (<CMD>) {
        chomp;
        push @files, $_;
    }
    close CMD;

 #    my @files = qw(lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthChoice.pm);
    foreach my $file (@files) {

        # Ignode old liberty-Alliance
        next if ( $file =~ m#Portal/AuthLA.pm$# );
        next if ( $file =~ /_Struct/ );
        open F, $file;
        $file =~ s#.*/NG/##;
        my $autoload = 0;
Xavier Guimard's avatar
Xavier Guimard committed
37
        my $pod = 0;
38 39
        while (<F>) {
            $autoload = 1 if (/use\s+AutoLoader/);
Xavier Guimard's avatar
Xavier Guimard committed
40 41 42 43
            if(/^=/) {
                if(/^=cut/){$pod=0;}else{$pod=1};
            }
            next if($pod);
44
            last if ( /^__END__$/ and not $autoload );
45
            if (/\$(?:self|args)->\{\s*(\w+)\s*\}/) {
46
                my $k = $1;
47
                unless ( $k =~ /^$IGNORE$/o ) {
48 49 50 51 52 53 54 55 56 57 58 59
                    $attr->{$module}->{$1}++;
                    $attrFile->{$module}->{$1}->{$file}++;
                }
            }
        }
        close F;
    }

    #use Data::Dumper;
    #print Dumper($attr);
}

60 61 62 63 64 65 66 67
open F, 'doc/pages/documentation/latest/parameterlist.html';
my $documentedAttr;
while (<F>) {
    next unless (/<td class="col1.*?">\s*(\w+)\s*<\/td>/);
    $documentedAttr->{$1}++;
}
close F;

68 69
open F, 'lemonldap-ng-manager/lib/Lemonldap/NG/Manager/_Struct.pm';
my $managedAttr;
Xavier Guimard's avatar
Xavier Guimard committed
70
my $buf;
71
while (<F>) {
72 73 74
    $buf = '' if ( $buf =~ /,$/ );
    $buf .= $_;
    $managedAttr->{$1}++ if ( $buf =~ /=>\s*'\w+:\/(\w+)/s );
75
}
76 77 78 79


close F;
my ( $unmanagedAttr, $undocumentedAttr );
80 81 82 83 84 85 86 87
foreach my $module (qw(common handler manager portal)) {
    foreach my $k ( keys %{ $attr->{$module} } ) {

        # Parameter that must not be documented
        #next if ( $k =~ /^$IGNORE$/ );
        unless ( defined( $managedAttr->{$k} ) ) {
            $unmanagedAttr->{$module}->{$k}++;
        }
88 89 90
        unless ( defined( $documentedAttr->{$k} ) ) {
            $undocumentedAttr->{$module}->{$k}++;
        }
91 92 93

        # TODO: scan doc/4.1-Configuration-parameter-list.html
    }
94
    print "\n##### ".uc($module)." #####\n\n### Unmanaged ###\n";
95 96 97 98
    foreach my $k ( sort keys %{ $unmanagedAttr->{$module} } ) {
        print "$k => "
          . join( ', ', keys( %{ $attrFile->{$module}->{$k} } ) ) . "\n";
    }
99 100 101 102 103
    print "\n### Undocumented ###\n";
    foreach my $k ( sort keys %{ $undocumentedAttr->{$module} } ) {
        print "$k => "
          . join( ', ', keys( %{ $attrFile->{$module}->{$k} } ) ) . "\n";
    }
104 105
}