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