Commit | Line | Data |
360aca43 |
1 | #!/usr/local/bin/perl |
2 | |
3 | use Config; |
4 | use File::Basename qw(&basename &dirname); |
933fea7f |
5 | use Cwd; |
360aca43 |
6 | |
7 | # List explicitly here the variables you want Configure to |
8 | # generate. Metaconfig only looks for shell variables, so you |
9 | # have to mention them as if they were shell variables, not |
10 | # %Config entries. Thus you write |
11 | # $startperl |
12 | # to ensure Configure will look for $Config{startperl}. |
13 | |
3b5ca523 |
14 | # This forces PL files to create target in same directory as PL file. |
15 | # This is so that make depend always knows where to find PL derivatives. |
933fea7f |
16 | $origdir = cwd; |
3b5ca523 |
17 | chdir(dirname($0)); |
18 | ($file = basename($0)) =~ s/\.PL$//; |
19 | $file =~ s/\.pl$// |
933fea7f |
20 | if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" |
b4bc034f |
21 | $file .= '.com' if $^O eq 'VMS'; |
360aca43 |
22 | |
23 | open OUT,">$file" or die "Can't create $file: $!"; |
24 | |
25 | print "Extracting $file (with variable substitutions)\n"; |
26 | |
27 | # In this section, perl variables will be expanded during extraction. |
28 | # You can use $Config{...} to use Configure variables. |
29 | |
30 | print OUT <<"!GROK!THIS!"; |
31 | $Config{'startperl'} |
32 | eval 'exec perl -S \$0 "\$@"' |
33 | if 0; |
34 | !GROK!THIS! |
35 | |
36 | # In the following, perl variables are not expanded during extraction. |
37 | |
38 | print OUT <<'!NO!SUBS!'; |
39 | ############################################################################# |
40 | # podchecker -- command to invoke the podchecker function in Pod::Checker |
41 | # |
27f805f4 |
42 | # Copyright (c) 1998-1999 by Bradford Appleton. All rights reserved. |
360aca43 |
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 | |
48 | use strict; |
e3237417 |
49 | #use diagnostics; |
360aca43 |
50 | |
51 | =head1 NAME |
52 | |
53 | podchecker - check the syntax of POD format documentation files |
54 | |
55 | =head1 SYNOPSIS |
56 | |
e3237417 |
57 | B<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] |
360aca43 |
58 | |
59 | =head1 OPTIONS AND ARGUMENTS |
60 | |
61 | =over 8 |
62 | |
63 | =item B<-help> |
64 | |
65 | Print a brief help message and exit. |
66 | |
67 | =item B<-man> |
68 | |
69 | Print the manual page and exit. |
70 | |
e3237417 |
71 | =item B<-warnings> B<-nowarnings> |
72 | |
73 | Turn on/off printing of warnings. |
74 | |
360aca43 |
75 | =item I<file> |
76 | |
77 | The pathname of a POD file to syntax-check (defaults to standard input). |
78 | |
79 | =back |
80 | |
81 | =head1 DESCRIPTION |
82 | |
83 | B<podchecker> will read the given input files looking for POD |
84 | syntax errors in the POD documentation and will print any errors |
85 | it find to STDERR. At the end, it will print a status message |
86 | indicating the number of errors found. |
87 | |
88 | B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> |
89 | Please see L<Pod::Checker/podchecker()> for more details. |
90 | |
e3237417 |
91 | =head1 RETURN VALUE |
92 | |
93 | B<podchecker> returns a 0 (zero) exit status if all specified |
94 | POD files are ok. |
95 | |
96 | =head1 ERRORS |
97 | |
98 | B<podchecker> returns the exit status 1 if at least one of |
99 | the given POD files has syntax errors. |
100 | |
101 | The status 2 indicates that at least one of the specified |
102 | files does not contain I<any> POD commands. |
103 | |
104 | Status 1 overrides status 2. If you want unambigouus |
105 | results, call B<podchecker> with one single argument only. |
106 | |
360aca43 |
107 | =head1 SEE ALSO |
108 | |
109 | L<Pod::Parser> and L<Pod::Checker> |
110 | |
e3237417 |
111 | =head1 AUTHORS |
360aca43 |
112 | |
e3237417 |
113 | Brad Appleton E<lt>bradapp@enteract.comE<gt>, |
114 | Marek Rouchal E<lt>marek@saftsack.fs.uni-bayreuth.deE<gt> |
360aca43 |
115 | |
116 | Based on code for B<Pod::Text::pod2text(1)> written by |
117 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> |
118 | |
119 | =cut |
120 | |
121 | |
122 | use Pod::Checker; |
123 | use Pod::Usage; |
124 | use Getopt::Long; |
125 | |
126 | ## Define options |
127 | my %options = ( |
128 | "help" => 0, |
129 | "man" => 0, |
e3237417 |
130 | "warnings" => 1, |
360aca43 |
131 | ); |
132 | |
133 | ## Parse options |
e3237417 |
134 | GetOptions(\%options, "help", "man", "warnings!") || pod2usage(2); |
360aca43 |
135 | pod2usage(1) if ($options{help}); |
136 | pod2usage(-verbose => 2) if ($options{man}); |
137 | |
138 | ## Dont default to STDIN if connected to a terminal |
139 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); |
140 | |
141 | ## Invoke podchecker() |
e3237417 |
142 | my $status = 0; |
143 | @ARGV = ("<&STDIN") unless(@ARGV); |
144 | for (@ARGV) { |
145 | my $s = podchecker($_, undef, '-warnings' => $options{warnings}); |
146 | if($s > 0) { |
147 | # errors occurred |
148 | $status = 1; |
149 | } |
150 | elsif($s < 0) { |
151 | # no pod found |
152 | $status = 2 unless($status); |
153 | } |
360aca43 |
154 | } |
e3237417 |
155 | exit $status; |
360aca43 |
156 | |
157 | !NO!SUBS! |
158 | |
159 | close OUT or die "Can't close $file: $!"; |
160 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
161 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |
933fea7f |
162 | chdir $origdir; |