| 1 | package Pod::Weaver::Section::Authors 4.022; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: a section listing authors | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | with 'Pod::Weaver::Role::Section'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # BEGIN BOILERPLATE | ||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use v5.22.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | no feature 'switch'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use experimental qw(postderef postderef_qq); # This experiment gets mainlined. | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | # END BOILERPLATE | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use Pod::Elemental::Element::Nested; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Pod::Elemental::Element::Pod5::Verbatim; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #pod =head1 OVERVIEW | ||||||||||||||||||||||||||||
| 19 | #pod | ||||||||||||||||||||||||||||
| 20 | #pod This section adds a listing of the documents authors. It expects a C<authors> | ||||||||||||||||||||||||||||
| 21 | #pod input parameter to be an arrayref of strings. If no C<authors> parameter is | ||||||||||||||||||||||||||||
| 22 | #pod given, it will do nothing. Otherwise, it produces a hunk like this: | ||||||||||||||||||||||||||||
| 23 | #pod | ||||||||||||||||||||||||||||
| 24 | #pod =head1 AUTHORS | ||||||||||||||||||||||||||||
| 25 | #pod | ||||||||||||||||||||||||||||
| 26 | #pod Author One <a1@example.com> | ||||||||||||||||||||||||||||
| 27 | #pod Author Two <a2@example.com> | ||||||||||||||||||||||||||||
| 28 | #pod | ||||||||||||||||||||||||||||
| 29 | #pod =attr header | ||||||||||||||||||||||||||||
| 30 | #pod | ||||||||||||||||||||||||||||
| 31 | #pod The title of the header to be added. | ||||||||||||||||||||||||||||
| 32 | #pod (default: "AUTHOR" or "AUTHORS") | ||||||||||||||||||||||||||||
| 33 | #pod | ||||||||||||||||||||||||||||
| 34 | #pod =cut | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 5 | has header => ( | |||||||||||||||||||||||||||
| 37 | is => 'ro', | ||||||||||||||||||||||||||||
| 38 | isa => 'Maybe[Str]', | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 7 | ▶ | sub weave_section { | ||||||||||||||||||||||||||
|
Subroutine
weave_section: called CC=6 SCAR=18.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 7 | my ($self, $document, $input) = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 7 | ▶ | return unless $input->{authors}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 7 | my $multiple_authors = $input->{authors}->@* > 1; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # I think I might like to have header be a callback or something, so that you | ||||||||||||||||||||||||||||
| 49 | # can get pluralization for your own custom header. -- rjbs, 2015-03-17 | ||||||||||||||||||||||||||||
| 50 | 7 | ▶ | my $name = $self->header || ($multiple_authors ? 'AUTHORS' : 'AUTHOR'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->header || ($multiple_authors ? 'AUTHORS' : 'AUTHOR')
MC/DC0%0/2
$self->header || ($multiple_authors ? 'AUTHORS' : 'AUTHOR')
$self->header
($multiple_authors ? 'AUTHORS' : 'AUTHOR')
Truth table33%1/3
A || B
A= $self->headerB= ($multiple_authors ? 'AUTHORS' : 'AUTHOR')
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 7 | $self->log_debug("adding $name section"); | |||||||||||||||||||||||||||
| 53 | 7 | $self->log_debug("author = $_") for $input->{authors}->@*; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | my $authors = [ map { | ||||||||||||||||||||||||||||
| 56 | 14 | Pod::Elemental::Element::Pod5::Ordinary->new({ | |||||||||||||||||||||||||||
| 57 | content => $_, | ||||||||||||||||||||||||||||
| 58 | }), | ||||||||||||||||||||||||||||
| 59 | 7 | } $input->{authors}->@* ]; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | $authors = [ | ||||||||||||||||||||||||||||
| 62 | Pod::Elemental::Element::Pod5::Command->new({ | ||||||||||||||||||||||||||||
| 63 | command => 'over', content => '4', | ||||||||||||||||||||||||||||
| 64 | }), | ||||||||||||||||||||||||||||
| 65 | ( map { | ||||||||||||||||||||||||||||
| 66 | 7 | ▶ | Pod::Elemental::Element::Pod5::Command->new({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | command => 'item', content => '*', | ||||||||||||||||||||||||||||
| 68 | }), | ||||||||||||||||||||||||||||
| 69 | $_, | ||||||||||||||||||||||||||||
| 70 | } @$authors ), | ||||||||||||||||||||||||||||
| 71 | Pod::Elemental::Element::Pod5::Command->new({ | ||||||||||||||||||||||||||||
| 72 | command => 'back', content => '', | ||||||||||||||||||||||||||||
| 73 | }), | ||||||||||||||||||||||||||||
| 74 | ] if $multiple_authors; | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 7 | push $document->children->@*, | |||||||||||||||||||||||||||
| 77 | Pod::Elemental::Element::Nested->new({ | ||||||||||||||||||||||||||||
| 78 | type => 'command', | ||||||||||||||||||||||||||||
| 79 | command => 'head1', | ||||||||||||||||||||||||||||
| 80 | content => $name, | ||||||||||||||||||||||||||||
| 81 | children => $authors, | ||||||||||||||||||||||||||||
| 82 | }); | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 5 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 86 | 5 | 1; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | __END__ | ||||||||||||||||||||||||||||