blib/lib/Pod/Weaver/Plugin/perlmv.pm

filter: Statementstmt 24.5% 15 / 61 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 3 / 6 Podpod 0.0% 0 / 1 totaltotal 20.6% 18 / 87 CC 10 SCAR 35.7
CC
10
Cov
19%
_process_module
61.2
weave_section
12.0
_md2pod
2.0
CRAP 35.4
↑ Summary
1 package Pod::Weaver::Plugin::perlmv;
2  
3 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4 1 our $DATE = '2020-08-04'; # DATE
5 1 our $DIST = 'Pod-Weaver-Plugin-perlmv'; # DIST
6 1 our $VERSION = '0.002'; # VERSION
7  
8 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 with 'Pod::Weaver::Role::AddTextToSection';
11 1 with 'Pod::Weaver::Role::Section';
12  
13 0 ▶sub _md2pod {
Subroutine _md2pod: not called CC=1 SCAR=6.9
14 0 require Markdown::To::POD;
15  
16 0 my ($self, $md) = @_;
17 0 my $pod = Markdown::To::POD::markdown_to_pod($md);
18 # make sure we add a couple of blank lines in the end
19 0 $pod =~ s/\s+\z//s;
20 0 $pod . "\n\n\n";
21 }
22  
23 0 ▶sub _process_module {
Subroutine _process_module: not called CC=8 SCAR=41.1
24 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 my ($self, $document, $input, $package) = @_;
27  
28 0 my $filename = $input->{filename};
29  
30 # XXX handle dynamically generated module (if there is such thing in the
31 # future)
32 0 local @INC = ("lib", @INC);
33  
34 {
35 0 my $package_pm = $package;
36 0 $package_pm =~ s!::!/!g;
37 0 $package_pm .= ".pm";
38 0 require $package_pm;
39 }
40  
41 0 my $scriptlet = ${"$package\::SCRIPTLET"};
42  
43 0 (my $scriptlet_name = $package) =~ s/\AApp::perlmv::scriptlet:://;
44 0 $scriptlet_name =~ s!::!/!g;
45 0 $scriptlet_name =~ s!_!-!g;
46  
47 0 ▶ if (defined $scriptlet->{description}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $scriptlet->{"description"}) 0 0 0
48 $self->add_text_to_section(
49 0 $document, $self->_md2pod($scriptlet->{description}), 'DESCRIPTION',
50 );
51 }
52  
53 0 ▶ if (defined $scriptlet->{args} && keys(%{ $scriptlet->{args} })) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $scriptlet->{"args"} and keys %{$$scriptlet{"args"};}) 0 0 0
Condition0%0/3
defined $scriptlet->{"args"} and keys %{$$scriptlet{"args"};}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $scriptlet->{"args"} and keys %{$$scriptlet{"args"};}
defined $scriptlet->{"args"} keys %{$$scriptlet{"args"};}
Truth table0%0/3
A and B
A= defined $scriptlet->{"args"}B= keys %{$$scriptlet{"args"};}
ABresult
0X0
100
111
54 0 my @pod;
55 0 push @pod, "Arguments can be passed using the C<-a> (C<--arg>) L<perlmv> option, e.g. C<< -a name=val >>.\n\n";
56 0 for my $argname (sort keys %{ $scriptlet->{args} }) {
57 0 my $argspec = $scriptlet->{args}{$argname};
58 0 push @pod, "=head2 $argname\n\n";
59 0 ▶ push @pod, "Required. " if $argspec->{req};
Branch: 1 branch
BranchTrueFalseTotal
if $argspec->{"req"} 0 0 0
60 0 ▶ if (defined $argspec->{summary}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argspec->{"summary"}) 0 0 0
61 0 require String::PodQuote;
62 0 push @pod, String::PodQuote::pod_quote($argspec->{summary}), ". ";
63 }
64 0 push @pod, "\n\n";
65 0 ▶ if (defined $argspec->{description}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argspec->{"description"}) 0 0 0
66 0 push @pod, $self->_md2pod($argspec->{description});
67 }
68 }
69 $self->add_text_to_section(
70 0 $document, join("", @pod), 'SCRIPTLET ARGUMENTS',
71 {after_section => 'DESCRIPTION'},
72 );
73 }
74  
75 # XXX don't add if current See Also already mentions it
76 0 my @pod = (
77 "L<perlmv> (from L<App::perlmv>)\n\n",
78 );
79 0 $self->add_text_to_section(
80 $document, join('', @pod), 'SEE ALSO',
81 {after_section => ['DESCRIPTION']
82 },
83 );
84  
85 0 $self->log(["Generated POD for '%s'", $filename]);
86 }
87  
88 0 ▶sub weave_section {
Subroutine weave_section: not called CC=3 SCAR=24.8
Pod undocumented
89 0 my ($self, $document, $input) = @_;
90  
91 0 my $filename = $input->{filename};
92  
93 0 ▶ return unless $filename =~ m!^lib/(.+)\.pm$!;
Branch: 1 branch
BranchTrueFalseTotal
unless $filename =~ m[^lib/(.+)\.pm$] 0 0 0
94 0 my $package = $1;
95 0 $package =~ s!/!::!g;
96 0 ▶ return unless $package =~ /\AApp::perlmv::scriptlet::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $package =~ /\AApp::perlmv::scriptlet::/ 0 0 0
97 0 $self->_process_module($document, $input, $package);
98 }
99  
100 1 1;
101 # ABSTRACT: Plugin to use when building App::perlmv and App::perlmv::scriptlet::* distribution
102  
103 __END__
↑ Summary