File Coverage

blib/lib/Pod/Elemental/Paragraph.pm
Criterion Covered Total %
statement 20 26 76.9
branch n/a
condition 0 2 0.0
subroutine 7 8 87.5
pod 1 1 100.0
total 28 37 75.6


line stmt bran cond sub pod time code
1             package Pod::Elemental::Paragraph 0.103006;
2             # ABSTRACT: a paragraph in a Pod document
3              
4 15     15   7838 use namespace::autoclean;
  15         30  
  15         111  
5 15     15   874 use Moose::Role;
  15         33  
  15         75  
6              
7 15     15   72359 use Encode qw(encode);
  15         131848  
  15         1002  
8 15     15   5662 use String::Truncate qw(elide);
  15         55732  
  15         87  
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             has content => (is => 'rw', isa => 'Str', required => 1);
34             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             sub as_pod_string {
46 37     37 1 59 my ($self) = @_;
47 37         930 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             sub _summarize_string {
59 0     0     my ($self, $str, $length) = @_;
60 0   0       $length ||= 30;
61              
62 15     15   12159 use utf8;
  15         210  
  15         75  
63 0           chomp $str;
64 0           my $elided = elide($str, $length, { truncate => 'middle', marker => '…' });
65 15     15   1028 $elided =~ tr/\n\t/␤␉/;
  15         32  
  15         271  
  0            
66              
67 0           return encode('utf-8', $elided);
68             }
69              
70             requires 'as_debug_string';
71              
72             1;
73              
74             __END__
75              
76             =pod
77              
78             =encoding UTF-8
79              
80             =head1 NAME
81              
82             Pod::Elemental::Paragraph - a paragraph in a Pod document
83              
84             =head1 VERSION
85              
86             version 0.103006
87              
88             =head1 OVERVIEW
89              
90             This is probably the most important role in the Pod-Elemental distribution.
91             Classes including this role represent paragraphs in a Pod document. The
92             paragraph is the fundamental unit of dividing up Pod documents, so this is a
93             often-included role.
94              
95             =head1 PERL VERSION
96              
97             This library should run on perls released even a long time ago. It should work
98             on any version of perl released in the last five years.
99              
100             Although it may work on older versions of perl, no guarantee is made that the
101             minimum required version will not be increased. The version may be increased
102             for any reason, and there is no promise that patches will be accepted to lower
103             the minimum required perl.
104              
105             =head1 ATTRIBUTES
106              
107             =head2 content
108              
109             This is the textual content of the element, as in a Pod::Eventual event. In
110             other words, this Pod:
111              
112             =head2 content
113              
114             has a content of "content\n"
115              
116             =head2 start_line
117              
118             This attribute, which may or may not be set, indicates the line in the source
119             document where the element began.
120              
121             =head1 METHODS
122              
123             =head2 as_pod_string
124              
125             This returns the element as a string, suitable for turning elements back into
126             a document. Some elements, like a C<=over> command, will stringify to include
127             extra content like a C<=back> command. In the case of elements with children,
128             this method will include the stringified children as well.
129              
130             =head2 as_debug_string
131              
132             This method returns a string, like C<as_string>, but is meant for getting an
133             overview of the document structure, and is not suitable for reproducing a
134             document. Its exact output is likely to change over time.
135              
136             =head1 AUTHOR
137              
138             Ricardo SIGNES <cpan@semiotic.systems>
139              
140             =head1 COPYRIGHT AND LICENSE
141              
142             This software is copyright (c) 2022 by Ricardo SIGNES.
143              
144             This is free software; you can redistribute it and/or modify it under
145             the same terms as the Perl 5 programming language system itself.
146              
147             =cut