Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
podchecker149 linesDownload Raw Back to core_perl
1#!/usr/bin/perl2    eval 'exec perl -S $0 "$@"'3        if 0;4#############################################################################5# podchecker -- command to invoke the podchecker function in Pod::Checker6#7# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved.8# This is free software; you can redistribute it and/or modify it under the9# same terms as Perl itself.10#############################################################################11 12use strict;13#use diagnostics;14 15=head1 NAME16 17podchecker - check the syntax of POD format documentation files18 19=head1 SYNOPSIS20 21B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...]22 23=head1 OPTIONS AND ARGUMENTS24 25=over 826 27=item B<-help>28 29Print a brief help message and exit.30 31=item B<-man>32 33Print the manual page and exit.34 35=item B<-quiet>36 37Do not print a success message.38 39=item B<-warnings> B<-nowarnings>40 41Turn on/off printing of warnings. Repeating B<-warnings> increases the42warning level, i.e. more warnings are printed. Currently increasing to43level two causes flagging of unescaped "E<lt>,E<gt>" characters.44 45=item I<file>46 47The pathname of a POD file to syntax-check (defaults to standard input).48 49=back50 51=head1 DESCRIPTION52 53B<podchecker> will read the given input files looking for POD54syntax errors in the POD documentation and will print any errors55it find to STDERR. At the end, it will print a status message56indicating the number of errors found.57 58Directories are ignored, an appropriate warning message is printed.59 60B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>61Please see L<Pod::Checker/podchecker()> for more details.62 63=head1 RETURN VALUE64 65B<podchecker> returns a 0 (zero) exit status if all specified66POD files are ok.67 68=head1 ERRORS69 70B<podchecker> returns the exit status 1 if at least one of71the given POD files has syntax errors.72 73The status 2 indicates that at least one of the specified 74files does not contain I<any> POD commands.75 76Status 1 overrides status 2. If you want unambiguous77results, call B<podchecker> with one single argument only.78 79=head1 SEE ALSO80 81L<Pod::Simple> and L<Pod::Checker>82 83=head1 AUTHORS84 85Please report bugs using L<http://rt.cpan.org>.86 87Brad Appleton E<lt>bradapp@enteract.comE<gt>,88Marek Rouchal E<lt>marekr@cpan.orgE<gt>89 90Based on code for B<Pod::Text::pod2text(1)> written by91Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>92 93=cut94 95 96use Pod::Checker;97use Pod::Usage;98use Getopt::Long;99 100## Define options101my %options;102 103## Parse options104GetOptions(\%options, qw(help man quiet warnings+ nowarnings))  ||  pod2usage(2);105pod2usage(1)  if ($options{help});106pod2usage(-verbose => 2)  if ($options{man});107 108if($options{nowarnings}) {109  $options{warnings} = 0;110}111elsif(!defined $options{warnings}) {112  $options{warnings} = 1; # default is warnings on113}114 115## Dont default to STDIN if connected to a terminal116pod2usage(2) if ((@ARGV == 0) && (-t STDIN));117 118## Invoke podchecker()119my $status = 0;120@ARGV = qw(-) unless(@ARGV);121for my $podfile (@ARGV) {122    if($podfile eq '-') {123      $podfile = '<&STDIN';124    }125    elsif(-d $podfile) {126      warn "podchecker: Warning: Ignoring directory '$podfile'\n";127      next;128    }129    my $errors =130      podchecker($podfile, undef, '-warnings' => $options{warnings});131    if($errors > 0) {132        # errors occurred133        $status = 1;134        printf STDERR ("%s has %d pod syntax %s.\n",135          $podfile, $errors,136          ($errors == 1) ? 'error' : 'errors');137    }138    elsif($errors < 0) {139        # no pod found140        $status = 2 unless($status);141        print STDERR "$podfile does not contain any pod commands.\n";142    }143    else {144        print "$podfile pod syntax OK.\n" unless $options{quiet};145    }146}147exit $status;148 149 
codekingpro/portable-devtools · Team Ai