1# Validate the POD documentation in all Perl modules (*.pm) under the 'lib' 2# directory. Prints a warning if no documentation was found (because that 3# probably means you should write some). 4 5use strict; 6use warnings; 7use Test; 8use File::Find; 9use Pod::Checker; 10use File::Temp qw( tempfile ); 11use IO::File; 12 13 14# Each test is for a particular '.pm' file, so we need to find how many 15# there are before we plan the tests. 16my @pm; 17find({ wanted => \&wanted, no_chdir => 1 }, 'lib'); 18 19sub wanted 20{ 21 return unless -f; 22 return unless /\.pm$/; 23 push @pm, $_; 24} 25 26plan tests => scalar @pm; 27 28 29foreach (@pm) { 30 # Warnings are sent to a temporary file. 31 my ($log_file, $log_filename) = tempfile(); 32 33 my $s = podchecker($_, $log_file, '-warnings' => 2); 34 close $log_file; 35 36 warn "\n$_: no documentation.\n" if $s < 0; 37 if ($s > 0) { 38 $log_file = IO::File->new($log_filename, 'r') 39 or die "$0: error rereading log file '$log_filename': $!\n"; 40 my $log = do { local $/; <$log_file> }; 41 warn "\n$log\n"; 42 } 43 44 ok($s <= 0); 45 unlink $log_filename; 46} 47 48# Local Variables: 49# mode: perl 50# perl-indent-level: 3 51# End: 52# vim:ft=perl ts=3 sw=3 expandtab: 53