| 1 | package Pod::Index::Extract; | ||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 4 | 4 | $VERSION = '0.14'; | |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use base qw(Pod::Parser); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | sub begin_input { | ||||||||||||||||||||||||||||||||||
|
Subroutine
begin_input: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 12 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 13 | 6 | $self->cutting(0); # force parser to notice that it's in POD mode | |||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | sub verbatim { | ||||||||||||||||||||||||||||||||||
|
Subroutine
verbatim: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 17 | 4 | my ($self, $text, $line_num, $pod_para) = @_; | |||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||
| 19 | # verbatim should't have the X<> attached | ||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | return $self->ppi_done unless $self->{ppi_anchor_type}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||
| 22 | 4 | my $out_fh = $self->output_handle; | |||||||||||||||||||||||||||||||||||
| 23 | 4 | print $out_fh $text; | |||||||||||||||||||||||||||||||||||
| 24 | 4 | $self->{ppi_textblock_count}++; | |||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | 9 | ▶ | sub textblock { | ||||||||||||||||||||||||||||||||||
|
Subroutine
textblock: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 28 | 9 | my ($self, $text, $line_num, $pod_para) = @_; | |||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||
| 30 | # should sanity check that the X<> is really here... | ||||||||||||||||||||||||||||||||||||
| 31 | #print "<<<$text>>>\n"; | ||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||
| 33 | 9 | my $out_fh = $self->output_handle; | |||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||
| 35 | 9 | ▶ | unless ($self->{ppi_anchor_type}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 36 | 2 | $self->{ppi_anchor_type} = 'textblock'; | |||||||||||||||||||||||||||||||||||
| 37 | 2 | $self->ppi_start; | |||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||
| 40 | # only print the first paragraph if in textblock mode | ||||||||||||||||||||||||||||||||||||
| 41 | return $self->ppi_done if $self->{ppi_anchor_type} eq 'textblock' | ||||||||||||||||||||||||||||||||||||
| 42 | 9 | ▶ | and $self->{ppi_textblock_count}; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"ppi_anchor_type"} eq "textblock" and $self->{"ppi_textblock_count"}
MC/DC100%2/2
$self->{"ppi_anchor_type"} eq "textblock" and $self->{"ppi_textblock_count"}
$self->{"ppi_anchor_type"} eq "textblock"
$self->{"ppi_textblock_count"}
Truth table100%3/3
A and B
A= $self->{"ppi_anchor_type"} eq "textblock"B= $self->{"ppi_textblock_count"}
| |||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||
| 44 | 8 | print $out_fh $text; | |||||||||||||||||||||||||||||||||||
| 45 | 8 | $self->{ppi_textblock_count}++; | |||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||
| 48 | 15 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||
|
Subroutine
command: called CC=14 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 49 | 15 | my ($self, $cmd, $text, $line_num, $pod_para) = @_; | |||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | # should sanity check that the X<> is really here... | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 15 | my $out_fh = $self->output_handle; | |||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||
| 55 | 15 | ▶ | unless ($self->{ppi_anchor_type}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 56 | 4 | $self->{ppi_anchor_type} = 'command'; | |||||||||||||||||||||||||||||||||||
| 57 | 4 | $self->{ppi_command} = $cmd; | |||||||||||||||||||||||||||||||||||
| 58 | 4 | $self->ppi_start; | |||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | if ($cmd eq 'item') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 60 | 2 | print $out_fh "=over\n\n"; | |||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||
| 64 | 15 | ▶ | return $self->ppi_done unless $self->{ppi_anchor_type} eq 'command'; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | 14 | my $ppi_cmd = $self->{ppi_command}; | |||||||||||||||||||||||||||||||||||
| 67 | 14 | ▶ | return $self->ppi_done unless $ppi_cmd =~ /^(?:head|item)/; # XXX | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||
| 69 | # check if we are out of scope | ||||||||||||||||||||||||||||||||||||
| 70 | 14 | ▶ | if ($self->{ppi_textblock_count}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 71 | 8 | ▶ | if ($ppi_cmd =~ /^head(\d)/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||
| 72 | 2 | my $initial_level = $1; | |||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | if ($cmd =~ /^head(\d)/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 74 | 2 | my $current_level = $1; | |||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | return $self->ppi_done if $current_level <= $initial_level; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||
| 77 | } elsif ($ppi_cmd =~ /^item/) { | ||||||||||||||||||||||||||||||||||||
| 78 | 6 | ▶ | if ($cmd =~ /item|back/ and !$self->{ppi_depth}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$cmd =~ /item|back/ and not $self->{"ppi_depth"}
MC/DC100%2/2
$cmd =~ /item|back/ and not $self->{"ppi_depth"}
$cmd =~ /item|back/
not $self->{"ppi_depth"}
Truth table100%3/3
A and not(B)
A= $cmd =~ /item|back/B= not $self->{"ppi_depth"}
| |||||||||||||||||||||||||||||||||||||
| 79 | 2 | return $self->ppi_done; | |||||||||||||||||||||||||||||||||||
| 80 | } elsif ($cmd eq 'over') { | ||||||||||||||||||||||||||||||||||||
| 81 | 1 | $self->{ppi_depth}++; | |||||||||||||||||||||||||||||||||||
| 82 | } elsif ($cmd eq 'back') { | ||||||||||||||||||||||||||||||||||||
| 83 | 1 | $self->{ppi_depth}--; | |||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||||||||||||||||||
| 86 | 0 | die "shouldn't be here "; | |||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||
| 90 | 10 | print $out_fh $pod_para->raw_text; | |||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||
| 93 | 6 | ▶ | sub ppi_start { | ||||||||||||||||||||||||||||||||||
|
Subroutine
ppi_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 94 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||
| 97 | 6 | ▶ | sub ppi_done { | ||||||||||||||||||||||||||||||||||
|
Subroutine
ppi_done: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 98 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 99 | 6 | my $out_fh = $self->output_handle; | |||||||||||||||||||||||||||||||||||
| 100 | 6 | ▶ | if ($self->{ppi_command} and $self->{ppi_command} eq 'item') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"ppi_command"} and $self->{"ppi_command"} eq "item"
MC/DC100%2/2
$self->{"ppi_command"} and $self->{"ppi_command"} eq "item"
$self->{"ppi_command"}
$self->{"ppi_command"} eq "item"
Truth table100%3/3
A and B
A= $self->{"ppi_command"}B= $self->{"ppi_command"} eq "item"
| |||||||||||||||||||||||||||||||||||||
| 101 | 2 | print $out_fh "=back\n\n"; | |||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||
| 105 | 6 | my $fh = $self->input_handle; | |||||||||||||||||||||||||||||||||||
| 106 | 6 | seek $fh, 0, 2; # EOF | |||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||
| 109 | 4 | 1; | |||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||||||||||