[PATCH] _04m2 <DOC> perlfunc.pod (fwd)
[p5sagit/p5-mst-13.2.git] / pod / checkpods.PL
CommitLineData
f31caa63 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
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.
44a8e56a 15chdir dirname($0);
16$file = basename($0, '.PL');
774d564b 17$file .= '.com' if $^O eq 'VMS';
f31caa63 18
19open OUT,">$file" or die "Can't create $file: $!";
20
21print "Extracting $file (with variable substitutions)\n";
22
23# In this section, perl variables will be expanded during extraction.
24# You can use $Config{...} to use Configure variables.
25
26print OUT <<"!GROK!THIS!";
5f05dabc 27$Config{startperl}
28 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
29 if \$running_under_some_shell;
f31caa63 30!GROK!THIS!
31
32# In the following, perl variables are not expanded during extraction.
33
34print OUT <<'!NO!SUBS!';
35# From roderick@gate.netThu Sep 5 17:19:30 1996
36# Date: Thu, 05 Sep 1996 00:11:22 -0400
37# From: Roderick Schertler <roderick@gate.net>
38# To: perl5-porters@africa.nicoh.com
39# Subject: POD lines with only spaces
2862e1b7 40#
f31caa63 41# There are some places in the documentation where a POD directive is
42# ignored because the line before it contains whitespace (and so the
43# directive doesn't start a paragraph). This patch adds a way to check
44# for these to the pod Makefile (though it isn't made part of the build
45# process, which would be a good idea), and fixes those places where the
46# problem currently exists.
47#
48# Version 1.00 Original.
49# Version 1.01 Andy Dougherty <doughera@lafcol.lafayette.edu>
50# Trivial modifications to output format for easier auto-parsing
51# Broke it out as a separate function to avoid nasty
52# Make/Shell/Perl quoting problems, and also to make it easier
53# to grow. Someone will probably want to rewrite in terms of
54# some sort of Pod::Checker module. Or something. Consider this
55# a placeholder for the future.
2862e1b7 56# Version 1.02 Roderick Schertler <roderick@argon.org>
57# Check for pod directives following any kind of unempty line, not
58# just lines of whitespace.
59
60@directive = qw(head1 head2 item over back cut pod for begin end);
61@directive{@directive} = (1) x @directive;
62
63$exit = $last_unempty = 0;
f31caa63 64while (<>) {
2862e1b7 65 chomp;
66 if (/^=(\S+)/ && $directive{$1} && $last_unempty) {
67 printf "%s: line %5d, no blank line preceeding directive =%s\n",
f31caa63 68 $ARGV, $., $1;
69 $exit = 1;
70 }
2862e1b7 71 $last_unempty = ($_ ne '');
3e3baf6d 72 if (eof) {
73 close(ARGV);
2862e1b7 74 $last_unempty = 0;
3e3baf6d 75 }
f31caa63 76}
77exit $exit
78!NO!SUBS!
79
80close OUT or die "Can't close $file: $!";
81chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
82exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';