summaryrefslogtreecommitdiff
path: root/t/data
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2021-09-08 15:22:02 -0700
committerRuss Allbery <rra@cpan.org>2021-09-08 15:22:02 -0700
commit6fa88289dae41e3e5f4514f58febafa680ffd48f (patch)
tree47026583e3541549f3fee088d9e1fa59fa97e791 /t/data
parente1ed1d4f0d86da79a4219508646be3e6b4879f4b (diff)
Add support for regenerating POD output
The spin test suite now contains POD output from App::DocKnot. Add regeneration of that data to t/data/regenerate-data.
Diffstat (limited to 't/data')
-rwxr-xr-xt/data/regenerate-data59
1 files changed, 59 insertions, 0 deletions
diff --git a/t/data/regenerate-data b/t/data/regenerate-data
index 9ef8f62..dc9fbb3 100755
--- a/t/data/regenerate-data
+++ b/t/data/regenerate-data
@@ -19,6 +19,8 @@ use lib 'blib/lib';
use App::DocKnot;
use App::DocKnot::Generate;
+use App::DocKnot::Spin;
+use Pod::Thread;
# For each subdirectory of t/data/generate, regenerate each file in the output
# subdirectory using the metadata subdirectory and the template matching the
@@ -45,3 +47,60 @@ for my $package (@packages) {
}
closedir($outputdir);
}
+
+# The test of spinning a tree of files uses a reference to App::DocKnot's own
+# POD documentation. Regenerate the expected output in case the POD has
+# changed.
+my $source = File::Spec->catdir('lib', 'App', 'DocKnot.pm');
+my $podthread = Pod::Thread->new(navbar => 1);
+my $spin = App::DocKnot::Spin->new();
+my $thread;
+$podthread->output_string(\$thread);
+$podthread->parse_file($source);
+my $html;
+open(my $in_fh, '<', \$thread);
+open(my $out_fh, '>', \$html);
+$spin->_spin($in_fh, q{-}, $out_fh, q{-});
+close($in_fh);
+close($out_fh);
+
+# Add the additional metadata that should be added by spin.
+my $links = <<'EOD';
+ <link rel="stylesheet" href="/~eagle/styles/pod.css" type="text/css" />
+ <link rel="next" href="app-docknot-command.html"
+ title="App::DocKnot::Command" />
+ <link rel="up" href="../" title="DocKnot" />
+ <link rel="top" href="../../../" />
+EOD
+my $comment = '<!-- Spun by spin %VERSION% on %DATE% -->';
+my $navbar = <<'EOD';
+<table class="navbar"><tr>
+ <td class="navleft"></td>
+ <td>
+ <a href="../../../">Russ Allbery</a>
+ &gt; <a href="../../">Software</a>
+ &gt; <a href="../">DocKnot</a>
+ </td>
+ <td class="navright"><a href="app-docknot-command.html">App::DocKnot::Command</a>&nbsp;&gt;</td>
+</tr></table>
+
+EOD
+my $address = <<'EOD';
+<address>
+ Last <a href="https://www.eyrie.org/~eagle/software/web/">spun</a>
+ %DATE% from POD modified %DATE%
+</address>
+EOD
+$html =~ s{ (</head>) }{$links$1}xms;
+$html =~ s{ <!-- [ ] Spun .*? [ ] --> }{$comment}xms;
+$html =~ s{ (<body> \n) }{$1$navbar}xms;
+$html =~ s{ (</body>) }{$navbar$address$1}xms;
+
+# Replace the expected data file.
+my $output = File::Spec->catdir(
+ 't', 'data', 'spin', 'output', 'software', 'docknot',
+ 'api', 'app-docknot.html',
+);
+open(my $fh, '>', $output);
+print {$fh} $html or die "Cannot write to $output: $!\n";
+close($fh);