| 17 | | my $tag_count = (scalar keys(%{ $tags->{function} }) |
|---|
| 18 | | + scalar keys(%{ $tags->{modifier} }) |
|---|
| 19 | | + scalar keys(%{ $tags->{block} })) |
|---|
| 20 | | - 3; # the registry gives us an extra 'plugin' key for each element |
|---|
| | 41 | my $tag_count = 0; |
|---|
| | 42 | foreach my $c (keys %$components) { |
|---|
| | 43 | next unless $mt->component($c); |
|---|
| | 44 | my $tags = $mt->component($c)->registry('tags'); |
|---|
| | 45 | my $fn_count = scalar keys(%{ $tags->{function} }); |
|---|
| | 46 | $fn_count-- if $fn_count; |
|---|
| | 47 | my $mod_count = scalar keys(%{ $tags->{modifier} }); |
|---|
| | 48 | $mod_count-- if $mod_count; |
|---|
| | 49 | my $block_count = scalar keys(%{ $tags->{block} }); |
|---|
| | 50 | $block_count-- if $block_count; |
|---|
| | 51 | my $count = $fn_count + $mod_count + $block_count; |
|---|
| | 52 | $tag_count += $count; |
|---|
| | 53 | } |
|---|
| | 54 | |
|---|
| 23 | | my $core_docs = ''; |
|---|
| 24 | | { |
|---|
| 25 | | local $/ = undef; |
|---|
| 26 | | foreach my $file ( @core_docs ) { |
|---|
| 27 | | # core tag docs are embedded as POD |
|---|
| 28 | | open DOC, "< $file"; |
|---|
| 29 | | $core_docs .= <DOC>; |
|---|
| 30 | | close DOC; |
|---|
| | 57 | foreach my $c (keys %$components) { |
|---|
| | 58 | next unless $mt->component($c); |
|---|
| | 59 | diag("Checking for tag documentation for component $c"); |
|---|
| | 60 | my $all_docs = ''; |
|---|
| | 61 | my $tags = $mt->component($c)->registry('tags'); |
|---|
| | 62 | my $paths = $components->{$c}{paths}; |
|---|
| | 63 | { |
|---|
| | 64 | local $/ = undef; |
|---|
| | 65 | FILE: foreach my $file ( @$paths ) { |
|---|
| | 66 | # core tag docs are embedded as POD |
|---|
| | 67 | foreach my $inc ( @INC ) { |
|---|
| | 68 | my $file_path = File::Spec->catfile($inc, $file); |
|---|
| | 69 | next unless -e $file_path; |
|---|
| | 70 | |
|---|
| | 71 | diag("Reading module $file_path"); |
|---|
| | 72 | open DOC, "< $file_path" |
|---|
| | 73 | or die "Can't read file $file_path: " . $!; |
|---|
| | 74 | $all_docs .= <DOC>; |
|---|
| | 75 | close DOC; |
|---|
| | 76 | next FILE; |
|---|
| | 77 | } |
|---|
| | 78 | die "Could not locate $file!"; |
|---|
| | 79 | } |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 82 | # Determine if the core tags have adequate documentation or not. |
|---|
| | 83 | my $doc_names = {}; |
|---|
| | 84 | while ($all_docs =~ m/\n=head2[ ]+([\w:]+)[ ]*\n(.*?)?\n=cut[ ]*\n/gs) { |
|---|
| | 85 | my $tag = $1; |
|---|
| | 86 | my $docs = defined $2 ? $2 : ''; |
|---|
| | 87 | $docs =~ s/\r//g; # for windows newlines |
|---|
| | 88 | # ignore comment lines |
|---|
| | 89 | $docs =~ s/^#.*//gm; |
|---|
| | 90 | # ignore empty lines |
|---|
| | 91 | $docs =~ s/^\s*$//gm; |
|---|
| | 92 | # strip any '=for ...', etc. directive. docs should be above this |
|---|
| | 93 | $docs =~ s/(^|\n)=\w+.*//s; |
|---|
| | 94 | # strip trailing/leading newlines |
|---|
| | 95 | $docs =~ s/^\n+//s; |
|---|
| | 96 | $docs =~ s/\n+$//s; |
|---|
| | 97 | # if documentation block doesn't have anything left, the tag is undocumented |
|---|
| | 98 | next if $docs eq ''; |
|---|
| | 99 | $doc_names->{$tag} = 1; |
|---|
| | 100 | } |
|---|
| | 101 | |
|---|
| | 102 | foreach my $tag ( keys %{ $tags->{function} } ) { |
|---|
| | 103 | next if $tag eq 'plugin'; |
|---|
| | 104 | ok(exists $doc_names->{$tag}, "component $c, function tag $tag"); |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| | 107 | foreach my $tag ( keys %{ $tags->{block} } ) { |
|---|
| | 108 | next if $tag eq 'plugin'; |
|---|
| | 109 | $tag =~ s/\?$//; |
|---|
| | 110 | ok(exists $doc_names->{$tag}, "component $c, block tag $tag"); |
|---|
| | 111 | } |
|---|
| | 112 | |
|---|
| | 113 | foreach my $tag ( keys %{ $tags->{modifier} } ) { |
|---|
| | 114 | next if $tag eq 'plugin'; |
|---|
| | 115 | ok(exists $doc_names->{$tag}, "component $c, modifier $tag"); |
|---|
| 34 | | # Determine if the core tags have adequate documentation or not. |
|---|
| 35 | | my $doc_names = {}; |
|---|
| 36 | | while ($core_docs =~ m/\n=head2[ ]+([\w:]+)[ ]*\n(.*?)?\n=cut[ ]*\n/gs) { |
|---|
| 37 | | my $tag = $1; |
|---|
| 38 | | my $docs = defined $2 ? $2 : ''; |
|---|
| 39 | | $docs =~ s/\r//g; # for windows newlines |
|---|
| 40 | | # ignore comment lines |
|---|
| 41 | | $docs =~ s/^#.*//gm; |
|---|
| 42 | | # ignore empty lines |
|---|
| 43 | | $docs =~ s/^\s*$//gm; |
|---|
| 44 | | # strip any '=for ...', etc. directive. docs should be above this |
|---|
| 45 | | $docs =~ s/(^|\n)=\w+.*//s; |
|---|
| 46 | | # strip trailing/leading newlines |
|---|
| 47 | | $docs =~ s/^\n+//s; |
|---|
| 48 | | $docs =~ s/\n+$//s; |
|---|
| 49 | | # if documentation block doesn't have anything left, the tag is undocumented |
|---|
| 50 | | next if $docs eq ''; |
|---|
| 51 | | $doc_names->{lc $tag} = 1; |
|---|
| 52 | | } |
|---|
| 53 | | |
|---|
| 54 | | foreach my $tag ( keys %{ $tags->{function} } ) { |
|---|
| 55 | | next if $tag eq 'plugin'; |
|---|
| 56 | | ok(exists $doc_names->{lc $tag}, "function tag $tag"); |
|---|
| 57 | | } |
|---|
| 58 | | |
|---|
| 59 | | foreach my $tag ( keys %{ $tags->{block} } ) { |
|---|
| 60 | | next if $tag eq 'plugin'; |
|---|
| 61 | | $tag =~ s/\?$//; |
|---|
| 62 | | ok(exists $doc_names->{lc $tag}, "block tag $tag"); |
|---|
| 63 | | } |
|---|
| 64 | | |
|---|
| 65 | | foreach my $tag ( keys %{ $tags->{modifier} } ) { |
|---|
| 66 | | next if $tag eq 'plugin'; |
|---|
| 67 | | ok(exists $doc_names->{lc $tag}, "modifier $tag"); |
|---|
| 68 | | } |
|---|
| 69 | | |
|---|