line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PodInherit; |
2
|
|
|
|
|
|
|
# ABSTRACT: autogenerate inherited POD sections for Dist::Zilla distributions |
3
|
1
|
|
|
1
|
|
3334996
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
7818
|
use Pod::Inherit; |
|
1
|
|
|
|
|
40326
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
527
|
use Module::Load; |
|
1
|
|
|
|
|
1189
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
516
|
use Dist::Zilla::File::InMemory; |
|
1
|
|
|
|
|
94480
|
|
|
1
|
|
|
|
|
502
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.009'; |
13
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodInherit - use L<Pod::Inherit> to provide C<INHERITED METHODS> sections in POD |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Just add [PodInherit] to dist.ini. Currently there's no config options at all. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Simple wrapper around L<Pod::Inherit> to provide an 'inherited methods' section for |
26
|
|
|
|
|
|
|
any modules in this distribution. See the documentation for L<Pod::Inherit> for more |
27
|
|
|
|
|
|
|
details. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileGatherer'; |
32
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileInjector'; |
33
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileFinderUser' => { |
34
|
|
|
|
|
|
|
default_finders => [ qw( :InstallModules ) ], |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has generated => is => 'rw', default => 0; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 METHODS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 gather_files |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Called for each matching file (using :InstallModules so we expect |
46
|
|
|
|
|
|
|
to find all the .pm files), we'll attempt to do pod generation for |
47
|
|
|
|
|
|
|
the ones which end in .pm (case insensitive, will also match .PM). |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub gather_files { |
52
|
1
|
|
|
1
|
1
|
71893
|
my ($self) = @_; |
53
|
1
|
|
|
|
|
2
|
foreach my $file (@{ $self->found_files }) { |
|
1
|
|
|
|
|
7
|
|
54
|
2
|
50
|
|
|
|
2169
|
$self->process_pod($file) if $file->name =~ /\.pm$/i; |
55
|
|
|
|
|
|
|
} |
56
|
1
|
|
|
|
|
34
|
$self->log("Generated " . $self->generated . " POD files"); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 process_pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Calls L<Pod::Inherit> to generate the merged C<.pod> documentation files. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub process_pod { |
66
|
2
|
|
|
2
|
1
|
115
|
my ($self, $file) = @_; |
67
|
2
|
50
|
|
|
|
7
|
unless(-r $file->name) { |
68
|
0
|
|
|
|
|
0
|
$self->log_debug("Skipping " . $file->name . " because we can't read it, probably InMemory/FromCode"); |
69
|
0
|
|
|
|
|
0
|
return; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
139
|
$self->log_debug("Processing " . $file->name . " for inherited methods"); |
73
|
2
|
|
|
|
|
241
|
local @INC = ('lib/', @INC); |
74
|
2
|
|
|
|
|
8
|
my $name = $file->name; |
75
|
2
|
|
|
|
|
111
|
my $cfg = Pod::Inherit->new({ |
76
|
|
|
|
|
|
|
input_files => [$name], |
77
|
|
|
|
|
|
|
skip_underscored => 1, |
78
|
|
|
|
|
|
|
method_format => 'L<%m|%c/%m>', |
79
|
|
|
|
|
|
|
debug => 0, |
80
|
|
|
|
|
|
|
}); |
81
|
2
|
|
|
|
|
108
|
Module::Load::load($cfg->_file_to_package($name)); |
82
|
2
|
100
|
|
|
|
32
|
my $content = $cfg->create_pod($name) or return; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# The encoding line does not make it through to the target file, so we |
85
|
|
|
|
|
|
|
# hardcode a value here. Ideally it'd match the original source... but |
86
|
|
|
|
|
|
|
# even more ideally, everything uses UTF-8 everywhere. |
87
|
1
|
50
|
|
|
|
7002
|
$content = "=encoding utf8\n\n$content" unless $content =~ /^=encoding/; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
6
|
(my $output = $file->name) =~ s{\.pm$}{.pod}i; |
90
|
1
|
|
|
|
|
99
|
$self->add_file( |
91
|
|
|
|
|
|
|
my $new = Dist::Zilla::File::InMemory->new({ |
92
|
|
|
|
|
|
|
name => $output, |
93
|
|
|
|
|
|
|
content => $content, |
94
|
|
|
|
|
|
|
}) |
95
|
|
|
|
|
|
|
); |
96
|
1
|
|
|
|
|
788
|
$self->log_debug("Generated POD for " . $file->name . " in " . $new->name); |
97
|
1
|
|
|
|
|
179
|
$self->generated($self->generated + 1); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
101
|
1
|
|
|
1
|
|
11
|
no Moose; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
8
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 BUGS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Some of the path and extension handling may be non-portable, should probably |
110
|
|
|
|
|
|
|
use L<File::Basename> and L<File::Spec>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Also, generating an entire .pod output file which is identical apart from the |
113
|
|
|
|
|
|
|
extra inherited methods section seems suboptimal, other plugins such as |
114
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::PodVersion> manage to update the source .pm file |
115
|
|
|
|
|
|
|
directly so perhaps that would be a better approach. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SEE ALSO |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * L<Pod::POM> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * L<Pod::Inherit> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Tom Molesworth <TEAM@cpan.org> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Copyright Tom Molesworth 2012-2020. Licensed under the same terms as Perl itself. |
134
|
|
|
|
|
|
|
|