| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package Pod::Weaver::Section::Legal::Supplemented; | ||
| 5 | |||
| 6 | our $VERSION = '0.0100'; # VERSION | ||
| 7 | # ABSTRACT: Add text to the Legal section | ||
| 8 | |||
| 9 | use Moose; | ||
| 10 | extends 'Pod::Weaver::Section::Legal'; | ||
| 11 | with 'Pod::Weaver::Role::AddTextToSection'; | ||
| 12 | use Types::Standard qw/ArrayRef Str/; | ||
| 13 | |||
| 14 | sub mvp_multivalue_args { qw/text_before text_after/ } | ||
| 15 | |||
| 16 | for my $where (qw/text_before text_after/) { | ||
| 17 | has $where => ( | ||
| 18 | is => 'rw', | ||
| 19 | isa => ArrayRef->plus_coercions(Str, sub { [$_] }), | ||
| 20 | coerce => 1, | ||
| 21 | traits => ['Array'], | ||
| 22 | predicate => "has_$where", | ||
| 23 | default => sub { [] }, | ||
| 24 | handles => { | ||
| 25 | "all_$where" => 'elements', | ||
| 26 | "join_$where" => 'join', | ||
| 27 | }, | ||
| 28 | ); | ||
| 29 | } | ||
| 30 | |||
| 31 | around weave_section => sub { | ||
| 32 | my $next = shift; | ||
| 33 | my $self = shift; | ||
| 34 | my $document = shift; | ||
| 35 | my $input = shift; | ||
| 36 | |||
| 37 | $self->$next($document, $input); | ||
| 38 | my $place = $document->children->[-1]; | ||
| 39 | |||
| 40 | if($self->has_text_before) { | ||
| 41 | $self->add_text_to_section($document, $self->join_text_before("\n"), $self->header, { top => 1 }); | ||
| 42 | } | ||
| 43 | if($self->has_text_after) { | ||
| 44 | $self->add_text_to_section($document, $self->join_text_after("\n") . "\n\n", $self->header); | ||
| 45 | } | ||
| 46 | }; | ||
| 47 | |||
| 48 | |||
| 49 | 1; | ||
| 50 | |||
| 51 | __END__ |