Skip to content

Commit

Permalink
Reword pod2html crossref err msgs; show only if $verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
marcgreen committed Feb 18, 2012
1 parent f5d8a3f commit a83bce1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
25 changes: 16 additions & 9 deletions ext/Pod-Html/lib/Pod/Html.pm
Expand Up @@ -701,22 +701,29 @@ sub resolve_pod_page_link {
push @matches, $modname if $modname =~ /::\Q$to\E\z/;
}

# make it look like a path instead of a namespace
my $modloc = File::Spec->catfile(split(/::/, $to));

if ($#matches == -1) {
warn "Cannot find \"$to\" in podpath: " .
"cannot find suitable replacement path, cannot resolve link\n"
unless $self->quiet;
warn "Cannot find file \"$modloc.*\" directly under podpath, " .
"cannot find suitable replacement: link remains unresolved.\n"
if $self->verbose;
return '';
} elsif ($#matches == 0) {
warn "Cannot find \"$to\" in podpath: " .
"using $matches[0] as replacement path to $to\n"
unless $self->quiet;
$path = $self->pages->{$matches[0]};
my $matchloc = File::Spec->catfile(split(/::/, $path));
warn "Cannot find file \"$modloc.*\" directly under podpath, but ".
"I did find \"$matchloc.*\", so I'll assume that is what you ".
"meant to link to.\n"
if $self->verbose;
} else {
warn "Cannot find \"$to\" in podpath: " .
"more than one possible replacement path to $to, " .
"using $matches[-1]\n" unless $self->quiet;
# Use [-1] so newer (higher numbered) perl PODs are used
# XXX currently, @matches isn't sorted so this is not true
$path = $self->pages->{$matches[-1]};
my $matchloc = File::Spec->catfile(split(/::/, $path));
warn "Cannot find file \"$modloc.*\" directly under podpath, but ".
"I did find \"$matchloc.*\" (among others), so I'll use that " .
"to resolve the link.\n" if $self->verbose;
}
} else {
$path = $self->pages->{$to};
Expand Down
6 changes: 4 additions & 2 deletions ext/Pod-Html/t/feature2.t
Expand Up @@ -26,8 +26,10 @@ convert_n_test("feature2", "misc pod-html features 2",

like($warn,
qr(
\Acaching\ directories\ for\ later\ use\n
Converting\ input\ file\ \S+[/\\\]]feature2\.pod\n\z
\Acaching\ directories\ for\ later\ use\n
Converting\ input\ file\ \S+[/\\\]]feature2\.pod\n
Cannot\ find\ file\ "crossref\.\*"\ directly\ under\ podpath,\ cannot\ find
\ suitable\ replacement:\ link\ remains\ unresolved\.\n\z
)x,
"misc pod-html --verbose warnings");

Expand Down

0 comments on commit a83bce1

Please sign in to comment.