Bio::DB::Universal: move into its own distribution
[bioperl-live.git] / maintenance / authors.pl
blob8783452a7d166deb29b1b6b64c68f25df3fcbc6c
1 #!/usr/bin/perl
3 =head1 NAME
5 authors.pl - check modules and scripts for authors not in AUTHORS file
7 =head1 SYNOPSIS
9 B<authors.pl> [B<-d|--dir> path ] [B<-v|--verbose>] B<-a|--authorsfile>
10 [B<-?|-h|--help>]
12 =head1 DESCRIPTION
14 Checks Plain Old Documentation (POD) of all bioperl live modules for
15 AUTHORS and CONTRIBUTORS tags and prints out any emails missing from
16 the AUTHORS file
18 =cut
20 use Data::Dumper;
21 use File::Find;
22 use Getopt::Long;
23 use strict;
25 sub findauthors;
28 # command line options
31 my ($verbose, $dir, $authorsfile, $help) = (0, undef, "../AUTHORS", undef);
32 GetOptions(
33 'v|verbose' => \$verbose,
34 'dir:s' => \$dir,
35 'authorsfile:s' => \$authorsfile,
36 'h|help|?' => sub{ exec('perldoc',$0); exit(0) }
40 # global variables
43 # known authors from the AUTHORS file are read into
44 # the hash which is initialized with known synonymes
45 our %AUTHORS = map {$_=>1} qw{
46 birney@sanger.ac.uk
47 jinsana@gmx.net
48 Insana@ebi.ac.uk
49 fugui@worf.fugu-sg.org
50 cjm@fruitfly.bdgp.berkeley.edu
51 elia@tll.org.sg
52 heikki-at-bioperl-dot-org
53 bioinformatics@dieselwurks.com
54 bioinformatics1@dieselwurks.com
55 bioperl-l@bio.perl.org
56 paul@systemsbiology.org
57 gattiker@isb-sib.ch
58 elia@fugu-sg.org
59 jason@cgt.mc.duke.edu
60 jason@chg.mc.duke.edu
61 jason@open-bio.org
62 hilmar.lapp@pharma.novartis.com
63 richard.adams@ed.ac.uk
64 dblock@gene.pbi.nrc.ca
65 ak@ebi.ac.uk
66 day@cshl.org
67 bala@tll.org.sg
68 mrp@sanger.ac.uk
69 m.w.e.j.fiers@plant.wag-ur.nl
70 cmzmasek@yahoo.com
71 fuguteam@fugu-sg.org
72 shawnh@gmx.net
74 our %NEWAUTHORS; # new authors
75 our %FIND_OPTIONS = ( wanted => \&findauthors, no_chdir => 1 );
78 # Directories to check
79 my @dirs = qw( ../Bio/ ../scripts . );
81 #print Dumper \%AUTHORS;
84 # Read the AUTHORS file
88 open my $F, '<', $authorsfile or die "Could not read file '$authorsfile': $!\n";
91 while (my $line = <$F>) {
92 my ($email) = ($line =~/([\.\w_-]+ at [\.\w_-]+)/);
93 next unless $email;
94 #print $email, "\n";
95 $email =~ s/ at /@/;
96 $AUTHORS{$email} = 1;
98 close $F;
102 # run
105 if ($dir) {
106 find \%FIND_OPTIONS, $dir;
107 } else {
108 find \%FIND_OPTIONS, @dirs;
112 # results
114 print Dumper \%NEWAUTHORS;
119 ### end main
124 # this is where the action is
126 sub findauthors {
127 my ($filename) = $_;
128 return unless ($filename =~ /\.PLS$/ or $filename =~ /\.p[ml]$/);
129 return unless -e $filename;
131 print "$filename\n" if $verbose;
132 #local $/=undef;
133 open my $F, '<', $filename or die "Could not read file '$filename': $!\n";
134 while (my $line = <$F>) {
135 #print $line;
136 last if $line =~ /=head1 +AUTHOR/;
138 my $authorblock;
139 while (my $line = <$F>) {
140 last if $line =~ /=head/ and $line !~ /CONTRIBUTORS/;
141 $authorblock .= $line;
143 close $F;
144 return unless $authorblock;
146 while ( $authorblock =~ /([\.\w_-]+@[\.a-z_-]+)/g) {
147 #my $email = $1;
148 #$email =~ //
149 next if $AUTHORS{$1};
150 #print "$filename\t$1\n";
152 push @{$NEWAUTHORS{$1}}, $filename;
158 =head1 OPTIONS
160 =over 3
162 =item B<-d | --dir> path
164 Overides the default directories to check by one directory 'path' and
165 all its subdirectories.
167 =item B<-a | --authorsfile>
169 path from working directory the AUTHORS file.
171 Redundant as this information could be had from --dir option butI am
172 feeling too lazy to change the code.
174 =cut
176 sub blankline {
177 my ($file) = @_;
178 return unless ($file =~ /\.PLS$/ or $file =~ /\.p[ml]$/);
179 return unless -e $file;
181 open my $F, '<', $file or warn "Could not read file '$file': $!\n" && return;
182 local $/ = "";
183 while (my $line = <$F>) {
184 print "$file: +|$1|\n" if $line =~ /[ \t]\n(=[a-z][^\n]+$)/m and $verbose;
185 print "$file: ++|$1|\n" if $line =~ /\w\n(=[a-z][^\n]+$)/m and $verbose;
186 print "$file:|$1|+\n" if $line =~ /(^=[a-z][^\n]+)\n[\t ]/m;
187 #print "$file:|$1|++\n" if /(^=[^\n]+)\n\w/m;
189 close $F;
192 __END__
194 =item B<-v | --verbose>
196 Show the progress through files during the POD checking.
198 =item B<-? | -h | --help>
200 This help text.
202 =back
204 =head1 FEEDBACK
206 =head2 Mailing Lists
208 User feedback is an integral part of the evolution of this and other
209 Bioperl modules. Send your comments and suggestions preferably to
210 the Bioperl mailing list. Your participation is much appreciated.
212 bioperl-l@bioperl.org - General discussion
213 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
215 =head2 Reporting Bugs
217 Report bugs to the Bioperl bug tracking system to help us keep track
218 of the bugs and their resolution. Bug reports can be submitted via the
219 web:
221 https://github.com/bioperl/bioperl-live/issues
223 =head1 AUTHOR - Heikki Lehvaslaiho
225 Email heikki-at-bioperl-dot-org
227 =cut
230 # find . -name '*.pm' -print | xargs perl -e '$/=""; while (<>) {$n = $1 if /^package\s+([\w:]+)/; print "$n:|$1|" if /(\s\s^=[^\n]+$)/m ; }' ;
232 # find . -name '*.pm' -print | xargs perl -e '$/=""; while (<>) {$n = $1 if /^package\s+([\w:]+)/; print "$n:|$1|\n" if /(^=[^\n]+\n[\t ])/m ; }' ;