Pod::Weaver::Plugin::EnsureUniqueSections - Ensure that POD has no duplicate section headers.
[-EnsureUniqueSections] strict = 0 ; The default
This plugin simply ensures that the POD after weaving has no duplicate top-level section headers. This can help you if you are converting from writing all your own POD to generating it with Pod::Weaver. If you begin generating a section with Pod::Weaver but you forget to delete the manually written section of the same name, this plugin will warn you.
By default, this module does some tricks to detect similar headers, such as
AUTHORS. You can turn this off by setting
strict = 1 in weaver.ini, in which case only exactly identical headers will be considered duplicates of each other.
If any similar (or identical if
strict is 1) section headers are found, all of their names will be listed on STDERR. Generally, you should take this list of modules and remove each from your POD. Then you should ensure that the sections generated by Pod::Weaver are suitable substitutes for those sections. In the case of similar names, only the first instance in each set of similar names will be listed.
If set to true (1), section headers will only be considered duplicates if they match exactly. If false (the default), certain similar section headers will be considered equivalent. The following similarities are considered (more may be added later):
For example, the following would all be considered duplicates of each other:
NAME would be considered duplicates.
For example, "COPYRIGHT AND LICENSE" would be considered a duplicate of "LICENSE AND COPYRIGHT".
A plural noun is considered equivalent to its singular. For example, "AUTHOR" and "AUTHORS" are the same section. A section header consisting of multiple words, such as "DISCLAIMER OF WARRANTY", is not affected by this rule.
This rule uses Lingua::EN::Inflect::Number to interconvert between singular and plural forms. Hopefully you don't need to make a section called
Note that these rules apply recursively, so
Authors; and Contributors would be a duplicate of
CONTRIBUTORS AND AUTHOR.
This method modifies the weaver object by moving EnsureUniqueSections to the end of the weaver's plugin list to ensure that it gets to look at the final woven POD.
THIS IS PURE EVIL. This is a hack to ensure that this plugin gets "the last word". Obviously if all plugins used this it would be total chaos. I welcome alternative suggestions. The main issue is that when other Finalizers, such as Section::Leftovers (which happens to be the most likely plugin to create duplicate sections), produce sections, this plugin will only see those sections if it runs after those Finalizers. Hence the need to be the last plugin on the list.
This method checks the document for duplicate headers, and throws an error if any are found. If no duplicates are found, it simply does nothing. It does not modify the POD in any way.
I would like to convert this to a Dist::Zilla testing plugin, so that you can use it without enabling Pod::Weaver if you don't want to, but I haven't yet figured out how to find all files in a dist with POD and extract all their headers. If anyone knows, please tell me.
This module only checks for duplicates in top-level headers (i.e.
head1). It could be extended to check the
head2 elements within each
head1 section and so on, but generally Pod::Weaver is not called upon to generate subsections, so you are unlikely to end up with duplicates at any level other than the first. However, if there is demand for recursive duplicate detection, I will add it.
Please report any bugs or feature requests to
See perlmodinstall for information and options on installing Perl modules.
Ryan C. Thompson <firstname.lastname@example.org>
This software is copyright (c) 2010 by Ryan C. Thompson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.