1 | @rem = '--*-Perl-*--
|
---|
2 | @echo off
|
---|
3 | if "%OS%" == "Windows_NT" goto WinNT
|
---|
4 | perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
---|
5 | goto endofperl
|
---|
6 | :WinNT
|
---|
7 | perl -x -S %0 %*
|
---|
8 | if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
|
---|
9 | if %errorlevel% == 9009 echo You do not have Perl in your PATH.
|
---|
10 | if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
|
---|
11 | goto 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 |
|
---|
26 | use strict;
|
---|
27 | #use diagnostics;
|
---|
28 |
|
---|
29 | =head1 NAME
|
---|
30 |
|
---|
31 | podchecker - check the syntax of POD format documentation files
|
---|
32 |
|
---|
33 | =head1 SYNOPSIS
|
---|
34 |
|
---|
35 | B<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 |
|
---|
43 | Print a brief help message and exit.
|
---|
44 |
|
---|
45 | =item B<-man>
|
---|
46 |
|
---|
47 | Print the manual page and exit.
|
---|
48 |
|
---|
49 | =item B<-warnings> B<-nowarnings>
|
---|
50 |
|
---|
51 | Turn on/off printing of warnings. Repeating B<-warnings> increases the
|
---|
52 | warning level, i.e. more warnings are printed. Currently increasing to
|
---|
53 | level two causes flagging of unescaped "E<lt>,E<gt>" characters.
|
---|
54 |
|
---|
55 | =item I<file>
|
---|
56 |
|
---|
57 | The pathname of a POD file to syntax-check (defaults to standard input).
|
---|
58 |
|
---|
59 | =back
|
---|
60 |
|
---|
61 | =head1 DESCRIPTION
|
---|
62 |
|
---|
63 | B<podchecker> will read the given input files looking for POD
|
---|
64 | syntax errors in the POD documentation and will print any errors
|
---|
65 | it find to STDERR. At the end, it will print a status message
|
---|
66 | indicating the number of errors found.
|
---|
67 |
|
---|
68 | Directories are ignored, an appropriate warning message is printed.
|
---|
69 |
|
---|
70 | B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
|
---|
71 | Please see L<Pod::Checker/podchecker()> for more details.
|
---|
72 |
|
---|
73 | =head1 RETURN VALUE
|
---|
74 |
|
---|
75 | B<podchecker> returns a 0 (zero) exit status if all specified
|
---|
76 | POD files are ok.
|
---|
77 |
|
---|
78 | =head1 ERRORS
|
---|
79 |
|
---|
80 | B<podchecker> returns the exit status 1 if at least one of
|
---|
81 | the given POD files has syntax errors.
|
---|
82 |
|
---|
83 | The status 2 indicates that at least one of the specified
|
---|
84 | files does not contain I<any> POD commands.
|
---|
85 |
|
---|
86 | Status 1 overrides status 2. If you want unambigouus
|
---|
87 | results, call B<podchecker> with one single argument only.
|
---|
88 |
|
---|
89 | =head1 SEE ALSO
|
---|
90 |
|
---|
91 | L<Pod::Parser> and L<Pod::Checker>
|
---|
92 |
|
---|
93 | =head1 AUTHORS
|
---|
94 |
|
---|
95 | Please report bugs using L<http://rt.cpan.org>.
|
---|
96 |
|
---|
97 | Brad Appleton E<lt>[email protected]<gt>,
|
---|
98 | Marek Rouchal E<lt>[email protected]<gt>
|
---|
99 |
|
---|
100 | Based on code for B<Pod::Text::pod2text(1)> written by
|
---|
101 | Tom Christiansen E<lt>[email protected]<gt>
|
---|
102 |
|
---|
103 | =cut
|
---|
104 |
|
---|
105 |
|
---|
106 | use Pod::Checker;
|
---|
107 | use Pod::Usage;
|
---|
108 | use Getopt::Long;
|
---|
109 |
|
---|
110 | ## Define options
|
---|
111 | my %options;
|
---|
112 |
|
---|
113 | ## Parse options
|
---|
114 | GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2);
|
---|
115 | pod2usage(1) if ($options{help});
|
---|
116 | pod2usage(-verbose => 2) if ($options{man});
|
---|
117 |
|
---|
118 | if($options{nowarnings}) {
|
---|
119 | $options{warnings} = 0;
|
---|
120 | }
|
---|
121 | elsif(!defined $options{warnings}) {
|
---|
122 | $options{warnings} = 1; # default is warnings on
|
---|
123 | }
|
---|
124 |
|
---|
125 | ## Dont default to STDIN if connected to a terminal
|
---|
126 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
|
---|
127 |
|
---|
128 | ## Invoke podchecker()
|
---|
129 | my $status = 0;
|
---|
130 | @ARGV = qw(-) unless(@ARGV);
|
---|
131 | for 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 | }
|
---|
157 | exit $status;
|
---|
158 |
|
---|
159 |
|
---|
160 | __END__
|
---|
161 | :endofperl
|
---|