This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
25d1f18fb6a85d01225ab4f577d4679406b231a6
[perl5.git] / pod / checkpods.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 # 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.
15 chdir(dirname($0));
16 ($file = basename($0)) =~ s/\.PL$//;
17 $file =~ s/\.pl$//
18         if ($Config{'osname'} eq 'VMS' or
19             $Config{'osname'} eq 'OS2');  # "case-forgiving"
20
21 open OUT,">$file" or die "Can't create $file: $!";
22
23 print "Extracting $file (with variable substitutions)\n";
24
25 # In this section, perl variables will be expanded during extraction.
26 # You can use $Config{...} to use Configure variables.
27
28 print OUT <<"!GROK!THIS!";
29 $Config{'startperl'}
30     eval 'exec perl -S \$0 "\$@"'
31         if 0;
32 !GROK!THIS!
33
34 # In the following, perl variables are not expanded during extraction.
35
36 print OUT <<'!NO!SUBS!';
37 # From roderick@gate.netThu Sep  5 17:19:30 1996
38 # Date: Thu, 05 Sep 1996 00:11:22 -0400
39 # From: Roderick Schertler <roderick@gate.net>
40 # To: perl5-porters@africa.nicoh.com
41 # Subject: POD lines with only spaces
42
43 # There are some places in the documentation where a POD directive is
44 # ignored because the line before it contains whitespace (and so the
45 # directive doesn't start a paragraph).  This patch adds a way to check
46 # for these to the pod Makefile (though it isn't made part of the build
47 # process, which would be a good idea), and fixes those places where the
48 # problem currently exists.
49 #
50 #  Version 1.00  Original.
51 #  Version 1.01  Andy Dougherty <doughera@lafcol.lafayette.edu>
52 #    Trivial modifications to output format for easier auto-parsing
53 #    Broke it out as a separate function to avoid nasty
54 #       Make/Shell/Perl quoting problems, and also to make it easier
55 #       to grow.  Someone will probably want to rewrite in terms of
56 #       some sort of Pod::Checker module.  Or something.  Consider this
57 #       a placeholder for the future.
58 $exit = $last_blank = 0;
59 while (<>) {
60     chop;
61     if (/^(=\S+)/ && $last_blank) {
62         printf "%s: line %5d, Non-empty line preceeding directive %s\n",
63                 $ARGV, $., $1;
64         $exit = 1;
65     }
66     $last_blank = /^\s+$/;
67     close(ARGV) if eof;
68 }
69 exit $exit
70 !NO!SUBS!
71
72 close OUT or die "Can't close $file: $!";
73 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
74 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';