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
|
|
3199702
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
7372
|
use Pod::Inherit; |
|
1
|
|
|
|
|
38329
|
|
|
1
|
|
|
|
|
59
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodInherit - use L<Pod::Inherit> to provide C<INHERITED METHODS> sections in POD |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
version 0.007 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Just add [PodInherit] to dist.ini. Currently there's no config options at all. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Simple wrapper around L<Pod::Inherit> to provide an 'inherited methods' section for |
25
|
|
|
|
|
|
|
any modules in this distribution. See the documentation for L<Pod::Inherit> for more |
26
|
|
|
|
|
|
|
details. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
473
|
use Dist::Zilla::File::InMemory; |
|
1
|
|
|
|
|
91711
|
|
|
1
|
|
|
|
|
380
|
|
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
|
69158
|
my ($self) = @_; |
53
|
1
|
|
|
|
|
3
|
foreach my $file (@{ $self->found_files }) { |
|
1
|
|
|
|
|
5
|
|
54
|
2
|
50
|
|
|
|
869
|
$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
|
113
|
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
|
|
|
|
|
137
|
$self->log_debug("Processing " . $file->name . " for inherited methods"); |
73
|
2
|
|
|
|
|
236
|
local @INC = ('lib/', @INC); |
74
|
2
|
|
|
|
|
6
|
my $cfg = Pod::Inherit->new({ |
75
|
|
|
|
|
|
|
input_files => [$file->name], |
76
|
|
|
|
|
|
|
skip_underscored => 1, |
77
|
|
|
|
|
|
|
method_format => 'L<%m|%c/%m>', |
78
|
|
|
|
|
|
|
debug => 0, |
79
|
|
|
|
|
|
|
}); |
80
|
2
|
100
|
|
|
|
201
|
my $content = $cfg->create_pod($file->name) or return; |
81
|
1
|
|
|
|
|
5944
|
(my $output = $file->name) =~ s{\.pm$}{.pod}i; |
82
|
1
|
|
|
|
|
96
|
$self->add_file( |
83
|
|
|
|
|
|
|
my $new = Dist::Zilla::File::InMemory->new({ |
84
|
|
|
|
|
|
|
name => $output, |
85
|
|
|
|
|
|
|
content => $content, |
86
|
|
|
|
|
|
|
}) |
87
|
|
|
|
|
|
|
); |
88
|
1
|
|
|
|
|
744
|
$self->log_debug("Generated POD for " . $file->name . " in " . $new->name); |
89
|
1
|
|
|
|
|
174
|
$self->generated($self->generated + 1); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
93
|
1
|
|
|
1
|
|
10
|
no Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 BUGS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Some of the path and extension handling may be non-portable, should probably |
102
|
|
|
|
|
|
|
use L<File::Basename> and L<File::Spec>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Also, generating an entire .pod output file which is identical apart from the |
105
|
|
|
|
|
|
|
extra inherited methods section seems suboptimal, other plugins such as |
106
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::PodVersion> manage to update the source .pm file |
107
|
|
|
|
|
|
|
directly so perhaps that would be a better approach. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SEE ALSO |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * L<Pod::POM> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * L<Pod::Inherit> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Tom Molesworth <cpan@entitymodel.com> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright Tom Molesworth 2012-2013. Licensed under the same terms as Perl itself. |