| 1 | package Pod::Knit::Plugin::HeadsToSections; | ||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||
| 3 | 1 | $Pod::Knit::Plugin::HeadsToSections::VERSION = '0.0.1'; | |||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use Web::Query; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use List::AllUtils qw/ part /; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | extends 'Pod::Knit::Plugin'; | |||||||||||||||||||
| 13 | 1 | with 'Pod::Knit::DOM::WebQuery'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 0 | ▶ | sub preprocess { | ||||||||||||||||||
|
Subroutine
preprocess: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 16 | 0 | my( $self, $doc ) = @_; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 0 | for my $level ( reverse 1..4 ) { | |||||||||||||||||||
| 19 | 0 | my( $in_section, $index ) = (0,0); | |||||||||||||||||||
| 20 | 0 | my @sections; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | $doc->find( \'./*' )->each(sub{ | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 23 | 0 | ▶ | if( $_->tagname =~ /^head(\d+)/ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | ▶ | if( $1 == $level ) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 25 | 0 | $index++; | |||||||||||||||||||
| 26 | 0 | $in_section = 1; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | elsif( $1 < $level ) { | ||||||||||||||||||||
| 29 | 0 | $in_section = 0; | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | 0 | ▶ | push @{$sections[ $in_section && $index]}, $_; | ||||||||||||||||||
|
Condition0%0/3
$in_section && $index
MC/DC0%0/2
$in_section && $index
$in_section
$index
Truth table0%0/3
A && B
A= $in_sectionB= $index
| |||||||||||||||||||||
| 33 | 0 | }); | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 0 | for my $i ( 1..$#sections ) { | |||||||||||||||||||
| 36 | 0 | my $s = shift @{ $sections[$i] }; | |||||||||||||||||||
| 37 | 0 | $s->html( | |||||||||||||||||||
| 38 | '<title>'. $s->html . '</title>' | ||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||
| 40 | 0 | ▶ | while( my $e = shift @{ $sections[$i] } ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | $e->detach; | |||||||||||||||||||
| 42 | 0 | $s->append($e); | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||