line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnnoCPAN::Perldoc::Filter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.10'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3050
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
86
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
986
|
use IO::String; |
|
1
|
|
|
|
|
5028
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
16845
|
use DBI; |
|
1
|
|
|
|
|
49784
|
|
|
1
|
|
|
|
|
88
|
|
9
|
1
|
|
|
1
|
|
12
|
use Digest::MD5 'md5_hex'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
279
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
bless {}, shift; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub filter { |
16
|
0
|
|
|
0
|
0
|
|
my ($self, $pod) = @_; |
17
|
0
|
|
|
|
|
|
my $notes = $self->find_notes($pod); |
18
|
0
|
0
|
|
|
|
|
return $pod unless @$notes; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $filtered_pod; |
21
|
0
|
|
|
|
|
|
my $fh_in = IO::String->new($pod); |
22
|
0
|
|
|
|
|
|
my $fh_out = IO::String->new($filtered_pod); |
23
|
0
|
|
|
|
|
|
my $parser = AnnoCPAN::Perldoc::Parser->new(ac_notes => $notes); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$parser->parse_from_filehandle($fh_in, $fh_out); |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $filtered_pod; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub find_notes { |
31
|
0
|
|
|
0
|
0
|
|
my ($self, $pod) = @_; |
32
|
0
|
|
|
|
|
|
my $signature = md5_hex($pod); |
33
|
0
|
|
|
|
|
|
my $db_file; |
34
|
0
|
|
|
|
|
|
DIR: for my $dir (@ENV{qw(HOME USERPROFILE ALLUSERSPROFILE)}, |
35
|
|
|
|
|
|
|
'/var/annocpan', '.' |
36
|
|
|
|
|
|
|
) { |
37
|
0
|
|
|
|
|
|
for my $file ('annopod.db', '.annopod.db') { |
38
|
1
|
|
|
1
|
|
7
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
234
|
|
39
|
0
|
0
|
|
|
|
|
$db_file = "$dir/$file", last DIR if -e "$dir/$file"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
0
|
0
|
|
|
|
|
unless ($db_file) { |
43
|
0
|
|
|
|
|
|
warn "Couldn't find any AnnoCPAN database\n"; |
44
|
0
|
|
|
|
|
|
return []; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
0
|
|
|
|
|
my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file") |
47
|
|
|
|
|
|
|
or die "Couldn't connect to database: $@\n"; |
48
|
0
|
0
|
|
|
|
|
my $notes = $dbh->selectall_arrayref( |
49
|
|
|
|
|
|
|
'SELECT DISTINCT n.note note, n.user user, n.time time, np.pos pos |
50
|
|
|
|
|
|
|
FROM note n, notepos np, podver pv |
51
|
|
|
|
|
|
|
WHERE np.note=n.id AND np.podver=pv.id AND pv.signature=? |
52
|
|
|
|
|
|
|
ORDER by pos, time', |
53
|
|
|
|
|
|
|
{Slice => {}}, |
54
|
|
|
|
|
|
|
$signature, |
55
|
|
|
|
|
|
|
) or die "$@"; |
56
|
0
|
|
|
|
|
|
$dbh->disconnect; |
57
|
0
|
|
|
|
|
|
return $notes; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
package AnnoCPAN::Perldoc::Parser; |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
|
5
|
use base 'Pod::Parser'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
433
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub verbatim { |
66
|
0
|
|
|
0
|
|
|
my ($self, $text, $line_num, $pod_para) = @_; |
67
|
0
|
|
|
|
|
|
$self->ac_section($text); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub textblock { |
71
|
0
|
|
|
0
|
|
|
my ($self, $text, $line_num, $pod_para) = @_; |
72
|
0
|
|
|
|
|
|
$self->ac_section($text); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub command { |
76
|
0
|
|
|
0
|
|
|
my ($self, $cmd, $text, $line_num, $pod_para) = @_; |
77
|
0
|
|
|
|
|
|
$self->ac_section($pod_para->raw_text); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub ac_section { |
81
|
0
|
|
|
0
|
|
|
my ($self, $text) = @_; |
82
|
0
|
|
|
|
|
|
my $pos = ++$self->{ac_pos}; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $out_fh = $self->output_handle; |
86
|
0
|
|
|
|
|
|
print $out_fh $text; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $notes = $self->{ac_notes}; |
90
|
0
|
|
0
|
|
|
|
while (@$notes and $notes->[0]{pos} == $pos) { |
91
|
0
|
|
|
|
|
|
my $note = shift @$notes; |
92
|
0
|
|
|
|
|
|
$note->{time_str} = gmtime($note->{time}); |
93
|
0
|
|
|
|
|
|
print $out_fh <<NOTE; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over 4 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item AnnoCPAN note by I<$note->{user}>, $note->{time_str}: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
$note->{note} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
NOTE |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
|