« blib/lib/Dist/Zilla/Plugin/Author/GETTY/InstallCheck.pm
↑ Summary
blib/lib/Pod/Weaver/Section/Author/GETTY/Support.pm »
| 1 | package Pod::Elemental::Transformer::Author::GETTY; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Transform custom POD commands to =head1 and =head2 | ||||||||||||||||||||||||||||
| 3 | 4 | our $VERSION = '0.328'; | |||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | with 'Pod::Elemental::Transformer'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | # Commands that transform to =head1 with specific content | ||||||||||||||||||||||||||||
| 11 | 4 | my %HEAD1_COMMANDS = ( | |||||||||||||||||||||||||||
| 12 | synopsis => 'SYNOPSIS', | ||||||||||||||||||||||||||||
| 13 | description => 'DESCRIPTION', | ||||||||||||||||||||||||||||
| 14 | seealso => 'SEE ALSO', | ||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Commands that transform to =head2 (keeping content as-is) | ||||||||||||||||||||||||||||
| 18 | 4 | my @HEAD2_COMMANDS = qw( | |||||||||||||||||||||||||||
| 19 | attr | ||||||||||||||||||||||||||||
| 20 | method | ||||||||||||||||||||||||||||
| 21 | func | ||||||||||||||||||||||||||||
| 22 | opt | ||||||||||||||||||||||||||||
| 23 | env | ||||||||||||||||||||||||||||
| 24 | hook | ||||||||||||||||||||||||||||
| 25 | example | ||||||||||||||||||||||||||||
| 26 | resource | ||||||||||||||||||||||||||||
| 27 | event | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 4 | my %IS_HEAD2_COMMAND = map { $_ => 1 } @HEAD2_COMMANDS; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 73 | ▶ | sub transform_node { | ||||||||||||||||||||||||||
|
Subroutine
transform_node: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 73 | my ($self, $node) = @_; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 73 | for my $child (@{ $node->children }) { | |||||||||||||||||||||||||||
| 36 | 40 | ▶ | if ($child->isa('Pod::Elemental::Element::Pod5::Command')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 20 | my $cmd = $child->command; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Transform head1 commands (replace content with fixed heading) | ||||||||||||||||||||||||||||
| 40 | 20 | ▶ | if (my $heading = $HEAD1_COMMANDS{$cmd}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 41 | 1 | $child->{command} = 'head1'; | |||||||||||||||||||||||||||
| 42 | 1 | $child->{content} = $heading; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | # Transform head2 commands (keep content) | ||||||||||||||||||||||||||||
| 45 | elsif ($IS_HEAD2_COMMAND{$cmd}) { | ||||||||||||||||||||||||||||
| 46 | 9 | $child->{command} = 'head2'; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # Recurse into nested structures | ||||||||||||||||||||||||||||
| 51 | 40 | ▶ | if ($child->can('children') && $child->children) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$child->can("children") and $child->children
MC/DC0%0/2
$child->can("children") and $child->children
$child->can("children")
$child->children
Truth table33%1/3
A and B
A= $child->can("children")B= $child->children
| |||||||||||||||||||||||||||||
| 52 | 0 | $self->transform_node($child); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 73 | return $node; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 4 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||