summaryrefslogtreecommitdiff
path: root/ext/Pod-Html
diff options
context:
space:
mode:
authorJames E Keenan <jkeenan@cpan.org>2021-03-18 19:18:14 +0000
committerJames E Keenan <jkeenan@cpan.org>2021-08-23 01:47:47 +0000
commitb33902f54359a709bf04c14e2458c127cf8d9b90 (patch)
treeb6d537075f1fd08c34cce54420f580fb3f56881a /ext/Pod-Html
parent0e74e9b028173e63b960835f7ba58e379dd18e0e (diff)
downloadperl-b33902f54359a709bf04c14e2458c127cf8d9b90.tar.gz
Introduce $self->{Pages}
htmldir3.t: 3rd test unit is now expected to fail. So now the test file demonstrates that the unit fails whether it's placed before the second unit or after. Signed-off-by: James E Keenan <jkeenan@cpan.org>
Diffstat (limited to 'ext/Pod-Html')
-rw-r--r--ext/Pod-Html/lib/Pod/Html.pm24
-rw-r--r--ext/Pod-Html/t/htmldir3.t3
2 files changed, 16 insertions, 11 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm
index 87f2b1eff2..67084ce934 100644
--- a/ext/Pod-Html/lib/Pod/Html.pm
+++ b/ext/Pod-Html/lib/Pod/Html.pm
@@ -242,7 +242,7 @@ This program is distributed under the Artistic License.
my $Podroot;
-my %Pages = (); # associative array used to find the location
+#my %Pages = (); # associative array used to find the location
# of pages referenced by L<> links.
sub new {
@@ -265,7 +265,8 @@ sub pod2html {
# load or generate/cache %Pages
unless ($self->get_cache()) {
# generate %Pages
- %Pages = $self->generate_cache(\%Pages);
+ #%Pages = $self->generate_cache(\%Pages);
+ $self->generate_cache($self->{Pages});
}
my $input = $self->identify_input();
my $podtree = $self->parse_input_for_podtree($input);
@@ -282,7 +283,8 @@ sub pod2html {
$parser->htmlroot($self->{Htmlroot});
$parser->index($self->{Doindex});
$parser->output_string(\$self->{output}); # written to file later
- $parser->pages(\%Pages);
+ #$parser->pages(\%Pages);
+ $parser->pages($self->{Pages});
$parser->quiet($self->{Quiet});
$parser->verbose($self->{Verbose});
@@ -323,6 +325,7 @@ sub init_globals {
$self->{Header} = 0; # produce block header/footer
$self->{Title} = undef; # title to give the pod(s)
$self->{Saved_Cache_Key} = '';
+ $self->{Pages} = {};
return $self;
}
@@ -382,7 +385,8 @@ sub refine_globals {
}
sub generate_cache {
- my ($self, $Pagesref) = @_;
+ #my ($self, $Pagesref) = @_;
+ my $self = shift;
my $pwd = getcwd();
chdir($self->{Podroot}) ||
die "$0: error changing to directory $self->{Podroot}: $!\n";
@@ -399,7 +403,7 @@ sub generate_cache {
->recurse($self->{Recurse})->survey(@{$self->{Podpath}});
# remove Podroot and extension from each file
for my $k (keys %{$name2path}) {
- $Pages{$k} = _transform($self, $name2path->{$k});
+ $self->{Pages}{$k} = _transform($self, $name2path->{$k});
}
chdir($pwd) || die "$0: error changing to directory $pwd: $!\n";
@@ -411,19 +415,19 @@ sub generate_cache {
print $cache join(":", @{$self->{Podpath}}) . "\n$self->{Podroot}\n";
my $_updirs_only = ($self->{Podroot} =~ /\.\./) && !($self->{Podroot} =~ /[^\.\\\/]/);
- foreach my $key (keys %{$Pagesref}) {
+ foreach my $key (keys %{$self->{Pages}}) {
if($_updirs_only) {
my $_dirlevel = $self->{Podroot};
while($_dirlevel =~ /\.\./) {
$_dirlevel =~ s/\.\.//;
# Assume $Pagesref->{$key} has '/' separators (html dir separators).
- $Pagesref->{$key} =~ s/^[\w\s\-\.]+\///;
+ $self->{Pages}->{$key} =~ s/^[\w\s\-\.]+\///;
}
}
- print $cache "$key $Pagesref->{$key}\n";
+ print $cache "$key $self->{Pages}->{$key}\n";
}
close $cache or die "error closing $self->{Dircache}: $!";
- return %{$Pagesref};
+ #return %{$Pagesref};
}
sub _transform {
@@ -506,7 +510,7 @@ sub load_cache {
warn "loading directory cache\n" if $self->{Verbose};
while (<$cachefh>) {
/(.*?) (.*)$/;
- $Pages{$1} = $2;
+ $self->{Pages}->{$1} = $2;
}
close($cachefh);
diff --git a/ext/Pod-Html/t/htmldir3.t b/ext/Pod-Html/t/htmldir3.t
index 63490eede8..e02863b9eb 100644
--- a/ext/Pod-Html/t/htmldir3.t
+++ b/ext/Pod-Html/t/htmldir3.t
@@ -61,8 +61,9 @@ xconvert($args);
$args = {
podstub => "htmldir3",
- description => "test --htmldir and --htmlroot 3b",
+ description => "test --htmldir and --htmlroot 3b: as expected pod file not yet locatable either under podroot or in cache: GH 12271",
expect => $expect_raw,
+ expect_fail => 1,
p2h => {
podpath => catdir($relcwd, 't'),
podroot => catpath($v, '/', ''),