| 1 | package Pod::Weaver::Plugin::Rinci; | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | with 'Pod::Weaver::Role::AddTextToSection'; | |||||||||||||||||||||||||||||||||||||||||||
| 6 | #with 'Pod::Weaver::Role::ReplaceCommand'; # not ready | ||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | with 'Pod::Weaver::Role::Section'; | |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Perinci::Access::Perl; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Perinci::To::POD; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Sub::Identify qw(sub_fullname); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our $DATE = '2023-04-14'; # DATE | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our $DIST = 'Pod-Weaver-Plugin-Rinci'; # DIST | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '0.786'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our $pa = Perinci::Access::Perl->new; | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | # regex | ||||||||||||||||||||||||||||||||||||||||||||
| 21 | has exclude_modules => ( | ||||||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||
| 23 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | '\\A(Sah::SchemaR::.+|Pod::Weaver::Plugin::Rinci)\\z'; | |||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | has exclude_files => ( | |||||||||||||||||||||||||||||||||||||||||||
| 29 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||
| 30 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | # whether to use Require::Hook::Source::DzilBuild | ||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | has use_require_hook_source_dzilbuild => ( | |||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||
| 36 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | # whether to force reloadding modules | ||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | has force_reload => ( | |||||||||||||||||||||||||||||||||||||||||||
| 41 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||
| 42 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub _process_module { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_module: not called CC=40 SCAR=73.5
| |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my ($self, $document, $input) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $filename = $input->{filename}; | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($file) = grep { $_->name eq $filename } @{ $input->{zilla}->files }; | |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | # guess package from filename | ||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $filename =~ m!^lib/(.+)\.pm$!; | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $package = $1; | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $package =~ s!/!::!g; | |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | my $use_require_hook_source_dzilbuild = | ||||||||||||||||||||||||||||||||||||||||||||
| 57 | $self->use_require_hook_source_dzilbuild // | ||||||||||||||||||||||||||||||||||||||||||||
| 58 | $ENV{PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD} // | ||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
($self->use_require_hook_source_dzilbuild // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD"}) // 1
$self->use_require_hook_source_dzilbuild // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD"}
MC/DC0%0/2
($self->use_require_hook_source_dzilbuild // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD"}) // 1
$self->use_require_hook_source_dzilbuild
$ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD"}
Truth table0%0/3
A // B
A= $self->use_require_hook_source_dzilbuildB= $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_USE_REQUIRE_HOOK_SOURCE_DZILBUILD"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 60 | my $force_reload = | ||||||||||||||||||||||||||||||||||||||||||||
| 61 | $self->force_reload // | ||||||||||||||||||||||||||||||||||||||||||||
| 62 | $ENV{PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD} // | ||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $package =~ /^(Dist::Zilla|Pod::Weaver)::/ ? 0:1; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
($self->force_reload // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD"}) // $package =~ /^(Dist::Zilla|Pod::Weaver)::/
$self->force_reload // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD"}
MC/DC0%0/3
($self->force_reload // $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD"}) // $package =~ /^(Dist::Zilla|Pod::Weaver)::/
$self->force_reload
$ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD"}
$package =~ /^(Dist::Zilla|Pod::Weaver)::/
Truth table0%0/4
A // B // C
A= $self->force_reloadB= $ENV{"PERL_POD_WEAVER_PLUGIN_RINCI_FORCE_RELOAD"}C= $package =~ /^(Dist::Zilla|Pod::Weaver)::/
| |||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | require Require::Hook::Source::DzilBuild if $use_require_hook_source_dzilbuild; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | # always add 'lib' because this is what we normally always want | ||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | local @INC = ("lib", @INC); | |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | # force reload to get the recent version of module | ||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | (my $package_pm = "$package.pm") =~ s!::!/!g; | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | delete $INC{$package_pm} if $force_reload; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($url, $res); | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | for my $attempt (1..2) { | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # first attempt is with Require::Hook::Source::DzilBuild, second attempt | ||||||||||||||||||||||||||||||||||||||||||||
| 77 | # without | ||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | next if $attempt == 1 && !$use_require_hook_source_dzilbuild; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attempt == 1 and not $use_require_hook_source_dzilbuild
MC/DC0%0/2
$attempt == 1 and not $use_require_hook_source_dzilbuild
$attempt == 1
not $use_require_hook_source_dzilbuild
Truth table0%0/3
A and not(B)
A= $attempt == 1B= not $use_require_hook_source_dzilbuild
| |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->log_debug("Attempt loading $package ".($attempt == 1 ? "with Require::Hook::Source::DzilBuild" : "with normal \@INC")); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | local @INC = (Require::Hook::Source::DzilBuild->new(zilla => $input->{zilla}, debug=>1), @INC) if $attempt == 1; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $url = $package; $url =~ s!::!/!g; $url = "pl:/$url/"; | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | eval { $res = $pa->request(meta => $url) }; | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $self->log_debug("Loading failed: $@") if $@; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | last if !$@ && $res->[0] == 200; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $@ and $res->[0] == 200
MC/DC0%0/2
not $@ and $res->[0] == 200
not $@
$res->[0] == 200
Truth table0%0/3
not(A) and B
A= not $@B= $res->[0] == 200
| |||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | die "Failed loading $package after attempt(s)" unless $res->[0] == 200; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $meta = $res->[2]; | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $res = $pa->request(child_metas => $url); | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | die "Can't child_metas $url: $res->[0] - $res->[1]" unless $res->[0] == 200; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $cmetas = $res->[2]; | |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $exports = {}; | |||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | # we import specifically when module is using Exporter::Rinci as its | ||||||||||||||||||||||||||||||||||||||||||||
| 100 | # exporter, because Exporter::Rinci works by filling @EXPORT* variables | ||||||||||||||||||||||||||||||||||||||||||||
| 101 | # during import(). | ||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if (sub_fullname($package->can("import")) =~ /^Exporter::Rinci::/) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $package->import; | |||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my $uses_exporter_mod = @{"$package\::EXPORT"} || @{"$package\::EXPORT_OK"}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
@{"${package}::EXPORT";} || @{"${package}::EXPORT_OK";}
MC/DC0%0/2
@{"${package}::EXPORT";} || @{"${package}::EXPORT_OK";}
@{"${package}::EXPORT";}
@{"${package}::EXPORT_OK";}
Truth table0%0/3
A || B
A= @{"${package}::EXPORT";}B= @{"${package}::EXPORT_OK";}
| |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | for my $funcname (keys %$cmetas) { | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | next unless $funcname =~ /\A\w+\z/; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $funcmeta = $cmetas->{$funcname}; | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | my $export = -1; | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($uses_exporter_mod && | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$uses_exporter_mod and grep {$_ eq $funcname;} @{"${package}::EXPORT";}
MC/DC0%0/2
$uses_exporter_mod and grep {$_ eq $funcname;} @{"${package}::EXPORT";}
$uses_exporter_mod
grep {$_ eq $funcname;} @{"${package}::EXPORT";}
Truth table0%0/3
A and B
A= $uses_exporter_modB= grep {$_ eq $funcname;} @{"${package}::EXPORT";}
| |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | grep {$_ eq $funcname} @{"$package\::EXPORT"}) { | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $export = 1; | |||||||||||||||||||||||||||||||||||||||||||
| 114 | ▶ | } elsif ($uses_exporter_mod && | |||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$uses_exporter_mod and grep {$_ eq $funcname;} @{"${package}::EXPORT_OK";}
MC/DC0%0/2
$uses_exporter_mod and grep {$_ eq $funcname;} @{"${package}::EXPORT_OK";}
$uses_exporter_mod
grep {$_ eq $funcname;} @{"${package}::EXPORT_OK";}
Truth table0%0/3
A and B
A= $uses_exporter_modB= grep {$_ eq $funcname;} @{"${package}::EXPORT_OK";}
| |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | grep {$_ eq $funcname} @{"$package\::EXPORT_OK"}) { | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $export = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 117 | } elsif ($uses_exporter_mod) { | ||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $export = -1; | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | } elsif (grep {$_ eq 'export:default'} @{ $funcmeta->{tags} // [] }) { | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$funcmeta->{"tags"} // []
MC/DC0%0/1
$funcmeta->{"tags"} // []
$funcmeta->{"tags"}
Truth table0%0/2
A
A= $funcmeta->{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $export = 1; | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | } elsif (grep {$_ eq 'export:never'} @{ $funcmeta->{tags} // [] }) { | ||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$funcmeta->{"tags"} // []
MC/DC0%0/1
$funcmeta->{"tags"} // []
$funcmeta->{"tags"}
Truth table0%0/2
A
A= $funcmeta->{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $export = -1; | |||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $exports->{$funcname} = $export; | |||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $doc = Perinci::To::POD->new( | |||||||||||||||||||||||||||||||||||||||||||
| 128 | name=>$package, meta=>$meta, child_metas=>$cmetas, url=>$url, | ||||||||||||||||||||||||||||||||||||||||||||
| 129 | exports=>$exports); | ||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $doc->delete_doc_section('summary'); # already handled by other plugins | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $doc->delete_doc_section('version'); # ditto | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $pod_text = $doc->gen_doc; | |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | while ($pod_text =~ /^=head1 ([^\n]+)\n(.+?)(?=^=head1|\z)/msg) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ($sectname, $sectcontent) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | # skip inserting section if there is no text | ||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | next unless $sectcontent =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | # skip inserting FUNCTIONS if there are no functions | ||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | next if $sectname eq 'FUNCTIONS' && $sectcontent !~ /^=head2/m; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sectname eq "FUNCTIONS" and not $sectcontent =~ /^=head2/m
MC/DC0%0/2
$sectname eq "FUNCTIONS" and not $sectcontent =~ /^=head2/m
$sectname eq "FUNCTIONS"
not $sectcontent =~ /^=head2/m
Truth table0%0/3
A and not(B)
A= $sectname eq "FUNCTIONS"B= not $sectcontent =~ /^=head2/m
| |||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | # skip inserting METHODS if there are no functions | ||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | next if $sectname eq 'METHODS' && $sectcontent !~ /^=head2/m; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sectname eq "METHODS" and not $sectcontent =~ /^=head2/m
MC/DC0%0/2
$sectname eq "METHODS" and not $sectcontent =~ /^=head2/m
$sectname eq "METHODS"
not $sectcontent =~ /^=head2/m
Truth table0%0/3
A and not(B)
A= $sectname eq "METHODS"B= not $sectcontent =~ /^=head2/m
| |||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $found++; | |||||||||||||||||||||||||||||||||||||||||||
| 148 | #$self->log(["generated POD section %s", $1]); | ||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my %opts; | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # position | ||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ($sectname eq 'FUNCTIONS' || $sectname eq 'METHODS') { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sectname eq "FUNCTIONS" or $sectname eq "METHODS"
MC/DC0%0/2
$sectname eq "FUNCTIONS" or $sectname eq "METHODS"
$sectname eq "FUNCTIONS"
$sectname eq "METHODS"
Truth table0%0/3
A or B
A= $sectname eq "FUNCTIONS"B= $sectname eq "METHODS"
| |||||||||||||||||||||||||||||||||||||||||||||
| 153 | $opts{after_section} = [ | ||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | 'DESCRIPTION', | |||||||||||||||||||||||||||||||||||||||||||
| 155 | ]; | ||||||||||||||||||||||||||||||||||||||||||||
| 156 | # make sure we don't put it too below | ||||||||||||||||||||||||||||||||||||||||||||
| 157 | $opts{before_section} = [ | ||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | 'SEE ALSO', | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 'HOMEPAGE', | ||||||||||||||||||||||||||||||||||||||||||||
| 160 | ]; | ||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $self->add_text_to_section($document, $sectcontent, $sectname, \%opts); | |||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($found) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->log(["added POD sections from Rinci metadata for file (module) '%s'", $filename]); | |||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | sub _process_script { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_script: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | require File::Temp; | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | require Perinci::CmdLine::POD; | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | require Perinci::CmdLine::Util; | |||||||||||||||||||||||||||||||||||||||||||
| 174 | #require Require::Hook::Source::DzilBuild; # script is dumped in a different process, so doesn't work here | ||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my ($self, $document, $input) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # dump to temporary file first because the file might not be an ondisk file | ||||||||||||||||||||||||||||||||||||||||||||
| 178 | # and/or already munged. | ||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my $filename; | |||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | require File::Temp; | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my ($fh, $tempname) = File::Temp::tempfile(); | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($file) = grep { $_->name eq $input->{filename} } | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | @{ $input->{zilla}->files }; | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | print $fh $file->encoded_content; | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $filename = $tempname; | |||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | (my $command_name = $input->{filename}) =~ s!.+/!!; | |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | my $det_res = Perinci::CmdLine::Util::detect_pericmd_script( | |||||||||||||||||||||||||||||||||||||||||||
| 193 | filename => $filename, | ||||||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($det_res->[0] == 412) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->log_debug(["skipped file '%s' (%s)", $filename, $det_res->[1]]); | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||
| 198 | } elsif (!$det_res->[2]) { | ||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->log_debug(["skipped file '%s' (not detected as Perinci::CmdLine script)", $filename]); | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | # so scripts can know that they are being dumped in the context of | ||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Dist::Zilla | ||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | local $ENV{DZIL} = 1; | |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $completer_name = $command_name; | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ($det_res->[3]{'func.is_inline'}) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | (my $comp_filename = $input->{filename}) =~ s!(.+)/(.+)!$1/_$2!; | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my $has_completer = grep { $_->name eq $comp_filename } | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | @{ $input->{zilla}->files }; | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ($has_completer) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $completer_name = "_$command_name"; | |||||||||||||||||||||||||||||||||||||||||||
| 214 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $completer_name = undef; | |||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $res = Perinci::CmdLine::POD::gen_pod_for_pericmd_script( | |||||||||||||||||||||||||||||||||||||||||||
| 219 | script => $filename, | ||||||||||||||||||||||||||||||||||||||||||||
| 220 | program_name => $command_name, | ||||||||||||||||||||||||||||||||||||||||||||
| 221 | libs => ["lib"], | ||||||||||||||||||||||||||||||||||||||||||||
| 222 | (completer_script => $completer_name) x !!defined($completer_name), | ||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | die "Can't generate POD for script: $res->[0] - $res->[1]" | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 225 | unless $res->[0] == 200; | ||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $modified; | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | for my $s (@{ $res->[3]{'func.sections'} }) { | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | next unless $s->{content}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 230 | $modified++ if $self->add_text_to_section( | ||||||||||||||||||||||||||||||||||||||||||||
| 231 | $document, $s->{content}, $s->{name}, | ||||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 233 | (ignore => $s->{ignore}) x !!$s->{ignore}, | ||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | }); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | # not ready | ||||||||||||||||||||||||||||||||||||||||||||
| 238 | #if ($res->[3]{'func.usage'}) { | ||||||||||||||||||||||||||||||||||||||||||||
| 239 | # $modified++ if $self->replace_command($document, 'head2', qr/usage/, $res->[3]{'func.usage'}, {ignore=>1}); | ||||||||||||||||||||||||||||||||||||||||||||
| 240 | #} | ||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ($modified) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->log(["added POD sections from Rinci metadata for script '%s'", $input->{filename}]); | |||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | sub weave_section { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
weave_section: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my ($self, $document, $input) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $filename = $input->{filename}; | |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | { | ||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $re; | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (defined $self->exclude_files) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $re = $self->exclude_files; | |||||||||||||||||||||||||||||||||||||||||||
| 256 | } elsif ($ENV{PERL_POD_WEAVER_PLUGIN_RINCI_EXCLUDE_FILES}) { | ||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | $re = $ENV{PERL_POD_WEAVER_PLUGIN_RINCI_EXCLUDE_FILES}; | |||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($re) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | eval { $re = qr/$re/ }; | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $@ and die "Invalid regex in exclude_files: $re"; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ($filename =~ $re) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->log_debug(["skipped file '%s' (matched exclude_files)", $filename]); | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my $package; | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($filename =~ m!^lib/(.+)\.pm$!) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $package = $1; | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $package =~ s!/!::!g; | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $re; | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if (defined $self->exclude_modules) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $re = $self->exclude_modules; | |||||||||||||||||||||||||||||||||||||||||||
| 276 | } elsif ($ENV{PERL_POD_WEAVER_PLUGIN_RINCI_EXCLUDE_MODULES}) { | ||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $re = $ENV{PERL_POD_WEAVER_PLUGIN_RINCI_EXCLUDE_MODULES}; | |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | if ($re) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | eval { $re = qr/$re/ }; | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $@ and die "Invalid regex in exclude_modules: $re"; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if ($package =~ $re) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->log (["skipped package %s (matched exclude_modules)", $package]); | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $self->_process_module($document, $input); | |||||||||||||||||||||||||||||||||||||||||||
| 288 | } elsif ($filename =~ m!^(?:bin|scripts?)/!) { | ||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->_process_script($document, $input); | |||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 294 | # ABSTRACT: Insert stuffs to POD from Rinci metadata | ||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||