On Fri Apr 17 13:29:57 2009, cotto wrote:
> On Fri Apr 17 13:24:13 2009, julianalbo wrote:
> > > I propose rejecting this ticket as unnecessary. The code may not be
> > > optimal, but it works fine and isn't even particularly hacky or
broken.
> >
> > +1
> >
> >
>
> rejected!
In the course of working on RT 43683, I came across the inline comment
which was the pretext for creating this ticket in the first place. It
was not removed when the ticket was rejected. And since I was doing
some refactoring for the other ticket, I decided to deal with the issue
in this ticket.
Please see patch attached. I'll apply it after this month's release
unless someone objects.
Index: lib/Parrot/Docs/File.pm
===================================================================
--- lib/Parrot/Docs/File.pm (revision 38663)
+++ lib/Parrot/Docs/File.pm (working copy)
@@ -380,45 +380,20 @@
return '' unless $self->contains_pod;
my @lines = $self->read;
+ my $firstline = shift @lines;
+ return $self->title unless $firstline =~ /^=head1\s+ABSTRACT/;
- while (@lines) {
- my $line = shift @lines;
-
- if ( $line =~ /^=head1\s+ABSTRACT/o ) {
- while (@lines) {
- $line = shift @lines;
-
- last if $line =~ /\S/o;
- }
-
- my @abstract_text = $line;
-
- while (@lines) {
- $line = shift @lines;
-
- last if $line !~ /\S/o;
-
- push @abstract_text, $line;
- }
-
- my $desc = join ' ', @abstract_text;
-
- # Joining lines may have created a bit of extra whitespace.
- $desc =~ s/\s+/ /osg;
- $desc =~ s/^\s+//os;
- $desc =~ s/\s+$//os;
-
- # Remove any POD.
- $desc =~ s/[CFL]<([^>]+)>/$1/osg;
-
- return $desc;
- }
- }
-
- # RT#43687 - The abstract section above was added later. The two searches
- # could be combined.
-
- return $self->title;
+ my $all_text = join "\n" => @lines;
+ $all_text =~ s/^\s+//;
+ my @paragraphs = split /\n{2,}/, $all_text;
+ my $desc;
+ # For a short description, we take only the first paragraph of any
+ # ABSTRACT.
+ ($desc = $paragraphs[0]) =~ s/\n/ /g;
+ $desc =~ s/\s+/ /sg;
+ # We eliminate certain POD formatting characters.
+ $desc =~ s/[CFL]<([^>]+)>/$1/sg;
+ return $desc;
}
=back