File Coverage

blib/lib/Pod/Weaver/PluginBundle/Author/TABULO.pm
Criterion Covered Total %
statement 51 51 100.0
branch 26 26 100.0
condition 11 14 78.5
subroutine 12 12 100.0
pod 0 4 0.0
total 100 107 93.4


line stmt bran cond sub pod time code
1 21     21   203566 use strict;
  21         75  
  21         915  
2 21     21   155 use warnings;
  21         74  
  21         1744  
3             package Pod::Weaver::PluginBundle::Author::TABULO;
4             # vim: set ts=2 sts=2 sw=2 tw=115 et :
5             # ABSTRACT: A plugin bundle for pod woven for TABULO
6             # BASED_ON: Pod::Weaver::PluginBundle::Author::ETHER
7              
8             our $VERSION = '0.198';
9             # AUTHORITY
10              
11 21     21   1176 use namespace::autoclean -also => ['_exp'];
  21         34071  
  21         262  
12 21     21   11677 use Pod::Weaver::Config::Assembler;
  21         9458295  
  21         978  
13 21     21   249 use Module::Runtime 'use_module';
  21         55  
  21         163  
14 21     21   10347 use PadWalker 'peek_sub';
  21         12859  
  21         19485  
15              
16             sub _exp { Pod::Weaver::Config::Assembler->expand_package($_[0]) }
17              
18             # This sub behaves somewhat like a Dist::Zilla pluginbundle's configure() -- it returns a list of strings or 1, 2
19             # or 3-element arrayrefs containing plugin specifications. The goal is to make this look as close to what
20             # weaver.ini looks like as possible.
21              
22             # Some other possibilities (found on CPAN) include :
23             #
24             # Pod::Weaver::Section::*
25             # * AllowOverride - Allow POD to override a Pod::Weaver-provided
26             # * Collect::FromOther - Import sections from other POD
27             # * CommentString - Add Pod::Weaver section with content extracted from comment with specified key
28             # * Bugs::DefaultRT - Add a BUGS section to refer to bugtracker (or RT as default)
29             # * GenerateSection - add pod section from an interpolated piece of text
30             # * ReplaceName - Add or replace a NAME section with abstract.
31             # * SeeAlso - add a SEE ALSO pod section. Also supports #SEEALSO comments (preferrable).
32             # WARNING: The 'SEE ALSO' section in your POD, if present,
33             # should just be a list of links (one per line), without any POD commands.
34             # * Template - add pod section from a Text::Template template
35             # * WarrantyDisclaimer - Add a standard DISCLAIMER OF WARRANTY section (for your Perl module)
36             #
37             # * Extends - Add a list of parent classes to your POD.
38             # * Consumes - Add a list of roles to your POD. WARNING: This one has some CAVEATS (refer to CPAN).
39             # * Requires - Add Pod::Weaver section with all used modules from package excluding listed ones, e.g. :
40             # [Requires]
41             # ignore = base lib constant namespace::sweep
42             #
43             # Pod::Weaver::Plugin::*
44             # .* AppendPrepend - Merge append:FOO and prepend:FOO sections in POD
45             # .* Include - Support for including sections of Pod from other files
46             # .* EnsureUniqueSections - Ensure that POD has no duplicate section headers.
47             # NOTE: Setting strict=1 will disable smart detection of duplicates (plural forms, collapsed space, ...)
48             # * Exec - include output of commands in your pod
49             # * Run - Write Pod::Weaver::Plugin directly in 'weaver.ini'
50             # WARNING: Seems to be a bit exoteric.
51             # * SortSections - Sort POD sections
52             # .* StopWords - Dynamically add stopwords to your woven pod
53             # .* WikiDoc - allow wikidoc-format regions to be translated during dialect phase
54              
55             sub configure
56             {
57 57     57 0 175 my $self = shift;
58              
59             # ETHER says: I wouldn't have to do this ugliness if I could have some configuration values passed in from weaver.ini or
60             # the [PodWeaver] plugin's use of config_plugin (where I could define a 'licence' option)
61 57         140 my $podweaver_plugin = ${ peek_sub(\&Dist::Zilla::Plugin::PodWeaver::weaver)->{'$self'} };
  57         1224  
62 57   100     2282 my $lic_plugin = $podweaver_plugin && $podweaver_plugin->zilla->plugin_named('@Author::TABULO/License');
63 57 100       20746 my $lic_filename = $lic_plugin ? $lic_plugin->filename : 'LICENSE'; # TAU: Changed default from 'LICENCE'
64              
65             return (
66             # equivalent to [@CorePrep]. These are REQUIRED for anything to work.
67 57         1398 [ '-EnsurePod5' ],
68             [ '-H1Nester' ],
69              
70             '-AppendPrepend', # + by TAU. Merge append:FOO and prepend:FOO sections in POD
71             '-EnsureUniqueSections', # + by TAU. Ensure that POD has no duplicate section headers.
72             [ '-Include' => { pod_path => 'lib:bin:script:scripts:docs/pod', insert_errors => 0 } ], # + by TAU
73             '-SingleEncoding', # Encoding defaults to UTF-8.
74             # In addition to the below, other stopWords may be added in several places, such as the [%PodWeaver] stash in 'dist.ini'
75             [ '-StopWords' => { gather=>1, include => [ stopwords() ] } ],
76             [ '-Transformer' => Verbatim => { transformer => 'Verbatim' } ],
77             [ '-Transformer' => WikiDoc => { transformer => 'WikiDoc' } ], # TAU : Added WikiDoc
78              
79              
80             [ 'Region' => 'header' ],
81             'Name',
82             'Version',
83             [ 'Region' => 'prelude' ],
84             [ 'Generic' => 'SYNOPSIS' ],
85             [ 'Generic' => 'DESCRIPTION' ],
86             [ 'Generic' => 'OVERVIEW' ],
87             [ 'Collect' => 'ATTRIBUTES' => { command => 'attr' } ],
88             # [ 'Collect' => 'ATTRIBUTES (PRIVATE)' => { command => 'pattr' } ],
89             [ 'Collect' => 'METHODS' => { command => 'method' } ],
90             # [ 'Collect' => 'METHODS (PRIVATE)' => { command => 'pmethod' } ],
91             [ 'Collect' => 'FUNCTIONS' => { command => 'func' } ],
92             # [ 'Collect' => 'FUNCTIONS (PRIVATE)' => { command => 'pfunc' } ],
93             [ 'Collect' => 'TYPES' => { command => 'type' } ],
94              
95             'Leftovers',
96             [ 'Region' => 'postlude' ],
97              
98             [ 'GenerateSection' => 'generate SUPPORT' => {
99             title => 'SUPPORT',
100             main_module_only => 0,
101             text => [ support_section_text() ],
102             },
103             ],
104              
105             [ 'AllowOverride' => 'allow override SUPPORT' => {
106             header_re => '^(SUPPORT|BUGS)\b',
107             action => 'prepend',
108             match_anywhere => 0,
109             },
110             ],
111              
112             'Authors',
113             [ 'Contributors' => { ':version' => '0.008' } ],
114             [ 'Legal' => { ':version' => '4.011', header => 'COPYRIGHT AND ' . $lic_filename } ],
115             'WarrantyDisclaimer', # + by TABULO
116             [ 'Region' => 'footer' ],
117             );
118             }
119              
120              
121             #--------------------------------------
122             sub stopwords {
123              
124             #pod =for COMMENT
125             #pod
126             #pod NOTE: See C<Pod::Wordlist> for a list of stopwords that are already taken into account
127             #pod automatically by L<[Test::PodSpelling]|Dist::Zilla::Plugin::Test::PodSpelling/stopwords>.
128             #pod
129             #pod =cut
130              
131             (
132              
133             # Frequently mentioned proper names
134 57     57 0 3304 qw ( bitbucket BitBucket CPAN irc GitHub metacpan ),
135              
136             # Frequently mentioned Perl module names (without the '::')
137             qw ( FakeRelease ModuleBuildTiny PodWeaver SurgicalPodWeaver UploadToCPAN),
138              
139             # Common idioms found in Perl docuentation
140             qw ( foo foobar bar baz ),
141              
142             # Frequently mentioned authors
143             qw ( DAGOLDEN ETHER TABULO KENTNL ),
144              
145             # Some made-up words or americanisms that TABULO likes to use anyway
146             qw ( customization customizations stopword stopwords repo submodule optimization optimizations),
147              
148             # Some words that are somehow not known to the spell-checker
149             qw (
150             MERCHANTABILITY
151             ),
152             )
153             }
154              
155             #--------------------------------------
156             sub support_section_text { # [TAU] : Note that this is actualy a template.
157             #--------------------------------------
158             return <<'SUPPORT',
159             {{ join("\n\n",
160             ($bugtracker_email && $bugtracker_email =~ /rt\.cpan\.org/)
161             ? "Bugs may be submitted through L<the RT bug tracker|$bugtracker_web>\n(or L<$bugtracker_email|mailto:$bugtracker_email>)."
162             : $bugtracker_web
163             ? "bugs may be submitted through L<$bugtracker_web>."
164             : (),
165              
166             $distmeta->{resources}{x_MailingList} ? 'There is also a mailing list available for users of this distribution, at' . "\nL<" . $distmeta->{resources}{x_MailingList} . '>.' : (),
167              
168             $distmeta->{resources}{x_IRC}
169             ? 'There is also an irc channel available for users of this distribution, at' . "\nL<"
170             . do {
171             # try to extract the channel
172             if (my ($network, $channel) = ($distmeta->{resources}{x_IRC} =~ m!(?:://)?(\w+(?:\.\w+)*)/?(#\w+)!)) {
173             'C<' . $channel . '> on C<' . $network . '>|' . $distmeta->{resources}{x_IRC}
174             }
175             else {
176             $distmeta->{resources}{x_IRC}
177             }
178             }
179             . '>.'
180             : (),
181              
182             (($distmeta->{x_authority} // '') eq 'cpan:ETHER') # Disabled for TABULO because I am not active on IRC, but ETHER can still use this profile:-)
183             ? "I am also usually active on irc, as 'ether' at C<irc.perl.org>."
184             : (),
185             ) }}
186             SUPPORT
187 57     57 0 1868 }
188              
189             sub mvp_bundle_config {
190 57   50 57 0 43878609 my $self = shift || __PACKAGE__;
191              
192             return map {
193 57         429 $self->_expand_config($_)
  1653         4130  
194             } $self->configure;
195             }
196              
197              
198             my $prefix;
199             sub _prefix {
200 1276     1276   74976 my $self = shift;
201 1276 100       4724 return $prefix if defined $prefix;
202 13   33     234 ($prefix = (ref($self) || $self)) =~ s/^Pod::Weaver::PluginBundle:://;
203 13         87 $prefix;
204             }
205              
206             sub _expand_config
207             {
208 1686     1686   433399 my ($self, $this_spec) = @_;
209              
210 1686 100       3918 die 'undefined config' if not $this_spec;
211 1685 100 100     6071 die 'unrecognized config format: ' . ref($this_spec) if ref($this_spec) and ref($this_spec) ne 'ARRAY';
212              
213 1684         3052 my ($name, $class, $payload);
214              
215 1684 100       5009 if (not ref $this_spec)
    100          
    100          
216             {
217 466         1083 ($name, $class, $payload) = ($this_spec, _exp($this_spec), {});
218             }
219             elsif (@$this_spec == 1)
220             {
221 114         468 ($name, $class, $payload) = ($this_spec->[0], _exp($this_spec->[0]), {});
222             }
223             elsif (@$this_spec == 2)
224             {
225 640 100       1717 $name = ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[1];
226 640 100       1748 $class = _exp(ref $this_spec->[1] ? $this_spec->[0] : $this_spec->[0]);
227 640 100       37687 $payload = ref $this_spec->[1] ? $this_spec->[1] : {};
228             }
229             else
230             {
231 464         1185 ($name, $class, $payload) = ($this_spec->[1], _exp($this_spec->[0]), $this_spec->[2]);
232             }
233              
234 1684         64814 $name =~ s/^[@=-]//;
235              
236             # Region plugins have the custom plugin name moved to 'region_name' parameter,
237             # because we don't want our bundle name to be part of the region name.
238 1684 100       3858 if ($class eq _exp('Region'))
239             {
240 231         13420 $name = $this_spec->[1];
241 231         947 $payload = { region_name => $this_spec->[1], %$payload };
242             }
243              
244 1684 100       84909 use_module($class, $payload->{':version'}) if $payload->{':version'};
245              
246             # prepend '@Author::TABULO/' to each class name,
247             # except for Generic and Collect which are left alone.
248 1683 100 100     1878395 $name = '@' . $self->_prefix . '/' . $name
249             if $class ne _exp('Generic') and $class ne _exp('Collect');
250              
251 1683         28544 return [ $name => $class => $payload ];
252             }
253              
254             1;
255              
256             __END__
257              
258             =pod
259              
260             =encoding UTF-8
261              
262             =head1 NAME
263              
264             Pod::Weaver::PluginBundle::Author::TABULO - A plugin bundle for pod woven for TABULO
265              
266             =head1 VERSION
267              
268             version 0.198
269              
270             =head1 SYNOPSIS
271              
272             In your F<weaver.ini>:
273              
274             [@Author::TABULO]
275              
276             Or in your F<dist.ini>
277              
278             [PodWeaver]
279             config_plugin = @Author::TABULO
280              
281             It is also used automatically when your F<dist.ini> contains:
282              
283             [@Author::TABULO]
284             :version = 0.094 ; or any higher version
285              
286             =head1 DESCRIPTION
287              
288             =begin COMMENT
289              
290              
291              
292              
293             =end COMMENT
294              
295             NOTE: See C<Pod::Wordlist> for a list of stopwords that are already taken into account
296             automatically by L<[Test::PodSpelling]|Dist::Zilla::Plugin::Test::PodSpelling/stopwords>.
297              
298             =for stopwords TABULO ETHER
299             =for stopwords GitHub
300             =for stopwords optimizations repo
301              
302             This is a L<Pod::Weaver> plugin bundle used for TABULO's distributions.
303             Like his dzil plugin-bundle, the starting point of this profile was ETHER's.
304              
305             And since TABULO initially forked the whole thing from ETHER's,
306             most of the documentation you see here actually come from her originally, ...
307              
308             Thank you ETHER!
309              
310             =head2 WARNING
311              
312             Please note that, although this module needs to be on CPAN for obvious reasons,
313             it is really intended to be a collection of personal preferences, which are
314             expected to be in great flux, at least for the time being.
315              
316             Therefore, please do NOT base your own distributions on this one, since anything
317             can change at any moment without prior notice, while I get accustomed to dzil
318             myself and form those preferences in the first place...
319             Absolutely nothing in this distribution is guaranteed to remain constant or
320             be maintained at this point. Who knows, I may even give up on dzil altogether...
321              
322             You have been warned.
323              
324             =head2 DESCRIPTION (at last)
325              
326             This L<Pod::Weaver> plugin bundle is I<approximately> equal to the
327             following F<weaver.ini>, minus some optimizations:
328              
329             [-EnsurePod5]
330             [-H1Nester]
331              
332             [-AppendPrepend]
333              
334             [-EnsureUniqueSections]
335              
336             [-Include]
337             insert_errors = 0
338             pod_path = lib:bin:script:scripts:docs/pod
339              
340             [-SingleEncoding]
341              
342             [-StopWords]
343             gather = 1
344             include = CPAN
345             include = DZIL
346             include = GITHUB
347             include = MERCHANTABILITY
348             ; include = ... (a bunch of other stopwords for the spell-checker, too many to list here)
349              
350             [-Transformer / List]
351             transformer = List
352              
353             [-Transformer / Verbatim]
354             transformer = Verbatim
355              
356             [-Transformer / WikiDoc]
357             transformer = WikiDoc
358              
359             [Region / header]
360             [Name]
361             [Version]
362              
363             [Region / prelude]
364              
365             [Generic / SYNOPSIS]
366             [Generic / DESCRIPTION]
367             [Generic / OVERVIEW]
368              
369             [Collect / ATTRIBUTES]
370             command = attr
371              
372             [Collect / METHODS]
373             command = method
374              
375             [Collect / FUNCTIONS]
376             command = func
377              
378             [Collect / TYPES]
379             command = type
380              
381             [Leftovers]
382              
383             [Region / postlude]
384              
385             [GenerateSection / generate SUPPORT]
386             title = SUPPORT
387             main_module_only = 0
388             text = <template>
389             [AllowOverride / allow override SUPPORT]
390             header_re = ^(SUPPORT|BUGS)
391             action = prepend
392             match_anywhere = 0
393              
394             [Authors]
395             [Contributors]
396             :version = 0.008
397              
398             [Legal]
399             :version = 4.011
400             header = COPYRIGHT AND <licence filename>
401              
402             [WarrantyDisclaimer]
403              
404             [Region / footer]
405              
406             This is also equivalent (other than section ordering) to:
407              
408             [-AppendPrepend]
409              
410             [-EnsureUniqueSections]
411              
412             [-Include]
413             insert_errors = 0
414             pod_path = lib:bin:script:scripts:docs/pod
415              
416             [-StopWords]
417             gather = 1
418             include = CPAN
419             include = DZIL
420             include = GITHUB
421             include = MERCHANTABILITY
422             ; include = ... (a bunch of other stopwords for the spell-checker, too many to list here)
423              
424             [-Transformer / List]
425             transformer = List
426              
427             [-Transformer / Verbatim]
428             transformer = Verbatim
429              
430             [-Transformer / WikiDoc] ; Added by TABULO
431             transformer = WikiDoc
432              
433             [Region / header]
434             [@Default]
435              
436             [Collect / TYPES]
437             command = type
438              
439             [GenerateSection / generate SUPPORT]
440             title = SUPPORT
441             main_module_only = 0
442             text = <template>
443             [AllowOverride / allow override SUPPORT]
444             header_re = ^(SUPPORT|BUGS)
445             action = prepend
446             match_anywhere = 0
447              
448             [Contributors]
449             :version = 0.008
450              
451             [WarrantyDisclaimer]
452              
453             [Region / footer]
454              
455             =head1 OPTIONS
456              
457             None at this time. (The bundle is never instantiated, so this doesn't seem to
458             be possible without updates to L<Pod::Weaver>.)
459              
460             =head1 OVERRIDING A SPECIFIC SECTION
461              
462             This F<weaver.ini> will let you use a custom C<COPYRIGHT AND LICENCE> section and still use the plugin bundle:
463              
464             [@Author::TABULO]
465             [AllowOverride / OverrideLegal]
466             header_re = ^COPYRIGHT
467             match_anywhere = 1
468              
469             =head1 ADDING STOPWORDS FOR SPELLING TESTS
470              
471             As noted in L<Dist::Zilla::PluginBundle::Author::TABULO>, stopwords for
472             spelling tests can be added by adding a directive to pod:
473              
474             =for stopwords foo bar baz
475              
476             However, if the stopword appears in the module's abstract, it is moved to the
477             C<NAME> section, which will be above your stopword directive. You can handle
478             this by declaring the stopword in the special C<header> section, which will be
479             woven ahead of everything else:
480              
481             =for :header
482             =for stopwords foo bar baz
483              
484             =head1 SEE ALSO
485              
486             =over 4
487              
488             =item *
489              
490             L<Pod::Weaver>
491              
492             =item *
493              
494             L<Pod::Weaver::PluginBundle::Default>
495              
496             =item *
497              
498             L<Dist::Zilla::Plugin::PodWeaver>
499              
500             =item *
501              
502             L<Dist::Zilla::PluginBundle::Author::TABULO>
503              
504             =item *
505              
506             L<Dist::Zilla::MintingProfile::Author::TABULO>
507              
508             =item *
509              
510             L<Pod::Weaver::PluginBundle::Author::ETHER> (the original bundle of ETHER)
511              
512             =back
513              
514             =head1 NAMING SCHEME
515              
516             =for stopwords KENTNL
517              
518             This distribution follows best practices for author-oriented plugin bundles; for more information,
519             see L<KENTNL's distribution|Dist::Zilla::PluginBundle::Author::KENTNL/NAMING-SCHEME>.
520              
521             =head1 ORIGINAL AUTHOR
522              
523             =for stopwords ETHER
524              
525             This distribution is based on L<Pod::Weaver::PluginBundle::Author::ETHER> by :
526              
527             Karen Etheridge L<cpan:ETHER>
528              
529             Thank you ETHER!
530              
531             =head1 SUPPORT
532              
533             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-PluginBundle-Author-TABULO>
534             (or L<bug-Dist-Zilla-PluginBundle-Author-TABULO@rt.cpan.org|mailto:bug-Dist-Zilla-PluginBundle-Author-TABULO@rt.cpan.org>).
535              
536             =head1 AUTHOR
537              
538             Tabulo <tabulo@cpan.org>
539              
540             =head1 COPYRIGHT AND LICENSE
541              
542             This software is copyright (c) 2018 by Tabulo.
543              
544             This is free software; you can redistribute it and/or modify it under
545             the same terms as the Perl 5 programming language system itself.
546              
547             =cut