source: for-distributions/trunk/bin/windows/perl/bin/podchecker.bat@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

File size: 4.0 KB
Line 
1@rem = '--*-Perl-*--
2@echo off
3if "%OS%" == "Windows_NT" goto WinNT
4perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
5goto endofperl
6:WinNT
7perl -x -S %0 %*
8if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
9if %errorlevel% == 9009 echo You do not have Perl in your PATH.
10if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
11goto endofperl
12@rem ';
13#!perl
14#line 15
15 eval 'exec perl -S $0 "$@"'
16 if 0;
17#############################################################################
18# podchecker -- command to invoke the podchecker function in Pod::Checker
19#
20# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved.
21# This file is part of "PodParser". PodParser is free software;
22# you can redistribute it and/or modify it under the same terms
23# as Perl itself.
24#############################################################################
25
26use strict;
27#use diagnostics;
28
29=head1 NAME
30
31podchecker - check the syntax of POD format documentation files
32
33=head1 SYNOPSIS
34
35B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...]
36
37=head1 OPTIONS AND ARGUMENTS
38
39=over 8
40
41=item B<-help>
42
43Print a brief help message and exit.
44
45=item B<-man>
46
47Print the manual page and exit.
48
49=item B<-warnings> B<-nowarnings>
50
51Turn on/off printing of warnings. Repeating B<-warnings> increases the
52warning level, i.e. more warnings are printed. Currently increasing to
53level two causes flagging of unescaped "E<lt>,E<gt>" characters.
54
55=item I<file>
56
57The pathname of a POD file to syntax-check (defaults to standard input).
58
59=back
60
61=head1 DESCRIPTION
62
63B<podchecker> will read the given input files looking for POD
64syntax errors in the POD documentation and will print any errors
65it find to STDERR. At the end, it will print a status message
66indicating the number of errors found.
67
68Directories are ignored, an appropriate warning message is printed.
69
70B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
71Please see L<Pod::Checker/podchecker()> for more details.
72
73=head1 RETURN VALUE
74
75B<podchecker> returns a 0 (zero) exit status if all specified
76POD files are ok.
77
78=head1 ERRORS
79
80B<podchecker> returns the exit status 1 if at least one of
81the given POD files has syntax errors.
82
83The status 2 indicates that at least one of the specified
84files does not contain I<any> POD commands.
85
86Status 1 overrides status 2. If you want unambigouus
87results, call B<podchecker> with one single argument only.
88
89=head1 SEE ALSO
90
91L<Pod::Parser> and L<Pod::Checker>
92
93=head1 AUTHORS
94
95Please report bugs using L<http://rt.cpan.org>.
96
97Brad Appleton E<lt>[email protected]<gt>,
98Marek Rouchal E<lt>[email protected]<gt>
99
100Based on code for B<Pod::Text::pod2text(1)> written by
101Tom Christiansen E<lt>[email protected]<gt>
102
103=cut
104
105
106use Pod::Checker;
107use Pod::Usage;
108use Getopt::Long;
109
110## Define options
111my %options;
112
113## Parse options
114GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2);
115pod2usage(1) if ($options{help});
116pod2usage(-verbose => 2) if ($options{man});
117
118if($options{nowarnings}) {
119 $options{warnings} = 0;
120}
121elsif(!defined $options{warnings}) {
122 $options{warnings} = 1; # default is warnings on
123}
124
125## Dont default to STDIN if connected to a terminal
126pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
127
128## Invoke podchecker()
129my $status = 0;
130@ARGV = qw(-) unless(@ARGV);
131for my $podfile (@ARGV) {
132 if($podfile eq '-') {
133 $podfile = "<&STDIN";
134 }
135 elsif(-d $podfile) {
136 warn "podchecker: Warning: Ignoring directory '$podfile'\n";
137 next;
138 }
139 my $errors =
140 podchecker($podfile, undef, '-warnings' => $options{warnings});
141 if($errors > 0) {
142 # errors occurred
143 $status = 1;
144 printf STDERR ("%s has %d pod syntax %s.\n",
145 $podfile, $errors,
146 ($errors == 1) ? "error" : "errors");
147 }
148 elsif($errors < 0) {
149 # no pod found
150 $status = 2 unless($status);
151 print STDERR "$podfile does not contain any pod commands.\n";
152 }
153 else {
154 print STDERR "$podfile pod syntax OK.\n";
155 }
156}
157exit $status;
158
159
160__END__
161:endofperl
Note: See TracBrowser for help on using the repository browser.