Integrate with Sarathy.
[p5sagit/p5-mst-13.2.git] / pod / podchecker.PL
1 #!/usr/local/bin/perl
2
3 use Config;
4 use File::Basename qw(&basename &dirname);
5 use Cwd;
6
7 # List explicitly here the variables you want Configure to
8 # generate.  Metaconfig only looks for shell variables, so you
9 # have to mention them as if they were shell variables, not
10 # %Config entries.  Thus you write
11 #  $startperl
12 # to ensure Configure will look for $Config{startperl}.
13
14 # This forces PL files to create target in same directory as PL file.
15 # This is so that make depend always knows where to find PL derivatives.
16 $origdir = cwd;
17 chdir(dirname($0));
18 ($file = basename($0)) =~ s/\.PL$//;
19 $file =~ s/\.pl$//
20         if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos');  # "case-forgiving"
21
22 open OUT,">$file" or die "Can't create $file: $!";
23
24 print "Extracting $file (with variable substitutions)\n";
25
26 # In this section, perl variables will be expanded during extraction.
27 # You can use $Config{...} to use Configure variables.
28
29 print OUT <<"!GROK!THIS!";
30 $Config{'startperl'}
31     eval 'exec perl -S \$0 "\$@"'
32         if 0;
33 !GROK!THIS!
34
35 # In the following, perl variables are not expanded during extraction.
36
37 print OUT <<'!NO!SUBS!';
38 #############################################################################
39 # podchecker -- command to invoke the podchecker function in Pod::Checker
40 #
41 # Copyright (c) 1998-1999 by Bradford Appleton. All rights reserved.
42 # This file is part of "PodParser". PodParser is free software;
43 # you can redistribute it and/or modify it under the same terms
44 # as Perl itself.
45 #############################################################################
46
47 use strict;
48 use diagnostics;
49
50 =head1 NAME
51
52 podchecker - check the syntax of POD format documentation files
53
54 =head1 SYNOPSIS
55
56 B<podchecker> [B<-help>] [B<-man>] [I<file>S< >...]
57
58 =head1 OPTIONS AND ARGUMENTS
59
60 =over 8
61
62 =item B<-help>
63
64 Print a brief help message and exit.
65
66 =item B<-man>
67
68 Print the manual page and exit.
69
70 =item I<file>
71
72 The pathname of a POD file to syntax-check (defaults to standard input).
73
74 =back
75
76 =head1 DESCRIPTION
77
78 B<podchecker> will read the given input files looking for POD
79 syntax errors in the POD documentation and will print any errors
80 it find to STDERR. At the end, it will print a status message
81 indicating the number of errors found.
82
83 B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
84 Please see L<Pod::Checker/podchecker()> for more details.
85
86 =head1 SEE ALSO
87
88 L<Pod::Parser> and L<Pod::Checker>
89
90 =head1 AUTHOR
91
92 Brad Appleton E<lt>bradapp@enteract.comE<gt>
93
94 Based on code for B<Pod::Text::pod2text(1)> written by
95 Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
96
97 =cut
98
99
100 use Pod::Checker;
101 use Pod::Usage;
102 use Getopt::Long;
103
104 ## Define options
105 my %options = (
106         "help"     => 0,
107         "man"      => 0,
108 );
109
110 ## Parse options
111 GetOptions(\%options, "help", "man")  ||  pod2usage(2);
112 pod2usage(1)  if ($options{help});
113 pod2usage(-verbose => 2)  if ($options{man});
114
115 ## Dont default to STDIN if connected to a terminal
116 pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
117
118 ## Invoke podchecker()
119 if(@ARGV) {
120    for (@ARGV) { podchecker($_) };
121 } else {
122         podchecker("<&STDIN");
123 }
124
125 !NO!SUBS!
126
127 close OUT or die "Can't close $file: $!";
128 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
129 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
130 chdir $origdir;