| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $self->{OT_type} = delete $args->{type} or panic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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'} || ''
MC/DC0%0/1
delete $args->{'description'} || ''
delete $args->{'description'}
Truth table0%0/2
A
A= delete $args->{'description'}
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
@lines and $lines[0] =~ /^\s*$/
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*$/
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | pop @lines while @lines && $lines[-1] =~ m/^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@lines and $lines[-1] =~ /^\s*$/
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*$/
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my @descr = map $_->findDescriptionObject, $self->extends; | |||||||||||||||||||||||||||
| 101 | 0 | ▶ | wantarray ? @descr : $descr[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $manual = $args->{manual} or panic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 124 | 0 | { $p->{name} = $exporter->markupString($name); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | my $descr; | |||||||||||||||||||||||||||
| 128 | 0 | ▶ | if($inherited) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 // ""
MC/DC0%0/1
$self->description // ""
$self->description
Truth table0%0/2
A
A= $self->description
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $p->{intro} = $exporter->markupBlock($descr) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | if length $descr; | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | $p; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 1 | 1; | |||||||||||||||||||||||||||