Debian Codegraph @

t/dsl/pod.t

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