Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / bin / podchecker
CommitLineData
920dae64
AT
1#!/import/archperf/ws/devtools/4/amd64/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
13use strict;
14#use diagnostics;
15
16=head1 NAME
17
18podchecker - check the syntax of POD format documentation files
19
20=head1 SYNOPSIS
21
22B<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
30Print a brief help message and exit.
31
32=item B<-man>
33
34Print the manual page and exit.
35
36=item B<-warnings> B<-nowarnings>
37
38Turn on/off printing of warnings. Repeating B<-warnings> increases the
39warning level, i.e. more warnings are printed. Currently increasing to
40level two causes flagging of unescaped "E<lt>,E<gt>" characters.
41
42=item I<file>
43
44The pathname of a POD file to syntax-check (defaults to standard input).
45
46=back
47
48=head1 DESCRIPTION
49
50B<podchecker> will read the given input files looking for POD
51syntax errors in the POD documentation and will print any errors
52it find to STDERR. At the end, it will print a status message
53indicating the number of errors found.
54
55Directories are ignored, an appropriate warning message is printed.
56
57B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
58Please see L<Pod::Checker/podchecker()> for more details.
59
60=head1 RETURN VALUE
61
62B<podchecker> returns a 0 (zero) exit status if all specified
63POD files are ok.
64
65=head1 ERRORS
66
67B<podchecker> returns the exit status 1 if at least one of
68the given POD files has syntax errors.
69
70The status 2 indicates that at least one of the specified
71files does not contain I<any> POD commands.
72
73Status 1 overrides status 2. If you want unambigouus
74results, call B<podchecker> with one single argument only.
75
76=head1 SEE ALSO
77
78L<Pod::Parser> and L<Pod::Checker>
79
80=head1 AUTHORS
81
82Please report bugs using L<http://rt.cpan.org>.
83
84Brad Appleton E<lt>bradapp@enteract.comE<gt>,
85Marek Rouchal E<lt>marekr@cpan.orgE<gt>
86
87Based on code for B<Pod::Text::pod2text(1)> written by
88Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
89
90=cut
91
92
93use Pod::Checker;
94use Pod::Usage;
95use Getopt::Long;
96
97## Define options
98my %options;
99
100## Parse options
101GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2);
102pod2usage(1) if ($options{help});
103pod2usage(-verbose => 2) if ($options{man});
104
105if($options{nowarnings}) {
106 $options{warnings} = 0;
107}
108elsif(!defined $options{warnings}) {
109 $options{warnings} = 1; # default is warnings on
110}
111
112## Dont default to STDIN if connected to a terminal
113pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
114
115## Invoke podchecker()
116my $status = 0;
117@ARGV = qw(-) unless(@ARGV);
118for my $podfile (@ARGV) {
119 if($podfile eq '-') {
120 $podfile = "<&STDIN";
121 }
122 elsif(-d $podfile) {
123 warn "podchecker: Warning: Ignoring directory '$podfile'\n";
124 next;
125 }
126 my $errors =
127 podchecker($podfile, undef, '-warnings' => $options{warnings});
128 if($errors > 0) {
129 # errors occurred
130 $status = 1;
131 printf STDERR ("%s has %d pod syntax %s.\n",
132 $podfile, $errors,
133 ($errors == 1) ? "error" : "errors");
134 }
135 elsif($errors < 0) {
136 # no pod found
137 $status = 2 unless($status);
138 print STDERR "$podfile does not contain any pod commands.\n";
139 }
140 else {
141 print STDERR "$podfile pod syntax OK.\n";
142 }
143}
144exit $status;
145