| 1 | package Pod::Elemental::Paragraph 0.103006; | ||||||||||||
| 2 | # ABSTRACT: a paragraph in a Pod document | ||||||||||||
| 3 | |||||||||||||
| 4 | 15 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 15 | ▶ | use Moose::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 15 | ▶ | use Encode qw(encode); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 15 | ▶ | use String::Truncate qw(elide); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | #pod =head1 OVERVIEW | ||||||||||||
| 11 | #pod | ||||||||||||
| 12 | #pod This is probably the most important role in the Pod-Elemental distribution. | ||||||||||||
| 13 | #pod Classes including this role represent paragraphs in a Pod document. The | ||||||||||||
| 14 | #pod paragraph is the fundamental unit of dividing up Pod documents, so this is a | ||||||||||||
| 15 | #pod often-included role. | ||||||||||||
| 16 | #pod | ||||||||||||
| 17 | #pod =attr content | ||||||||||||
| 18 | #pod | ||||||||||||
| 19 | #pod This is the textual content of the element, as in a Pod::Eventual event. In | ||||||||||||
| 20 | #pod other words, this Pod: | ||||||||||||
| 21 | #pod | ||||||||||||
| 22 | #pod =head2 content | ||||||||||||
| 23 | #pod | ||||||||||||
| 24 | #pod has a content of "content\n" | ||||||||||||
| 25 | #pod | ||||||||||||
| 26 | #pod =attr start_line | ||||||||||||
| 27 | #pod | ||||||||||||
| 28 | #pod This attribute, which may or may not be set, indicates the line in the source | ||||||||||||
| 29 | #pod document where the element began. | ||||||||||||
| 30 | #pod | ||||||||||||
| 31 | #pod =cut | ||||||||||||
| 32 | |||||||||||||
| 33 | 15 | has content => (is => 'rw', isa => 'Str', required => 1); | |||||||||||
| 34 | 15 | has start_line => (is => 'ro', isa => 'Int', required => 0); | |||||||||||
| 35 | |||||||||||||
| 36 | #pod =method as_pod_string | ||||||||||||
| 37 | #pod | ||||||||||||
| 38 | #pod This returns the element as a string, suitable for turning elements back into | ||||||||||||
| 39 | #pod a document. Some elements, like a C<=over> command, will stringify to include | ||||||||||||
| 40 | #pod extra content like a C<=back> command. In the case of elements with children, | ||||||||||||
| 41 | #pod this method will include the stringified children as well. | ||||||||||||
| 42 | #pod | ||||||||||||
| 43 | #pod =cut | ||||||||||||
| 44 | |||||||||||||
| 45 | 37 | ▶ | sub as_pod_string { | ||||||||||
|
Subroutine
as_pod_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 46 | 37 | my ($self) = @_; | |||||||||||
| 47 | 37 | return $self->content; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | #pod =method as_debug_string | ||||||||||||
| 51 | #pod | ||||||||||||
| 52 | #pod This method returns a string, like C<as_string>, but is meant for getting an | ||||||||||||
| 53 | #pod overview of the document structure, and is not suitable for reproducing a | ||||||||||||
| 54 | #pod document. Its exact output is likely to change over time. | ||||||||||||
| 55 | #pod | ||||||||||||
| 56 | #pod =cut | ||||||||||||
| 57 | |||||||||||||
| 58 | 0 | ▶ | sub _summarize_string { | ||||||||||
|
Subroutine
_summarize_string: not called CC=2 SCAR=12.6
| |||||||||||||
| 59 | 0 | my ($self, $str, $length) = @_; | |||||||||||
| 60 | 0 | ▶ | $length ||= 30; | ||||||||||
|
Condition0%0/2
$length ||= 30
MC/DC0%0/1
$length ||= 30
$length
Truth table0%0/2
A
A= $length
| |||||||||||||
| 61 | |||||||||||||
| 62 | 15 | ▶ | use utf8; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 63 | 0 | chomp $str; | |||||||||||
| 64 | 0 | my $elided = elide($str, $length, { truncate => 'middle', marker => '…' }); | |||||||||||
| 65 | 0 | $elided =~ tr/\n\t/␉/; | |||||||||||
| 66 | |||||||||||||
| 67 | 0 | return encode('utf-8', $elided); | |||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | 15 | requires 'as_debug_string'; | |||||||||||
| 71 | |||||||||||||
| 72 | 15 | 1; | |||||||||||
| 73 | |||||||||||||
| 74 | __END__ | ||||||||||||