From: Gurusamy Sarathy Date: Sun, 5 Mar 2000 09:20:12 +0000 (+0000) Subject: undo change#5506; add patch to make blank line warnings optional X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a5317591e1223e953379e948a9268bbad4eaa55f;p=p5sagit%2Fp5-mst-13.2.git undo change#5506; add patch to make blank line warnings optional (from Brad Appleton) p4raw-link: @5506 on //depot/perl: eaf840779373130f95f7bd459b3864c78c698e28 p4raw-id: //depot/perl@5541 --- diff --git a/lib/Pod/Checker.pm b/lib/Pod/Checker.pm index 6611a05..0fd36a9 100644 --- a/lib/Pod/Checker.pm +++ b/lib/Pod/Checker.pm @@ -471,7 +471,7 @@ sub podchecker( $ ; $ % ) { ## Now create a pod checker my $checker = new Pod::Checker(%options); - $checker->parseopts(-process_cut_cmd => 1); + $checker->parseopts(-process_cut_cmd => 1, -warnings => 1); ## Now check the pod document for errors $checker->parse_from_file($infile, $outfile); diff --git a/lib/Pod/Parser.pm b/lib/Pod/Parser.pm index 1bd440b..9ad5d16 100644 --- a/lib/Pod/Parser.pm +++ b/lib/Pod/Parser.pm @@ -172,7 +172,7 @@ paragraph, or some other input paragraph. Normally (by default) B handles the C<=cut> POD directive by itself and does not pass it on to the caller for processing. Setting -this option to non-empty, non-zero value will cause B to +this option to a non-empty, non-zero value will cause B to pass the C<=cut> directive to the caller just like any other POD command (and hence it may be processed by the B method). @@ -181,6 +181,15 @@ B will still interpret the C<=cut> directive to mean that to capture the actual C<=cut> paragraph itself for whatever purpose it desires. +=item B<-warnings> (default: unset) + +Normally (by default) B recognizes a bare minimum of +pod syntax errors and warnings and issues diagnostic messages +for errors, but not for warnings. (Use B to do more +thorough checking of POD syntax.) Setting this option to a non-empty, +non-zero value will cause B to issue diagnostics for +the few warnings it recognizes as well as the errors. + =back Please see L<"parseopts()"> for a complete description of the interface @@ -838,7 +847,7 @@ sub parse_text { ($rdelim = $ldelim) =~ tr//; $rdelim =~ s/^(\S+)(\s*)$/$2$1/; pop @seq_stack; - my $errmsg = "*** WARNING: unterminated ${cmd}${ldelim}...${rdelim}". + my $errmsg = "*** ERROR: unterminated ${cmd}${ldelim}...${rdelim}". " at line $line in file $file\n"; (ref $errorsub) and &{$errorsub}($errmsg) or (defined $errorsub) and $self->$errorsub($errmsg) @@ -1027,6 +1036,8 @@ sub parse_from_filehandle { my %opts = (ref $_[0] eq 'HASH') ? %{ shift() } : (); my ($in_fh, $out_fh) = @_; $in_fh = \*STDIN unless ($in_fh); + local *myData = $self; ## alias to avoid deref-ing overhead + local *myOpts = ($myData{_PARSEOPTS} ||= {}); ## get parse-options local $_; ## Put this stream at the top of the stack and do beginning-of-input @@ -1061,20 +1072,20 @@ sub parse_from_filehandle { ## See if this line is blank and ends the current paragraph. ## If it isnt, then keep iterating until it is. - next unless (($textline =~ /^(\s*)$/) && (length $paragraph)); + next unless (($textline =~ /^([^\S\r\n]*)[\r\n]*$/) + && (length $paragraph)); ## Issue a warning about any non-empty blank lines -# XXX avoid warning until Brad has a chance to make this optional --GSAR -# if (length($1) > 1 and ! $self->{_CUTTING}) { -# my $errorsub = $self->errorsub(); -# my $file = $self->input_file(); -# $file = VMS::Filespec::unixify($file) if $^O eq 'VMS'; -# my $errmsg = "*** WARNING: line containing nothing but whitespace". -# " in paragraph at line $nlines in file $file\n"; -# (ref $errorsub) and &{$errorsub}($errmsg) -# or (defined $errorsub) and $self->$errorsub($errmsg) -# or warn($errmsg); -# } + if (length($1) > 1 and $myOpts{'-warnings'} and ! $myData{_CUTTING}) { + my $errorsub = $self->errorsub(); + my $file = $self->input_file(); + $file = VMS::Filespec::unixify($file) if $^O eq 'VMS'; + my $errmsg = "*** WARNING: line containing nothing but whitespace". + " in paragraph at line $nlines in file $file\n"; + (ref $errorsub) and &{$errorsub}($errmsg) + or (defined $errorsub) and $self->$errorsub($errmsg) + or warn($errmsg); + } ## Now process the paragraph parse_paragraph($self, $paragraph, ($nlines - $plines) + 1); @@ -1295,7 +1306,7 @@ key/value pairs and the specified parse-option names are set to the given values. Any unspecified parse-options are unaffected. ## Set them back to the default - $parser->parseopts(-process_cut_cmd => 0); + $parser->parseopts(-warnings => 0); When passed a single hash-ref, B uses that hash to completely reset the existing parse-options, all previous parse-option values @@ -1304,7 +1315,7 @@ are lost. ## Reset all options to default $parser->parseopts( { } ); -See L<"PARSING OPTIONS"> for more for the name and meaning of each +See L<"PARSING OPTIONS"> for more information on the name and meaning of each parse-option currently recognized. =cut diff --git a/t/pod/poderrs.xr b/t/pod/poderrs.xr index 17baee9..b8e5e86 100644 --- a/t/pod/poderrs.xr +++ b/t/pod/poderrs.xr @@ -3,9 +3,10 @@ *** ERROR: Unknown interior-sequence 'A' at line 30 in file pod/poderrs.t *** ERROR: Unknown interior-sequence 'Y' at line 31 in file pod/poderrs.t *** ERROR: Unknown interior-sequence 'V' at line 31 in file pod/poderrs.t -*** WARNING: unterminated B<...> at line 35 in file pod/poderrs.t -*** WARNING: unterminated I<...> at line 34 in file pod/poderrs.t -*** WARNING: unterminated C<...> at line 37 in file pod/poderrs.t +*** ERROR: unterminated B<...> at line 35 in file pod/poderrs.t +*** ERROR: unterminated I<...> at line 34 in file pod/poderrs.t +*** ERROR: unterminated C<...> at line 37 in file pod/poderrs.t +*** WARNING: line containing nothing but whitespace in paragraph at line 45 in file pod/poderrs.t *** ERROR: =item without previous =over at line 52 in file pod/poderrs.t *** ERROR: =back without previous =over at line 56 in file pod/poderrs.t *** ERROR: =over on line 60 without closing =back (at head2) at line 64 in file pod/poderrs.t @@ -29,4 +30,4 @@ *** ERROR: unresolved internal link 'abc def' at line 96 in file pod/poderrs.t *** ERROR: unresolved internal link 'passwd(5)' at line 103 in file pod/poderrs.t *** WARNING: multiple occurence of link target 'oops' at line - in file pod/poderrs.t -pod/poderrs.t has 22 pod syntax errors. +pod/poderrs.t has 25 pod syntax errors.