|
0 |
package Test::Pod::_parser;
|
|
1 |
use base 'Pod::Simple';
|
|
2 |
use strict;
|
|
3 |
|
|
4 |
sub _handle_element_start {
|
|
5 |
my($parser, $element_name, $attr_hash_r) = @_;
|
|
6 |
|
|
7 |
# Curiously, Pod::Simple supports L<text|scheme:...> rather well.
|
|
8 |
|
|
9 |
if( $element_name eq "L" and $attr_hash_r->{type} eq "url") {
|
|
10 |
$parser->{_state_of_concern}{'Lurl'} = $attr_hash_r->{to};
|
|
11 |
}
|
|
12 |
|
|
13 |
return $parser->SUPER::_handle_element_start(@_);
|
|
14 |
}
|
|
15 |
|
|
16 |
sub _handle_element_end {
|
|
17 |
my($parser, $element_name) = @_;
|
|
18 |
|
|
19 |
delete $parser->{_state_of_concern}{'Lurl'}
|
|
20 |
if $element_name eq "L" and exists $parser->{_state_of_concern}{'Lurl'};
|
|
21 |
|
|
22 |
return $parser->SUPER::_handle_element_end(@_);
|
|
23 |
}
|
|
24 |
|
|
25 |
sub _handle_text {
|
|
26 |
my($parser, $text) = @_;
|
|
27 |
if( my $href = $parser->{_state_of_concern}{'Lurl'} ) {
|
|
28 |
if( $href ne $text ) {
|
|
29 |
my $line = $parser->line_count() -2; # XXX: -2, WHY WHY WHY??
|
|
30 |
|
|
31 |
$parser->whine($line, "L<text|scheme:...> is invalid according to perlpod");
|
|
32 |
}
|
|
33 |
}
|
|
34 |
|
|
35 |
return $parser->SUPER::_handle_text(@_);
|
|
36 |
}
|
|
37 |
|
|
38 |
1;
|
|
39 |
|
0 | 40 |
package Test::Pod;
|
1 | 41 |
|
2 | 42 |
use strict;
|
|
63 | 103 |
|
64 | 104 |
use 5.008;
|
65 | 105 |
|
66 | |
use Pod::Simple;
|
67 | 106 |
use Test::Builder;
|
68 | 107 |
use File::Spec;
|
69 | 108 |
|
|
80 | 119 |
|
81 | 120 |
$Test->exported_to($caller);
|
82 | 121 |
$Test->plan(@_);
|
|
122 |
}
|
|
123 |
|
|
124 |
sub _additional_test_pod_specific_checks {
|
|
125 |
my ($ok, $errata, $file) = @_;
|
|
126 |
|
|
127 |
return $ok;
|
83 | 128 |
}
|
84 | 129 |
|
85 | 130 |
=head1 FUNCTIONS
|
|
108 | 153 |
return;
|
109 | 154 |
}
|
110 | 155 |
|
111 | |
my $checker = Pod::Simple->new;
|
|
156 |
my $checker = Test::Pod::_parser->new;
|
112 | 157 |
|
113 | 158 |
$checker->output_string( \my $trash ); # Ignore any output
|
114 | 159 |
$checker->parse_file( $file );
|
115 | 160 |
|
116 | 161 |
my $ok = !$checker->any_errata_seen;
|
|
162 |
$ok = _additional_test_pod_specific_checks( $ok, ($checker->{errata}||={}), $file );
|
|
163 |
|
117 | 164 |
$Test->ok( $ok, $name );
|
118 | 165 |
if ( !$ok ) {
|
119 | 166 |
my $lines = $checker->{errata};
|