| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::PodWeaver 4.009; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: weave your Pod together from configuration and Dist::Zilla |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4586
|
use Moose; |
|
|
1
|
|
|
|
|
568656
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
1
|
|
|
1
|
|
9115
|
use Pod::Weaver 3.100710; # logging with proxies |
|
|
1
|
|
|
|
|
1715471
|
|
|
|
1
|
|
|
|
|
65
|
|
|
6
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileMunger', |
|
7
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
|
8
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles' ], |
|
9
|
|
|
|
|
|
|
}; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# BEGIN BOILERPLATE |
|
12
|
1
|
|
|
1
|
|
15
|
use v5.20.0; |
|
|
1
|
|
|
|
|
4
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
56
|
|
|
14
|
1
|
|
|
1
|
|
8
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
15
|
1
|
|
|
1
|
|
32
|
no feature 'switch'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
122
|
|
|
16
|
1
|
|
|
1
|
|
789
|
use experimental qw(postderef postderef_qq); # This experiment gets mainlined. |
|
|
1
|
|
|
|
|
3691
|
|
|
|
1
|
|
|
|
|
6
|
|
|
17
|
|
|
|
|
|
|
# END BOILERPLATE |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
114
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
#pod |
|
23
|
|
|
|
|
|
|
#pod [PodWeaver] is the bridge between L<Dist::Zilla> and L<Pod::Weaver>. It rips |
|
24
|
|
|
|
|
|
|
#pod apart your kinda-Pod and reconstructs it as boring old real Pod. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod =head1 CONFIGURATION |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod If the C<config_plugin> attribute is given, it will be treated like a |
|
29
|
|
|
|
|
|
|
#pod Pod::Weaver section heading. For example, C<@Default> could be given. It may |
|
30
|
|
|
|
|
|
|
#pod be given multiple times. |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod Otherwise, if a file matching C<./weaver.*> exists, Pod::Weaver will be told to |
|
33
|
|
|
|
|
|
|
#pod look for configuration in the current directory. |
|
34
|
|
|
|
|
|
|
#pod |
|
35
|
|
|
|
|
|
|
#pod Otherwise, it will use the default configuration. |
|
36
|
|
|
|
|
|
|
#pod |
|
37
|
|
|
|
|
|
|
#pod =attr finder |
|
38
|
|
|
|
|
|
|
#pod |
|
39
|
|
|
|
|
|
|
#pod [PodWeaver] is a L<Dist::Zilla::Role::FileFinderUser>. The L<FileFinder> given |
|
40
|
|
|
|
|
|
|
#pod for its C<finder> attribute is used to decide which files to munge. By |
|
41
|
|
|
|
|
|
|
#pod default, it will munge: |
|
42
|
|
|
|
|
|
|
#pod |
|
43
|
|
|
|
|
|
|
#pod =for :list |
|
44
|
|
|
|
|
|
|
#pod * C<:InstallModules> |
|
45
|
|
|
|
|
|
|
#pod * C<:ExecFiles> |
|
46
|
|
|
|
|
|
|
#pod |
|
47
|
|
|
|
|
|
|
#pod =method weaver |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod This method returns the Pod::Weaver object to be used. The current |
|
50
|
|
|
|
|
|
|
#pod implementation builds a new weaver on each invocation, because one or two core |
|
51
|
|
|
|
|
|
|
#pod Pod::Weaver plugins cannot be trusted to handle multiple documents per plugin |
|
52
|
|
|
|
|
|
|
#pod instance. In the future, when that is fixed, this may become an accessor of an |
|
53
|
|
|
|
|
|
|
#pod attribute with a builder. Until this is clearer, use caution when modifying |
|
54
|
|
|
|
|
|
|
#pod this method in subclasses. |
|
55
|
|
|
|
|
|
|
#pod |
|
56
|
|
|
|
|
|
|
#pod =cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub weaver { |
|
59
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $root = $self->zilla->root->stringify; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my @files = glob("$root/weaver.*"); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $arg = { |
|
66
|
|
|
|
|
|
|
root => $root, |
|
67
|
|
|
|
|
|
|
root_config => { logger => $self->logger }, |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ($self->has_config_plugins) { |
|
|
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $assembler = Pod::Weaver::Config::Assembler->new; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $root = $assembler->section_class->new({ name => '_' }); |
|
74
|
0
|
|
|
|
|
|
$assembler->sequence->add_section($root); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
for my $header ($self->config_plugins) { |
|
77
|
0
|
|
|
|
|
|
$assembler->change_section($header); |
|
78
|
0
|
|
|
|
|
|
$assembler->end_section; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
return Pod::Weaver->new_from_config_sequence($assembler->sequence, $arg); |
|
82
|
|
|
|
|
|
|
} elsif (@files) { |
|
83
|
0
|
|
|
|
|
|
return Pod::Weaver->new_from_config( |
|
84
|
|
|
|
|
|
|
{ root => $root }, |
|
85
|
|
|
|
|
|
|
{ root_config => { logger => $self->logger } }, |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} else { |
|
88
|
0
|
|
|
|
|
|
return Pod::Weaver->new_with_default_config($arg); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
0
|
|
sub mvp_aliases { return { config_plugin => 'config_plugins' } } |
|
94
|
|
|
|
|
|
|
sub mvp_multivalue_args { qw(config_plugins) } |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
has config_plugins => ( |
|
97
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
98
|
|
|
|
|
|
|
traits => [ 'Array' ], |
|
99
|
|
|
|
|
|
|
default => sub { [] }, |
|
100
|
|
|
|
|
|
|
handles => { |
|
101
|
|
|
|
|
|
|
config_plugins => 'elements', |
|
102
|
|
|
|
|
|
|
has_config_plugins => 'count', |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
around dump_config => sub |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
|
109
|
|
|
|
|
|
|
my $config = $self->$orig; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $our = { |
|
112
|
|
|
|
|
|
|
$self->has_config_plugins |
|
113
|
|
|
|
|
|
|
? ( config_plugins => [ $self->config_plugins ] ) |
|
114
|
|
|
|
|
|
|
: (), |
|
115
|
|
|
|
|
|
|
finder => $self->finder, |
|
116
|
|
|
|
|
|
|
}; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$our->{plugins} = []; |
|
119
|
|
|
|
|
|
|
for my $plugin ($self->weaver->plugins->@*) { |
|
120
|
|
|
|
|
|
|
push $our->{plugins}->@*, { |
|
121
|
|
|
|
|
|
|
class => $plugin->meta->name, |
|
122
|
|
|
|
|
|
|
name => $plugin->plugin_name, |
|
123
|
|
|
|
|
|
|
version => $plugin->VERSION, |
|
124
|
|
|
|
|
|
|
}; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$config->{'' . __PACKAGE__} = $our; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
return $config; |
|
130
|
|
|
|
|
|
|
}; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub munge_files { |
|
133
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
require PPI; |
|
136
|
0
|
|
|
|
|
|
require Pod::Weaver; |
|
137
|
0
|
|
|
|
|
|
require Pod::Weaver::Config::Assembler; |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->munge_file($_) for $self->found_files->@*; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub munge_file { |
|
143
|
0
|
|
|
0
|
0
|
|
my ($self, $file) = @_; |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
$self->log_debug([ 'weaving pod in %s', $file->name ]); |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$self->munge_pod($file); |
|
148
|
0
|
|
|
|
|
|
return; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub munge_perl_string { |
|
152
|
|
|
|
|
|
|
my ($self, $doc, $arg) = @_; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $weaver = $self->weaver; |
|
155
|
|
|
|
|
|
|
my $new_doc = $weaver->weave_document({ |
|
156
|
|
|
|
|
|
|
%$arg, |
|
157
|
|
|
|
|
|
|
pod_document => $doc->{pod}, |
|
158
|
|
|
|
|
|
|
ppi_document => $doc->{ppi}, |
|
159
|
|
|
|
|
|
|
}); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
return { |
|
162
|
|
|
|
|
|
|
pod => $new_doc, |
|
163
|
|
|
|
|
|
|
ppi => $doc->{ppi}, |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub munge_pod { |
|
168
|
0
|
|
|
0
|
0
|
|
my ($self, $file) = @_; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my @authors = $self->zilla->authors; |
|
171
|
0
|
0
|
0
|
|
|
|
@authors = $authors[0]->@* if @authors == 1 && ref $authors[0]; |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
my $new_content = $self->munge_perl_string( |
|
174
|
|
|
|
|
|
|
$file->content, |
|
175
|
|
|
|
|
|
|
{ |
|
176
|
|
|
|
|
|
|
zilla => scalar $self->zilla, |
|
177
|
|
|
|
|
|
|
filename => scalar $file->name, |
|
178
|
|
|
|
|
|
|
version => scalar $self->zilla->version, |
|
179
|
|
|
|
|
|
|
license => scalar $self->zilla->license, |
|
180
|
|
|
|
|
|
|
authors => \@authors, |
|
181
|
|
|
|
|
|
|
distmeta => scalar $self->zilla->distmeta, |
|
182
|
|
|
|
|
|
|
}, |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
|
|
|
|
|
$file->content($new_content); |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
return; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
with 'Pod::Elemental::PerlMunger' => { -version => 0.100000 }; |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
193
|
1
|
|
|
1
|
|
1201
|
no Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
194
|
|
|
|
|
|
|
1; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
__END__ |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=pod |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=encoding UTF-8 |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 NAME |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Dist::Zilla::Plugin::PodWeaver - weave your Pod together from configuration and Dist::Zilla |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 VERSION |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
version 4.009 |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
[PodWeaver] is the bridge between L<Dist::Zilla> and L<Pod::Weaver>. It rips |
|
213
|
|
|
|
|
|
|
apart your kinda-Pod and reconstructs it as boring old real Pod. |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 PERL VERSION SUPPORT |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This module has the same support period as perl itself: it supports the two |
|
218
|
|
|
|
|
|
|
most recent versions of perl. (That is, if the most recently released version |
|
219
|
|
|
|
|
|
|
is v5.40, then this module should work on both v5.40 and v5.38.) |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
|
222
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
|
223
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
|
224
|
|
|
|
|
|
|
the minimum required perl. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 finder |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
[PodWeaver] is a L<Dist::Zilla::Role::FileFinderUser>. The L<FileFinder> given |
|
231
|
|
|
|
|
|
|
for its C<finder> attribute is used to decide which files to munge. By |
|
232
|
|
|
|
|
|
|
default, it will munge: |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=over 4 |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
C<:InstallModules> |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item * |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
C<:ExecFiles> |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=back |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 METHODS |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 weaver |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This method returns the Pod::Weaver object to be used. The current |
|
251
|
|
|
|
|
|
|
implementation builds a new weaver on each invocation, because one or two core |
|
252
|
|
|
|
|
|
|
Pod::Weaver plugins cannot be trusted to handle multiple documents per plugin |
|
253
|
|
|
|
|
|
|
instance. In the future, when that is fixed, this may become an accessor of an |
|
254
|
|
|
|
|
|
|
attribute with a builder. Until this is clearer, use caution when modifying |
|
255
|
|
|
|
|
|
|
this method in subclasses. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
If the C<config_plugin> attribute is given, it will be treated like a |
|
260
|
|
|
|
|
|
|
Pod::Weaver section heading. For example, C<@Default> could be given. It may |
|
261
|
|
|
|
|
|
|
be given multiple times. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
Otherwise, if a file matching C<./weaver.*> exists, Pod::Weaver will be told to |
|
264
|
|
|
|
|
|
|
look for configuration in the current directory. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Otherwise, it will use the default configuration. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Ricardo SIGNES <rjbs@semiotic.systems> |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=for stopwords David Golden Florian Ragwitz Karen Etheridge Yasutaka ATARASHI Сергей Романов |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=over 4 |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=item * |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=item * |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item * |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item * |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Yasutaka ATARASHI <yakex@cpan.org> |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=item * |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Сергей Романов <sromanov-dev@yandex.ru> |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=back |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Ricardo SIGNES. |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
305
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=cut |