Pod::Elemental::PerlMunger - a thing that takes a string of Perl and rewrites its documentation
This role is to be included in classes that rewrite the documentation of a Perl document, stripping out all the Pod, munging it, and replacing it into the Perl.
The only relevant method is munge_perl_string, which must be implemented with a different interface than will be exposed.
When calling the munge_perl_string method, arguments should be passed like this:
$perl_string should be a character string containing Perl source code.
%arg may contain any input for the underlying procedure. Defined keys for %arg are:
the name of the file whose contents are being munged; optional, used for error messages
If given, the BOM character (U+FEFF) won't be stripped from the input. Probably best to leave this one off.
The method will return a character string containing the rewritten and combined document.
Classes including this role must implement a munge_perl_string that expects to be called like this:
%doc will have two entries:
ppi - a PPI::Document of the Perl document with all its Pod removed
pod - a Pod::Elemental::Document with no transformations yet performed
This munge_perl_string method should return a hashref in the same format as %doc.
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
The replacer is either a method name or code reference used to produces PPI elements used to replace removed Pod. By default, it is "replace_with_nothing", which just removes Pod tokens entirely. This means that the line numbers of the code in the newly-produced document are changed, if the Pod had been interleaved with the code.
See also "replace_with_comment" and "replace_with_blank".
If no further code follows the Pod being replaced, "post_code_replacer" is used instead.
This attribute is used just like "replacer", and defaults to its value, but is used for building replacements for Pod removed after the last hunk of code. The idea is that if you're only concerned about altering your code's line numbers, you can stop replacing stuff after there's no more code to be affected.
This method returns nothing. It's the default "replacer". It's not very interesting.
This replacer replaces removed Pod elements with a comment containing their text. In other words:
=head1 A header!
This is great!
...is replaced with:
# =head1 A header!
# This is great!
This replacer replaces removed Pod elements with vertical whitespace of equal line count. In other words:
...is replaced with five blank lines.
Ricardo SIGNES <firstname.lastname@example.org>
Christopher J. Madsen <email@example.com>
Dave Rolsky <firstname.lastname@example.org>
Karen Etheridge <email@example.com>
perlancar (on PC, Bandung) <firstname.lastname@example.org>
Ricardo Signes <email@example.com>
This software is copyright (c) 2022 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Pod::Elemental::PerlMunger, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.