Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #!/import/bw/tools/local/perl-5.8.0/bin/perl |
2 | eval 'exec perl -S $0 "$@"' | |
3 | if 0; | |
4 | ############################################################################# | |
5 | # podchecker -- command to invoke the podchecker function in Pod::Checker | |
6 | # | |
7 | # Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. | |
8 | # This file is part of "PodParser". PodParser is free software; | |
9 | # you can redistribute it and/or modify it under the same terms | |
10 | # as Perl itself. | |
11 | ############################################################################# | |
12 | ||
13 | use strict; | |
14 | #use diagnostics; | |
15 | ||
16 | =head1 NAME | |
17 | ||
18 | podchecker - check the syntax of POD format documentation files | |
19 | ||
20 | =head1 SYNOPSIS | |
21 | ||
22 | B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] | |
23 | ||
24 | =head1 OPTIONS AND ARGUMENTS | |
25 | ||
26 | =over 8 | |
27 | ||
28 | =item B<-help> | |
29 | ||
30 | Print a brief help message and exit. | |
31 | ||
32 | =item B<-man> | |
33 | ||
34 | Print the manual page and exit. | |
35 | ||
36 | =item B<-warnings> B<-nowarnings> | |
37 | ||
38 | Turn on/off printing of warnings. Repeating B<-warnings> increases the | |
39 | warning level, i.e. more warnings are printed. Currently increasing to | |
40 | level two causes flagging of unescaped "E<lt>,E<gt>" characters. | |
41 | ||
42 | =item I<file> | |
43 | ||
44 | The pathname of a POD file to syntax-check (defaults to standard input). | |
45 | ||
46 | =back | |
47 | ||
48 | =head1 DESCRIPTION | |
49 | ||
50 | B<podchecker> will read the given input files looking for POD | |
51 | syntax errors in the POD documentation and will print any errors | |
52 | it find to STDERR. At the end, it will print a status message | |
53 | indicating the number of errors found. | |
54 | ||
55 | Directories are ignored, an appropriate warning message is printed. | |
56 | ||
57 | B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> | |
58 | Please see L<Pod::Checker/podchecker()> for more details. | |
59 | ||
60 | =head1 RETURN VALUE | |
61 | ||
62 | B<podchecker> returns a 0 (zero) exit status if all specified | |
63 | POD files are ok. | |
64 | ||
65 | =head1 ERRORS | |
66 | ||
67 | B<podchecker> returns the exit status 1 if at least one of | |
68 | the given POD files has syntax errors. | |
69 | ||
70 | The status 2 indicates that at least one of the specified | |
71 | files does not contain I<any> POD commands. | |
72 | ||
73 | Status 1 overrides status 2. If you want unambigouus | |
74 | results, call B<podchecker> with one single argument only. | |
75 | ||
76 | =head1 SEE ALSO | |
77 | ||
78 | L<Pod::Parser> and L<Pod::Checker> | |
79 | ||
80 | =head1 AUTHORS | |
81 | ||
82 | Brad Appleton E<lt>bradapp@enteract.comE<gt>, | |
83 | Marek Rouchal E<lt>marek@saftsack.fs.uni-bayreuth.deE<gt> | |
84 | ||
85 | Based on code for B<Pod::Text::pod2text(1)> written by | |
86 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> | |
87 | ||
88 | =cut | |
89 | ||
90 | ||
91 | use Pod::Checker; | |
92 | use Pod::Usage; | |
93 | use Getopt::Long; | |
94 | ||
95 | ## Define options | |
96 | my %options; | |
97 | ||
98 | ## Parse options | |
99 | GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2); | |
100 | pod2usage(1) if ($options{help}); | |
101 | pod2usage(-verbose => 2) if ($options{man}); | |
102 | ||
103 | if($options{nowarnings}) { | |
104 | $options{warnings} = 0; | |
105 | } | |
106 | elsif(!defined $options{warnings}) { | |
107 | $options{warnings} = 1; # default is warnings on | |
108 | } | |
109 | ||
110 | ## Dont default to STDIN if connected to a terminal | |
111 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); | |
112 | ||
113 | ## Invoke podchecker() | |
114 | my $status = 0; | |
115 | @ARGV = qw(-) unless(@ARGV); | |
116 | for (@ARGV) { | |
117 | if($_ eq '-') { | |
118 | $_ = "<&STDIN"; | |
119 | } | |
120 | elsif(-d) { | |
121 | warn "podchecker: Warning: Ignoring directory '$_'\n"; | |
122 | next; | |
123 | } | |
124 | my $s = podchecker($_, undef, '-warnings' => $options{warnings}); | |
125 | if($s > 0) { | |
126 | # errors occurred | |
127 | $status = 1; | |
128 | } | |
129 | elsif($s < 0) { | |
130 | # no pod found | |
131 | $status = 2 unless($status); | |
132 | } | |
133 | } | |
134 | exit $status; | |
135 |