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