| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::More; |
| •4 |
use Config; |
| 5 |
|
| 6 |
use Dancer2::Core::DSL; |
| 7 |
use Pod::Simple::SimpleTree; |
| 8 |
use Ref::Util qw< is_arrayref >; |
| 9 |
|
| 10 |
{ |
| 11 |
package App; |
| 12 |
use Dancer2; |
| 13 |
} |
| 14 |
|
| 15 |
my $dsl_keywords = Dancer2::Core::DSL->new(app => App->to_app)->dsl_keywords; |
| 16 |
|
| 17 |
isa_ok($dsl_keywords, 'HASH', 'Check whether keywords are present'); |
| 18 |
|
| •19 |
my $dir = $ENV{AUTOPKGTEST_TMP} ? $Config{vendorlib} : 'lib'; |
| 20 |
my $podpa = Pod::Simple::SimpleTree->new->parse_file($dir . '/Dancer2/Manual/Keywords.pod')->root; |
| 21 |
|
| 22 |
for my $entry (@$podpa) { |
| 23 |
if (ref($entry) eq 'ARRAY') { |
| 24 |
if ($entry->[0] eq 'head2') { |
| 25 |
# get the bare keyword and compare with the authoritative list |
| 26 |
my $title = $entry->[2]; |
| 27 |
my $keyword = is_arrayref($title) ? $title->[2] : $title; |
| 28 |
|
| 29 |
if (exists $dsl_keywords->{$keyword}) { |
| 30 |
$dsl_keywords->{$keyword}->{found} = $entry->[1]->{startline}; |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
# go through the authoritative list and test we have a corresponding POD entry |
| 37 |
my %missing; |
| 38 |
for my $keyword ( sort keys %$dsl_keywords ) { |
| 39 |
exists $dsl_keywords->{$keyword}->{found} |
| 40 |
or $missing{$keyword}++; |
| 41 |
ok( exists $dsl_keywords->{$keyword}->{found}, "Keyword \"$keyword\" is documented in Dancer2::Manual::Keywords" ); |
| 42 |
} |
| 43 |
|
| 44 |
done_testing; |
| 45 |
|
| 46 |
print "$_\n" for keys %missing; |