line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Pod::Snippets::Parser; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
100
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
110
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use Pod::Parser; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
188
|
|
7
|
3
|
|
|
3
|
|
17
|
use base qw/ Pod::Parser /; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
868
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.03_03'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub initialize { |
12
|
1
|
|
|
1
|
0
|
10
|
$_[0]->SUPER::initialize; |
13
|
1
|
|
|
|
|
12
|
$_[0]->{$_} = 0 for qw/ tps_ignore tps_ignore_all tps_within_begin_test /; |
14
|
1
|
|
|
|
|
4
|
$_[0]->{tps_method_level} = 0; |
15
|
1
|
|
|
|
|
7
|
$_[0]->{tps_function_level} = 0; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub command { |
19
|
21
|
|
|
21
|
0
|
43
|
my ($parser, $command, $paragraph) = @_; |
20
|
|
|
|
|
|
|
|
21
|
21
|
50
|
|
|
|
142
|
if ( $command eq 'for' ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
my( $target, $directive, $rest ) = split ' ', $paragraph, 3; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
0
|
return unless $target eq 'test'; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
0
|
return $parser->{tps_ignore} = 1 if $directive eq 'ignore'; |
27
|
0
|
0
|
|
|
|
0
|
return $parser->{tps_ignore_all} = 1 if $directive eq 'ignore_all'; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
$parser->{tps_ignore} = 0; |
30
|
3
|
|
|
3
|
|
15
|
no warnings qw/ uninitialized /; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2779
|
|
31
|
0
|
|
|
|
|
0
|
print {$parser->output_handle} join ' ', $directive, $rest; |
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif( $command eq 'begin' ) { |
34
|
0
|
|
|
|
|
0
|
my( $target, $rest ) = split ' ', $paragraph, 2; |
35
|
0
|
0
|
|
|
|
0
|
return unless $target eq 'test'; |
36
|
0
|
|
|
|
|
0
|
$parser->{tps_within_begin_test} = 1; |
37
|
0
|
|
|
|
|
0
|
print {$parser->output_handle} $rest; |
|
0
|
|
|
|
|
0
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
elsif( $command eq 'end' ) { |
40
|
0
|
|
|
|
|
0
|
my( $target, $rest ) = split ' ', $paragraph, 2; |
41
|
0
|
0
|
|
|
|
0
|
return unless $target eq 'test'; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
$parser->{tps_within_begin_test} = 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif( $command =~ /^head(\d+)/ ) { |
46
|
|
|
|
|
|
|
|
47
|
21
|
|
|
|
|
31
|
$DB::single = 1; |
48
|
|
|
|
|
|
|
return unless $parser->{tps}->is_extracting_functions |
49
|
21
|
100
|
100
|
|
|
72
|
or $parser->{tps}->is_extracting_methods; |
50
|
|
|
|
|
|
|
|
51
|
14
|
|
|
|
|
29
|
my $level = $1; |
52
|
|
|
|
|
|
|
|
53
|
14
|
|
|
|
|
22
|
for my $type ( qw/ tps_method_level tps_function_level / ) { |
54
|
28
|
100
|
|
|
|
76
|
if ( $level <= $parser->{$type} ) { |
55
|
1
|
|
|
|
|
3
|
$parser->{$type} = 0; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
14
|
100
|
|
|
|
40
|
if ( $paragraph =~ /^\s*METHODS\s*$/ ) { |
60
|
|
|
|
|
|
|
$parser->{tps_method_level} = |
61
|
2
|
|
66
|
|
|
8
|
$parser->{tps}->is_extracting_methods && $level; |
62
|
2
|
|
|
|
|
90
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
12
|
100
|
|
|
|
30
|
if ( $paragraph =~ /^\s*FUNCTIONS\s*$/ ) { |
66
|
|
|
|
|
|
|
$parser->{tps_function_level} = |
67
|
2
|
|
66
|
|
|
6
|
$parser->{tps}->is_extracting_functions && $level; |
68
|
2
|
|
|
|
|
100
|
return; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
10
|
50
|
33
|
|
|
39
|
return if $parser->{tps_ignore} or $parser->{tps_ignore_all}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $master_level = $parser->{tps_method_level} |
74
|
|
|
|
|
|
|
|| $parser->{tps_function_level} |
75
|
10
|
|
100
|
|
|
317
|
|| return ; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# functions and methods are one level deeper than |
78
|
|
|
|
|
|
|
# their main header |
79
|
3
|
50
|
|
|
|
8
|
return unless $level == 1 + $master_level; |
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
6
|
$paragraph =~ s/[IBC]<(.*?)>/$1/g; # remove markups |
82
|
|
|
|
|
|
|
|
83
|
3
|
|
|
|
|
9
|
$paragraph =~ s/^\s+//; |
84
|
3
|
|
|
|
|
13
|
$paragraph =~ s/\s+$//; |
85
|
|
|
|
|
|
|
|
86
|
3
|
100
|
|
|
|
9
|
if ( $parser->{tps_method_level} ) { |
87
|
2
|
50
|
|
|
|
7
|
if ( $paragraph =~ /^new/ ) { |
88
|
0
|
|
|
|
|
0
|
print {$parser->output_handle} |
89
|
|
|
|
|
|
|
$parser->{tps}->get_object_name, |
90
|
0
|
|
|
|
|
0
|
' = $class->', $paragraph, ";\n"; |
91
|
0
|
|
|
|
|
0
|
return; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { |
94
|
2
|
|
|
|
|
9
|
$paragraph = $parser->{tps}->get_object_name.'->'.$paragraph; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
|
|
4
|
print {$parser->output_handle} '@result = ', $paragraph, ";\n"; |
|
3
|
|
|
|
|
145
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub textblock { |
103
|
9
|
50
|
|
9
|
0
|
360
|
return unless $_[0]->{tps_within_begin_test}; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
print_paragraph( @_ ); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
0
|
0
|
|
sub interior_sequence {} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub verbatim { |
111
|
6
|
|
|
6
|
0
|
9
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
6
|
100
|
|
|
|
21
|
return unless $self->{tps}->is_extracting_verbatim_bits; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return if ( $self->{tps_ignore} or $self->{tps_ignore_all} ) |
116
|
2
|
50
|
33
|
|
|
11
|
and not $self->{tps_within_begin_test}; |
|
|
|
33
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
6
|
print_paragraph( $self, @_ ); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub print_paragraph { |
122
|
2
|
|
|
2
|
0
|
4
|
my ( $parser, $paragraph, $line_no ) = @_; |
123
|
|
|
|
|
|
|
|
124
|
2
|
|
|
|
|
4
|
$DB::single = 1; |
125
|
2
|
|
50
|
|
|
14
|
my $filename = $parser->input_file || 'unknown'; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# remove the indent |
128
|
2
|
|
|
|
|
7
|
$paragraph =~ /^(\s*)/; |
129
|
2
|
|
|
|
|
5
|
my $indent = $1; |
130
|
2
|
|
|
|
|
25
|
$paragraph =~ s/^$indent//mg; |
131
|
2
|
|
|
|
|
14
|
$paragraph = "\n#line $line_no $filename\n".$paragraph; |
132
|
|
|
|
|
|
|
|
133
|
2
|
|
|
|
|
4
|
$paragraph .= ";\n"; |
134
|
|
|
|
|
|
|
|
135
|
2
|
|
|
|
|
2
|
print {$parser->output_handle} $paragraph; |
|
2
|
|
|
|
|
108
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
'end of Test::Pod::Snippets::Parser'; |