Commit | Line | Data |
---|---|---|
360aca43 GS |
1 | #!/usr/local/bin/perl |
2 | ||
3 | use Config; | |
4 | use File::Basename qw(&basename &dirname); | |
933fea7f | 5 | use Cwd; |
360aca43 GS |
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 GS |
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 GS |
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 GS |
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 | # | |
92e3d63a | 42 | # Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. |
360aca43 GS |
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 GS |
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 GS |
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 GS |
71 | =item B<-warnings> B<-nowarnings> |
72 | ||
92e3d63a JH |
73 | Turn on/off printing of warnings. Repeating B<-warnings> increases the |
74 | warning level, i.e. more warnings are printed. Currently increasing to | |
75 | level two causes flagging of unescaped "E<lt>,E<gt>" characters. | |
e3237417 | 76 | |
360aca43 GS |
77 | =item I<file> |
78 | ||
79 | The pathname of a POD file to syntax-check (defaults to standard input). | |
80 | ||
81 | =back | |
82 | ||
83 | =head1 DESCRIPTION | |
84 | ||
85 | B<podchecker> will read the given input files looking for POD | |
86 | syntax errors in the POD documentation and will print any errors | |
87 | it find to STDERR. At the end, it will print a status message | |
88 | indicating the number of errors found. | |
89 | ||
92e3d63a JH |
90 | Directories are ignored, an appropriate warning message is printed. |
91 | ||
360aca43 GS |
92 | B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> |
93 | Please see L<Pod::Checker/podchecker()> for more details. | |
94 | ||
e3237417 GS |
95 | =head1 RETURN VALUE |
96 | ||
97 | B<podchecker> returns a 0 (zero) exit status if all specified | |
98 | POD files are ok. | |
99 | ||
100 | =head1 ERRORS | |
101 | ||
102 | B<podchecker> returns the exit status 1 if at least one of | |
103 | the given POD files has syntax errors. | |
104 | ||
105 | The status 2 indicates that at least one of the specified | |
106 | files does not contain I<any> POD commands. | |
107 | ||
108 | Status 1 overrides status 2. If you want unambigouus | |
109 | results, call B<podchecker> with one single argument only. | |
110 | ||
360aca43 GS |
111 | =head1 SEE ALSO |
112 | ||
113 | L<Pod::Parser> and L<Pod::Checker> | |
114 | ||
e3237417 | 115 | =head1 AUTHORS |
360aca43 | 116 | |
e3237417 GS |
117 | Brad Appleton E<lt>bradapp@enteract.comE<gt>, |
118 | Marek Rouchal E<lt>marek@saftsack.fs.uni-bayreuth.deE<gt> | |
360aca43 GS |
119 | |
120 | Based on code for B<Pod::Text::pod2text(1)> written by | |
121 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> | |
122 | ||
123 | =cut | |
124 | ||
125 | ||
126 | use Pod::Checker; | |
127 | use Pod::Usage; | |
128 | use Getopt::Long; | |
129 | ||
130 | ## Define options | |
92e3d63a | 131 | my %options; |
360aca43 GS |
132 | |
133 | ## Parse options | |
92e3d63a | 134 | GetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2); |
360aca43 GS |
135 | pod2usage(1) if ($options{help}); |
136 | pod2usage(-verbose => 2) if ($options{man}); | |
137 | ||
92e3d63a JH |
138 | if($options{nowarnings}) { |
139 | $options{warnings} = 0; | |
140 | } | |
141 | elsif(!defined $options{warnings}) { | |
142 | $options{warnings} = 1; # default is warnings on | |
143 | } | |
144 | ||
360aca43 GS |
145 | ## Dont default to STDIN if connected to a terminal |
146 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); | |
147 | ||
148 | ## Invoke podchecker() | |
e3237417 | 149 | my $status = 0; |
92e3d63a | 150 | @ARGV = qw(-) unless(@ARGV); |
e3237417 | 151 | for (@ARGV) { |
92e3d63a JH |
152 | if($_ eq '-') { |
153 | $_ = "<&STDIN"; | |
154 | } | |
155 | elsif(-d) { | |
156 | warn "podchecker: Warning: Ignoring directory '$_'\n"; | |
157 | next; | |
158 | } | |
e3237417 GS |
159 | my $s = podchecker($_, undef, '-warnings' => $options{warnings}); |
160 | if($s > 0) { | |
161 | # errors occurred | |
162 | $status = 1; | |
163 | } | |
164 | elsif($s < 0) { | |
165 | # no pod found | |
166 | $status = 2 unless($status); | |
167 | } | |
360aca43 | 168 | } |
e3237417 | 169 | exit $status; |
360aca43 GS |
170 | |
171 | !NO!SUBS! | |
172 | ||
173 | close OUT or die "Can't close $file: $!"; | |
174 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; | |
175 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; | |
933fea7f | 176 | chdir $origdir; |