lib/OODoc/Text/Structure.pm

filter: Statementstmt 26.0% 18 / 69 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 22.7% 5 / 22 Podpod 92.3% 12 / 13 totaltotal 26.5% 35 / 132 CC 15 SCAR 25.4
CC
15
Cov
19%
isEmpty
42.0
addSubroutine
20.0
init
12.0
CRAP 12.6
« lib/OODoc/Export/JSON.pm ↑ Summary lib/OODoc/Text/Default.pm »
1 # This code is part of Perl distribution OODoc version 3.05.
2 # The POD got stripped from this file by OODoc version 3.05.
3 # For contributors see file ChangeLog.
4  
5 # This software is copyright (c) 2003-2025 by Mark Overmeer.
6  
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10  
11  
12 package OODoc::Text::Structure;{
13 1 our $VERSION = '3.05';
14 }
15  
16 1 ▶use parent 'OODoc::Text';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use Log::Report 'oodoc';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use List::Util 'first';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 #--------------------
25  
26 sub init($)
27 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=3 SCAR=24.8
Pod undocumented
28 0 ▶ $self->SUPER::init($args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
29 0 $self->{OTS_subs} = [];
30 0 ▶ $self->{OTS_level} = delete $args->{level} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"OTS_level"} = delete $args->{"level"} or &panic() 0 0 0
31 0 $self;
32 }
33  
34  
35 sub emptyExtension($)
36 0 ▶{ my ($self, $container) = @_;
Subroutine emptyExtension: not called CC=1 SCAR=6.9
Pod documented
37  
38 0 my $new = (ref $self)->new(
39 name => $self->name,
40 linenr => -1,
41 level => $self->level,
42 container => $container,
43 );
44 0 $new->extends($self);
45 0 $new;
46 }
47  
48 #--------------------
49  
50 0 ▶sub level() { $_[0]->{OTS_level} }
Subroutine level: not called CC=1 SCAR=6.9
Pod documented
51  
52  
53 sub niceName()
54 0 ▶{ my $name = shift->name;
Subroutine niceName: not called CC=2 SCAR=17.9
Pod documented
55 0 ▶ $name =~ m/[a-z]/ ? $name : ucfirst(lc $name);
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /[a-z]/ ? : 0 0 0
56 }
57  
58 #--------------------
59  
60 0 ▶sub path() { panic "Not implemented" }
Subroutine path: not called CC=1 SCAR=6.9
Pod documented
61  
62  
63 0 ▶sub findEntry($) { panic "Not implemented" }
Subroutine findEntry: not called CC=1 SCAR=6.9
Pod documented
64  
65 #--------------------
66  
67 sub all($@)
68 0 ▶{ my ($self, $method) = (shift, shift);
Subroutine all: not called CC=1 SCAR=6.9
Pod documented
69 0 $self->$method(@_);
70 }
71  
72  
73 sub isEmpty()
74 0 ▶{ my $self = shift;
Subroutine isEmpty: not called CC=6 SCAR=37.4
Pod documented
75  
76 0 my $manual = $self->manual;
77 0 ▶ return 0 if $self->description !~ m/^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->description =~ /^\s*$/ 0 0 0
78 0 ▶ return 0 if first { !$manual->inherited($_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 0 ▶ $self->examples, $self->subroutines;
Branch: 1 branch
BranchTrueFalseTotal
if &first(sub { not $manual->inherited($_); } , $self->examples, $self->subroutines) 0 0 0
80  
81 my @nested
82 0 ▶ = $self->isa('OODoc::Text::Chapter') ? $self->sections
Branch: 3 branches
BranchTrueFalseTotal
$self->isa('OODoc::Text::Chapter') ? : 0 0 0
$self->isa('OODoc::Text::Section') ? : 0 0 0
$self->isa('OODoc::Text::SubSection') ? : 0 0 0
83 : $self->isa('OODoc::Text::Section') ? $self->subsections
84 : $self->isa('OODoc::Text::SubSection') ? $self->subsubsections
85 : return 1;
86  
87 0 ▶ not first { !$_->isEmpty } @nested;
Subroutine __ANON__: not called CC=1 SCAR=6.9
88 }
89  
90 sub publish($$)
91 0 ▶{ my ($self, $args) = @_;
Subroutine publish: not called CC=3 SCAR=24.8
Pod documented
92 0 my $p = $self->SUPER::publish($args);
93 0 $p->{level} = $self->level;
94 0 $p->{path} = $self->path;
95  
96 0 my @n = map $_->publish($args)->{id}, $self->nest;
97 0 ▶ $p->{nest} = \@n if @n;
Branch: 1 branch
BranchTrueFalseTotal
if @n 0 0 0
98  
99 0 my @s = map $_->publish($args)->{id}, $self->subroutines;
100 0 ▶ $p->{subroutines} = \@s if @s;
Branch: 1 branch
BranchTrueFalseTotal
if @s 0 0 0
101 0 $p;
102 }
103  
104 #--------------------
105  
106 sub addSubroutine(@)
107 0 ▶{ my ($self, $fn, @objs) = @_;
Subroutine addSubroutine: not called CC=4 SCAR=30.0
Pod documented
108 0 ▶ my $subs = $self->{OTS_subs} ||= [];
Condition0%0/2
$self->{"OTS_subs"} ||= []
l!l
00
MC/DC0%0/1
$self->{"OTS_subs"} ||= []
$self->{"OTS_subs"}
Truth table0%0/2
A
A= $self->{"OTS_subs"}
Aresult
11
00
109  
110 0 foreach my $sub (@objs)
111 0 { $sub->container($self);
112  
113 0 my $name = $sub->name;
114 0 ▶ if(my $has = first { $_->name eq $name } @$subs)
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (my $has = &first(sub { $_->name eq $name; } , @$subs)) 0 0 0
115 0 { warning __x"name '{name}' seen before, file {file} lines {nr1} and {nr2}", name => $name, file => $fn, nr1 => $has->linenr, nr2 => $sub->linenr;
116 }
117 0 push @{$self->{OTS_subs}}, $sub;
118 }
119  
120 0 $self;
121 }
122  
123  
124 0 ▶sub subroutines() { @{ $_[0]->{OTS_subs}} }
Subroutine subroutines: not called CC=1 SCAR=6.9
Pod documented
125  
126  
127 sub subroutine($)
128 0 ▶{ my ($self, $name) = @_;
Subroutine subroutine: not called CC=1 SCAR=6.9
Pod documented
129 0 ▶ first {$_->name eq $name} $self->subroutines;
Subroutine __ANON__: not called CC=1 SCAR=6.9
130 }
131  
132  
133 sub setSubroutines($)
134 0 ▶{ my $self = shift;
Subroutine setSubroutines: not called CC=2 SCAR=17.9
Pod documented
135 0 ▶ $self->{OTS_subs} = shift || [];
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
136 }
137  
138 1 1;
« lib/OODoc/Export/JSON.pm ↑ Summary lib/OODoc/Text/Default.pm »