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