Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Also check pod and docs folders when trying to generate a name for a …
….pod file.
  • Loading branch information
oalders committed Mar 15, 2014
1 parent d7a6050 commit ff0074f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/MetaCPAN/Document/File.pm
Expand Up @@ -51,7 +51,7 @@ sub _build_abstract {
# an abstract and name based on filename
if( !$section && $self->path =~ /\.pod$/ ) {
$section = $self->path;
$section =~ s{^lib/}{};
$section =~ s{^(lib|pod|docs)/}{};
$section =~ s{\.pod$}{};
$section =~ s{/}{::}g;
}
Expand Down
42 changes: 41 additions & 1 deletion t/document/file.t
Expand Up @@ -115,7 +115,8 @@ END
is( $file->abstract,
'An object containing information about how to get access to teh Moby databases, resources, etc. from the mobycentral.config file'
);
is( $file->module->[0]
is(
$file->module->[0]
->hide_from_pause( ${ $file->content }, $file->name ),
0, 'indexed'
);
Expand Down Expand Up @@ -225,4 +226,43 @@ END
is( $file->description, 'hot stuff * Foo * Bar' );
}

{
my $content = <<'END';
package Foo::Bar::Baz;
=head1 DESCRIPTION
hot stuff
=over
=item *
Foo
=item *
Bar
=back
END

foreach my $folder ( 'pod', 'lib', 'docs' ) {
my $file = MetaCPAN::Document::File->new(
author => 'Foo',
content_cb => sub { \$content },
distribution => 'Foo',
name => 'Baz.pod',
path => $folder . '/Foo/Bar/Baz.pod',
release => 'release',
);
is( $file->documentation, 'Foo::Bar::Baz',
'Fakes a name when no name section exists in '
. $folder
. ' folder' );
is( $file->abstract, undef, 'abstract undef when NAME is missing' );
}
}

done_testing;

0 comments on commit ff0074f

Please sign in to comment.