blib/lib/Pod/Manual/PodXML2Docbook.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 95.6% 66 / 69 CC 7 SCAR 9.3
CC
7
Cov
100%
tc_title
4.0
action_sect1
3.0
tc_list
2.0
CRAP 2.5
« blib/lib/Pod/Manual.pm ↑ Summary script/podmanual »
1 package Pod::Manual::PodXML2Docbook;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 ▶use XML::XPathScript::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use XML::XPathScript::Processor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 our $VERSION = '0.08';
10  
11 5 our $processor;
12  
13 5 our $stylesheet = <<'END_STYLESHEET';
14 <?xml version="1.0" encoding="iso-8859-1"?>
15 <%
16 $XML::XPathScript::current->interpolating( 0 );
17 $Pod::Manual::PodXML2Docbook::processor = $processor;
18 $template->import_template( $Pod::Manual::PodXML2Docbook::template );
19 %>
20 <%~ / %>
21 END_STYLESHEET
22  
23 5 our $template = XML::XPathScript::Template->new;
24  
25 5 $template->set( pod => { content => <<'END_CONTENT' } );
26 <chapter>
27 <%~ head %>
28 <%~ sect1[title/text()="DESCRIPTION"] %>
29 <%~ sect1[title/text()!="DESCRIPTION"] %>
30 </chapter>
31 END_CONTENT
32  
33 5 $template->set( head => {
34 showtag => 0,
35 } );
36 5 $template->set( sect1 => { testcode => \&action_sect1 } );
37 5 $template->set( "sect$_" => { rename => 'section' } ) for 1..5;
38  
39 5 $template->set( 'list' => { testcode => \&tc_list } );
40  
41 5 $template->set( code => {
42 pre => '<literal role="code">',
43 post => '</literal>' } );
44  
45 5 $template->set( strong => {
46 pre => '<emphasis role="bold">',
47 post => '</emphasis>' } );
48  
49 5 $template->set( emphasis => {
50 pre => '<emphasis role="italic">',
51 post => '</emphasis>' } );
52  
53 5 $template->set( verbatim => { rename => 'screen' } );
54  
55 5 $template->set( title => {
56 showtag => 1,
57 testcode => \&tc_title } );
58  
59 59 ▶sub tc_title {
Subroutine tc_title: called CC=4 SCAR=13.9
Pod undocumented
60 59 my ( $n, $t ) = @_;
61  
62 59 my $abbrev;
63 59 ▶ if ( $n->parentNode->getName eq "sect1" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n->parentNode->getName eq "sect1") 32 27 59
64 32 ( $abbrev ) = eval { split '-', $n->childNodes->[0]->toString, 2 };
65 }
66  
67 59 ▶ $t->set({ post => "<titleabbrev>$abbrev</titleabbrev>" }) if $abbrev;
Branch: 1 branch
BranchTrueFalseTotal
if $abbrev 32 27 59
68  
69 59 ▶ return $n->findvalue( 'text()' ) eq 'DESCRIPTION'
Branch: 1 branch
BranchTrueFalseTotal
$n->findvalue('text()') eq 'DESCRIPTION' ? : 3 56 59
70 ? $DO_NOT_PROCESS
71 : $DO_SELF_AND_KIDS
72 ;
73 }
74  
75 40 ▶sub action_sect1 {
Subroutine action_sect1: called CC=3 SCAR=11.0
Pod undocumented
76 40 my( $n, $t ) = @_;
77  
78 40 my $title = $n->findvalue( 'title/text()' );
79  
80 40 ▶ if ( $title eq 'DESCRIPTION' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($title eq "DESCRIPTION") 3 37 40
81 3 $t->set({ pre => '', showtag => 0 });
82 }
83  
84 40 ▶ return $title eq 'NAME' ? $DO_NOT_PROCESS : $DO_SELF_AND_KIDS ;
Branch: 1 branch
BranchTrueFalseTotal
$title eq 'NAME' ? : 8 32 40
85 }
86  
87 5 $template->set( 'item' => { showtag => 0 } );
88 5 $template->set( 'itemtext' => { showtag => 0 } );
89  
90 6 ▶sub tc_list {
Subroutine tc_list: called CC=2 SCAR=6.9
Pod undocumented
91 6 my ( $n, $t ) = @_;
92 6 my $output;
93  
94 #if ( $n->findnodes( 'item/itemtext' ) ) { # we are a variable list
95 # $output = '<variablelist>';
96 # for my $c ( $n->findnodes('item') ) {
97 # my $item = '<varlistentry>';
98 # $item .= '<term>' . $c->findvalue( 'term/text()' ) . '</term>';
99 # $item .= '<listitem>';
100 # $item .= $processor->apply_templates( $c );
101 # $item .= '</listitem>';
102 # $item .= '</varlistentry>';
103 # $output .= $item;
104 # }
105 # $output .= '</variablelist>';
106 #}
107 #else { # we are a itemized list
108 6 $output = '<itemizedlist>';
109  
110 6 for ( $n->findnodes( 'item' ) ) {
111 9 $output .= '<listitem>'
112 . $processor->apply_templates( $_ )
113 . '</listitem>'
114 ;
115 }
116  
117 6 $output .= '</itemizedlist>';
118  
119 #}
120  
121 6 $t->{pre} = $output;
122  
123 6 return $DO_SELF_ONLY;
124 }
125  
126 5 'end of Pod::Manual::PodXML2Docbook';
« blib/lib/Pod/Manual.pm ↑ Summary script/podmanual »