This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
optimize method name lookup
[perl5.git] / pod / podchecker.PL
1 #!/usr/local/bin/perl
2
3 use Config;
4 use 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
13 $file = basename($0);
14 $file =~ s/\.PL$//i;
15 $file .= '.com' if $^O eq 'VMS';
16
17 chdir("pod") or die "Can't chdir to pod: $!";
18 open OUT,">$file" or die "Can't create $file: $!";
19
20 print "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
25 print 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
33 print 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
46 use strict;
47 use diagnostics;
48
49 =head1 NAME
50
51 podchecker - check the syntax of POD format documentation files
52
53 =head1 SYNOPSIS
54
55 B<podchecker> [B<-help>] [B<-man>] [I<file>S< >...]
56
57 =head1 OPTIONS AND ARGUMENTS
58
59 =over 8
60
61 =item B<-help>
62
63 Print a brief help message and exit.
64
65 =item B<-man>
66
67 Print the manual page and exit.
68
69 =item I<file>
70
71 The pathname of a POD file to syntax-check (defaults to standard input).
72
73 =back
74
75 =head1 DESCRIPTION
76
77 B<podchecker> will read the given input files looking for POD
78 syntax errors in the POD documentation and will print any errors
79 it find to STDERR. At the end, it will print a status message
80 indicating the number of errors found.
81
82 B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker>
83 Please see L<Pod::Checker/podchecker()> for more details.
84
85 =head1 SEE ALSO
86
87 L<Pod::Parser> and L<Pod::Checker>
88
89 =head1 AUTHOR
90
91 Brad Appleton E<lt>bradapp@enteract.comE<gt>
92
93 Based on code for B<Pod::Text::pod2text(1)> written by
94 Tom Christiansen E<lt>tchrist@mox.perl.comE<gt>
95
96 =cut
97
98
99 use Pod::Checker;
100 use Pod::Usage;
101 use Getopt::Long;
102
103 ## Define options
104 my %options = (
105         "help"     => 0,
106         "man"      => 0,
107 );
108
109 ## Parse options
110 GetOptions(\%options, "help", "man")  ||  pod2usage(2);
111 pod2usage(1)  if ($options{help});
112 pod2usage(-verbose => 2)  if ($options{man});
113
114 ## Dont default to STDIN if connected to a terminal
115 pod2usage(2) if ((@ARGV == 0) && (-t STDIN));
116
117 ## Invoke podchecker()
118 if(@ARGV) {
119    for (@ARGV) { podchecker($_) };
120 } else {
121         podchecker("<&STDIN");
122 }
123
124 !NO!SUBS!
125
126 close OUT or die "Can't close $file: $!";
127 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
128 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';