1#!/usr/local/bin/perl 2 3use Config; 4use File::Basename qw(&basename &dirname); 5use Cwd; 6 7# List explicitly here the variables you want Configure to 8# generate. Metaconfig only looks for shell variables, so you 9# have to mention them as if they were shell variables, not 10# %Config entries. Thus you write 11# $startperl 12# to ensure Configure will look for $Config{startperl}. 13 14# This forces PL files to create target in same directory as PL file. 15# This is so that make depend always knows where to find PL derivatives. 16$origdir = cwd; 17chdir(dirname($0)); 18($file = basename($0)) =~ s/\.PL$//; 19$file =~ s/\.pl$// 20 if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" 21$file .= '.com' if $^O eq 'VMS'; 22 23open OUT,">$file" or die "Can't create $file: $!"; 24 25print "Extracting $file (with variable substitutions)\n"; 26 27# In this section, perl variables will be expanded during extraction. 28# You can use $Config{...} to use Configure variables. 29 30print OUT <<"!GROK!THIS!"; 31$Config{'startperl'} 32 eval 'exec perl -S \$0 "\$@"' 33 if 0; 34!GROK!THIS! 35 36# In the following, perl variables are not expanded during extraction. 37 38print OUT <<'!NO!SUBS!'; 39############################################################################# 40# podchecker -- command to invoke the podchecker function in Pod::Checker 41# 42# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. 43# This is free software; you can redistribute it and/or modify it under the 44# same terms as Perl itself. 45############################################################################# 46 47use strict; 48#use diagnostics; 49 50=head1 NAME 51 52podchecker - check the syntax of POD format documentation files 53 54=head1 SYNOPSIS 55 56B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] 57 58=head1 OPTIONS AND ARGUMENTS 59 60=over 8 61 62=item B<-help> 63 64Print a brief help message and exit. 65 66=item B<-man> 67 68Print the manual page and exit. 69 70=item B<-warnings> B<-nowarnings> 71 72Turn on/off printing of warnings. Repeating B<-warnings> increases the 73warning level, i.e. more warnings are printed. Currently increasing to 74level two causes flagging of unescaped "E<lt>,E<gt>" characters. 75 76=item I<file> 77 78The pathname of a POD file to syntax-check (defaults to standard input). 79 80=back 81 82=head1 DESCRIPTION 83 84B<podchecker> will read the given input files looking for POD 85syntax errors in the POD documentation and will print any errors 86it find to STDERR. At the end, it will print a status message 87indicating the number of errors found. 88 89Directories are ignored, an appropriate warning message is printed. 90 91B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> 92Please see L<Pod::Checker/podchecker()> for more details. 93 94=head1 RETURN VALUE 95 96B<podchecker> returns a 0 (zero) exit status if all specified 97POD files are ok. 98 99=head1 ERRORS 100 101B<podchecker> returns the exit status 1 if at least one of 102the given POD files has syntax errors. 103 104The status 2 indicates that at least one of the specified 105files does not contain I<any> POD commands. 106 107Status 1 overrides status 2. If you want unambiguous 108results, call B<podchecker> with one single argument only. 109 110=head1 SEE ALSO 111 112L<Pod::Simple> and L<Pod::Checker> 113 114=head1 AUTHORS 115 116Please report bugs using L<http://rt.cpan.org>. 117 118Brad Appleton E<lt>bradapp@enteract.comE<gt>, 119Marek Rouchal E<lt>marekr@cpan.orgE<gt> 120 121Based on code for B<Pod::Text::pod2text(1)> written by 122Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> 123 124=cut 125 126 127use Pod::Checker; 128use Pod::Usage; 129use Getopt::Long; 130 131## Define options 132my %options; 133 134## Parse options 135GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2); 136pod2usage(1) if ($options{help}); 137pod2usage(-verbose => 2) if ($options{man}); 138 139if($options{nowarnings}) { 140 $options{warnings} = 0; 141} 142elsif(!defined $options{warnings}) { 143 $options{warnings} = 1; # default is warnings on 144} 145 146## Dont default to STDIN if connected to a terminal 147pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 148 149## Invoke podchecker() 150my $status = 0; 151@ARGV = qw(-) unless(@ARGV); 152for my $podfile (@ARGV) { 153 if($podfile eq '-') { 154 $podfile = '<&STDIN'; 155 } 156 elsif(-d $podfile) { 157 warn "podchecker: Warning: Ignoring directory '$podfile'\n"; 158 next; 159 } 160 my $errors = 161 podchecker($podfile, undef, '-warnings' => $options{warnings}); 162 if($errors > 0) { 163 # errors occurred 164 $status = 1; 165 printf STDERR ("%s has %d pod syntax %s.\n", 166 $podfile, $errors, 167 ($errors == 1) ? 'error' : 'errors'); 168 } 169 elsif($errors < 0) { 170 # no pod found 171 $status = 2 unless($status); 172 print STDERR "$podfile does not contain any pod commands.\n"; 173 } 174 else { 175 print STDERR "$podfile pod syntax OK.\n"; 176 } 177} 178exit $status; 179 180!NO!SUBS! 181 182close OUT or die "Can't close $file: $!"; 183chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 184exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 185chdir $origdir; 186