lib/OODoc/Text.pm

filter: Statementstmt 24.0% 18 / 75 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 23.8% 5 / 21 Podpod 92.8% 13 / 14 totaltotal 22.7% 36 / 158 CC 21 SCAR 32.5
CC
21
Cov
15%
publish
72.0
init
42.0
description
30.0
CRAP 25.9
« lib/OODoc/Export.pm ↑ Summary lib/OODoc/Format/Pod3.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;{
13 1 our $VERSION = '3.05';
14 }
15  
16 1 ▶use parent 'OODoc::Object';
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  
23 #--------------------
24  
25 use overload
26 0 ▶ '""' => sub {$_[0]->name},
Subroutine BEGIN: called CC=1 SCAR=0.6
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 ▶ 'cmp' => sub {$_[0]->name cmp "$_[1]"};
Subroutine __ANON__: not called CC=1 SCAR=0.2
28  
29 #--------------------
30  
31 sub init($)
32 0 ▶{ my ($self, $args) = @_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
33 0 ▶ $self->SUPER::init($args) or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init($args) or return 0 0 0
34  
35 0 $self->{OT_name} = delete $args->{name};
36  
37 0 ▶ my $nr = $self->{OT_linenr} = delete $args->{linenr} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $nr = $self->{"OT_linenr"} = delete $args->{"linenr"} or &panic() 0 0 0
38 0 ▶ $self->{OT_type} = delete $args->{type} or panic;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"OT_type"} = delete $args->{"type"} or &panic() 0 0 0
39  
40 exists $args->{container} # may be explicit undef
41 0 ▶ or panic "no text container specified for the ".(ref $self)." object";
Branch: 1 branch
BranchTrueFalseTotal
exists $args->{"container"} or &panic('no text container specified for the ' . ref($self) . ' object') 0 0 0
42  
43 0 $self->{OT_container}= delete $args->{container}; # may be undef initially
44 0 ▶ $self->{OT_descr} = delete $args->{description} || '';
Condition0%0/2
delete $args->{'description'} || ''
l!l
00
MC/DC0%0/1
delete $args->{'description'} || ''
delete $args->{'description'}
Truth table0%0/2
A
A= delete $args->{'description'}
Aresult
11
00
45 0 $self->{OT_examples} = [];
46 0 $self->{OT_extends} = [];
47 0 $self;
48 }
49  
50 #--------------------
51  
52 0 ▶sub name() { $_[0]->{OT_name} }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
53  
54  
55 0 ▶sub type() { $_[0]->{OT_type} }
Subroutine type: not called CC=1 SCAR=6.9
Pod documented
56  
57  
58 sub description()
59 0 ▶{ my @lines = split /^/m, shift->{OT_descr};
Subroutine description: not called CC=5 SCAR=34.0
Pod documented
60 0 ▶ shift @lines while @lines && $lines[ 0] =~ m/^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
@lines and $lines[0] =~ /^\s*$/ and do { shift @lines } 0 0 0
Condition0%0/3
@lines and $lines[0] =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
@lines and $lines[0] =~ /^\s*$/
@lines $lines[0] =~ /^\s*$/
Truth table0%0/3
A and B
A= @linesB= $lines[0] =~ /^\s*$/
ABresult
0X0
100
111
61 0 ▶ pop @lines while @lines && $lines[-1] =~ m/^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
@lines and $lines[-1] =~ /^\s*$/ and do { pop @lines } 0 0 0
Condition0%0/3
@lines and $lines[-1] =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
@lines and $lines[-1] =~ /^\s*$/
@lines $lines[-1] =~ /^\s*$/
Truth table0%0/3
A and B
A= @linesB= $lines[-1] =~ /^\s*$/
ABresult
0X0
100
111
62 0 join '', @lines;
63 }
64  
65  
66 sub container(;$)
67 0 ▶{ my $self = shift;
Subroutine container: not called CC=2 SCAR=17.9
Pod documented
68 0 ▶ @_ ? ($self->{OT_container} = shift) : $self->{OT_container};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
69 }
70  
71 0 ▶sub manual(;$) { $_[0]->container->manual }
Subroutine manual: not called CC=1 SCAR=6.9
Pod documented
72  
73  
74 0 ▶sub linenr() { $_[0]->{OT_linenr} }
Subroutine linenr: not called CC=1 SCAR=6.9
Pod documented
75  
76  
77 sub where()
78 0 ▶{ my $self = shift;
Subroutine where: not called CC=1 SCAR=6.9
Pod documented
79 0 ( $self->manual->source, $self->linenr );
80 }
81  
82  
83 sub extends(;$)
84 0 ▶{ my $self = shift;
Subroutine extends: not called CC=2 SCAR=17.9
Pod documented
85 0 my $ext = $self->{OT_extends};
86 0 push @$ext, @_;
87  
88 0 ▶ wantarray ? @$ext : $ext->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
89 }
90  
91 #--------------------
92  
93 0 ▶sub openDescription() { \($_[0]->{OT_descr}) }
Subroutine openDescription: not called CC=1 SCAR=6.9
Pod documented
94  
95  
96 sub findDescriptionObject()
97 0 ▶{ my $self = shift;
Subroutine findDescriptionObject: not called CC=3 SCAR=24.8
Pod documented
98 0 ▶ return $self if length $self->description;
Branch: 1 branch
BranchTrueFalseTotal
if length $self->description 0 0 0
99  
100 0 my @descr = map $_->findDescriptionObject, $self->extends;
101 0 ▶ wantarray ? @descr : $descr[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
102 }
103  
104  
105 sub addExample($)
106 0 ▶{ my ($self, $example) = @_;
Subroutine addExample: not called CC=1 SCAR=6.9
Pod documented
107 0 push @{$self->{OT_examples}}, $example;
108 0 $example;
109 }
110  
111  
112 0 ▶sub examples() { @{ $_[0]->{OT_examples}} }
Subroutine examples: not called CC=1 SCAR=6.9
Pod documented
113  
114 sub publish($%)
115 0 ▶{ my ($self, $args) = @_;
Subroutine publish: not called CC=8 SCAR=42.8
Pod documented
116 0 ▶ my $exporter = $args->{exporter} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $exporter = $args->{"exporter"} or &panic() 0 0 0
117 0 ▶ my $manual = $args->{manual} or panic;
Branch: 1 branch
BranchTrueFalseTotal
my $manual = $args->{"manual"} or &panic() 0 0 0
118 0 my $inherited = $manual->inherited($self);
119  
120 0 my $p = $self->SUPER::publish($args);
121 0 $p->{type} = $exporter->markup(lc $self->type);
122  
123 0 ▶ if(my $name = $self->name)
Branch: 1 branch
BranchTrueFalseTotal
if (my $name = $self->name) 0 0 0
124 0 { $p->{name} = $exporter->markupString($name);
125 }
126  
127 0 my $descr;
128 0 ▶ if($inherited)
Branch: 1 branch
BranchTrueFalseTotal
if ($inherited) { } 0 0 0
129 { # This node has nothing extra wrt its base implementation
130 0 $descr = 'Inherited, see M<'. $exporter->referTo($manual, $self).'>';
131 0 $p->{extends} = $self->unique;
132 }
133 else
134 0 ▶ { $descr = $self->description // '';
Condition0%0/2
$self->description // ""
l!l
00
MC/DC0%0/1
$self->description // ""
$self->description
Truth table0%0/2
A
A= $self->description
Aresult
11
00
135  
136 # Any kind of text can contain examples
137 0 my @e = map $_->publish($args)->{id}, $self->examples;
138 0 ▶ $p->{examples} = \@e if @e;
Branch: 1 branch
BranchTrueFalseTotal
if @e 0 0 0
139 }
140  
141 0 ▶ $p->{intro} = $exporter->markupBlock($descr)
Branch: 1 branch
BranchTrueFalseTotal
if length $descr 0 0 0
142 if length $descr;
143  
144 0 $p;
145 }
146  
147 1 1;
« lib/OODoc/Export.pm ↑ Summary lib/OODoc/Format/Pod3.pm »