Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix issue #476 #184

Closed
wants to merge 1 commit into from

4 participants

Michael Peters Olaf Alders Moritz Onken Randy Stauner
Michael Peters

If we don't have a NAME section in the POD and it's a .pod file
we can autogenerate a name based on the file path. So that
something like My/Project/Tutorial.pod becomes My::Project::Tutorial.
This fixes issue #476

Michael Peters mpeters If we don't have a NAME section in the POD and it's a .pod file
we can autogenerate a name based on the file path. So that
something like My/Project/Tutorial.pod becomes My::Project::Tutorial.
This fixes issue #476
fb1d2cd
Olaf Alders
Owner

Thanks very much for this! Based on the work you did yesterday, I'm thinking we may want to tweak this a bit to deal with modules which aren't in found in a lib folder. What do you think?

Michael Peters

It should work for anything that ends in .pod. It just strips off anything that has a lib/ prefix since that's pretty common. Are there other prefixes that should be considered too?

Moritz Onken
Owner

@mpeters I can think of pod/ docs/ etc.
maybe do
$section =~ s{^[a-z]+/}{}; ?

Olaf Alders
Owner

I think we just need to fix up this patch and apply it. For reference, the issue it fixes is in the metacpan-web issues: CPAN-API/metacpan-web#476

Randy Stauner
Owner

lib/ would be fine, pod/ and docs/ probably ok, too...
^[a-z]+/ is a bit liberal, but in this case it's probably sufficient.
If this is just for pod docs that don't have a NAME,
then if we strip off too much path i say let the author fix their doc.

This looks like a good start.

Leo Lapworth ranguard referenced this pull request in CPAN-API/metacpan-web
Closed

The HTML title for a .pod document displays "Search the CPAN" #476

Olaf Alders
Owner

Closing this via #303

Olaf Alders oalders closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2012
  1. Michael Peters

    If we don't have a NAME section in the POD and it's a .pod file

    mpeters authored
    we can autogenerate a name based on the file path. So that
    something like My/Project/Tutorial.pod becomes My::Project::Tutorial.
    This fixes issue #476
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/MetaCPAN/Document/File.pm
10 lib/MetaCPAN/Document/File.pm
View
@@ -369,6 +369,16 @@ sub _build_abstract {
my $text = ${ $self->content };
my ( $documentation, $abstract );
my $section = MetaCPAN::Util::extract_section( $text, 'NAME' );
+
+ # if it's a POD file without a name section, let's try to generate
+ # an abstract and name based on filename
+ if( !$section && $self->path =~ /\.pod$/ ) {
+ $section = $self->path;
+ $section =~ s{^lib/}{};
+ $section =~ s{\.pod$}{};
+ $section =~ s{/}{::}g;
+ }
+
return undef unless ($section);
$section =~ s/^=\w+.*$//mg;
$section =~ s/X<.*?>//mg;
Something went wrong with that request. Please try again.