--- /usr/lib/perl5/5.8.8/Pod/Checker.pm 2007-11-08 06:59:35.000000000 -0500 +++ Checker.pm 2008-05-02 08:32:47.000000000 -0400 @@ -46,8 +46,13 @@ Turn warnings on/off. I is usually 1 for on, but higher values trigger additional warnings. See L<"Warnings">. +=item B<-want_nonPODs> =E 1 + +Will trigger check for Pod command not preceded by blank. Ignores, however, +when this happens in a C<=for comment> block. + =back =head1 DESCRIPTION @@ -534,9 +539,9 @@ following options are recognized: C<-warnings =E num> Print warnings if C is true. The higher the value of C, -the more warnings are printed. Currently there are only levels 1 and 2. +the more warnings are printed. Currently there are levels 1, 2 and 3. C<-quiet =E num> If C is true, do not print any errors/warnings. This is useful when Pod::Checker is used to munge POD code into plain text from within @@ -571,9 +576,20 @@ $self->{_index} = []; # text in X<> # print warnings? $self->{-warnings} = 1 unless(defined $self->{-warnings}); $self->{_current_head1} = ''; # the current =head1 block - $self->parseopts(-process_cut_cmd => 1, -warnings => $self->{-warnings}); + $self->{-want_nonPODs} = 0 unless(defined $self->{-want_nonPODs}); + # Following provides alternative to explicitly stating + # "-want_nonPODs => 1" in calling script. + $self->{-want_nonPODs} = 1 if $self->{-warnings}>2; + $self->parseopts( + -process_cut_cmd => 1, + -warnings => $self->{-warnings}, + -want_nonPODs => $self->{-want_nonPODs}, + ); + + # To hold state: Did we have Pod, (not =cut) before =cut? + $self->{_any_Pod_substance} = 0; } ################################## @@ -741,8 +757,34 @@ } ## overrides for Pod::Parser +sub preprocess_paragraph { + my ($self, $text, $line_num) = @_; + #if ($text =~ /\A=for comment\z/) { + if ($text =~ /^=for comment/) { + #warn "Ignoring comment : $text\n"; + return $text; + } + else { + while ($text =~ /[\r\n](={1,2}\S+)/g) { + my $errorsub = $self->errorsub(); + my $file = $self->input_file(); + my $errmsg = "Need a Blank Line before $1"; + #" Block begins at line $line_num\n"; + $self->poderror( + { + -line => $line_num,-file => $file, + -severity => 'WARNING', + -msg => $errmsg, + } + ); + } + } + #warn "Processing $text"; + return $text; +} + sub end_pod { ## Do some final checks and ## print the number of errors found my $self = shift; @@ -799,8 +841,18 @@ } # no POD found here $self->num_errors(-1) if($self->{_commands} == 0); + # set warning here if only have =cut (one or more) + if (($self->num_errors() == 0) && (! $self->{_any_Pod_substance})) { + $self->poderror( + { + -line => 'EOF', -file => $infile, + -severity => 'WARNING', + -msg => "File with only =cut(s) will produce no Pod!!", + } + ); + } } # check a POD command directive sub command { @@ -820,9 +872,13 @@ # $self->poderror({ -line => $line, -file => $file, # -severity => 'WARNING', # -msg => "file does not start with =head" }); #} - + # To know whether something valid precedes =cut. Note: this ignores + # the fact the the command here might subsequently error out. + if ($cmd ne 'cut') { + $self->{_any_Pod_substance} = 1; + } # check syntax of particular command if($cmd eq 'over') { # check for argument $arg = $self->interpolate_and_check($paragraph, $line,$file);