Knit/Plugin/NamedSections.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 97.5% 40 / 41 CC 4 SCAR 4.1
CC
4
Cov
100%
setup_podparser
2.0
munge
2.0
__ANON__
2.0
CRAP 1.5
« Knit/Output/Pod.pm ↑ Summary Knit/Plugin/Attributes.pm »
1 package Pod::Knit::Plugin::NamedSections;
2 3 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Create directive shortcuts for sections
4 3 $Pod::Knit::Plugin::NamedSections::VERSION = '0.0.1';
5  
6 3 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 extends 'Pod::Knit::Plugin';
13 3 with 'Pod::Knit::DOM::WebQuery';
14  
15 3 ▶use experimental 'signatures', 'postderef';
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 has sections => (
18 isa => 'ArrayRef',
19 is => 'ro',
20 lazy => 1,
21 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 1 []
23 },
24 3 traits => [ 'Array' ],
25 handles => { all_sections => 'elements' },
26 );
27  
28 2 ▶sub setup_podparser {
Subroutine setup_podparser: called CC=2 SCAR=6.9
Pod undocumented
29 2 my( $self, $parser ) = @_;
30  
31 2 $parser->accept_directive_as_processed( @{ $self->sections } );
32  
33 $parser->commands->{$_} = { alias => 'head1' }
34 2 for $self->all_sections;
35 }
36  
37 2 ▶sub munge( $self, $doc ) {
Subroutine munge: called CC=2 SCAR=6.9
38  
39 2 for my $section ( $self->all_sections ) {
40 2 ▶ $doc->dom->find( ".$section > head1" )->each(sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
41 2 ▶ return if $_->text;
Branch: 1 branch
BranchTrueFalseTotal
if $_->text 1 1 2
42 1 $_->text( uc $section );
43 2 });
44 }
45  
46 }
47  
48 3 1;
49  
50 __END__
« Knit/Output/Pod.pm ↑ Summary Knit/Plugin/Attributes.pm »