Pod::E...Munger(3pm)

πŸ“¦
version 0.200007 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

ok so Pod::Elemental::PerlMunger β€” it's literally a thing that takes a string of Perl and rewrites its documentation. that's the whole vibe. a Perl-doc glow-up machine πŸ¦‹


✨ VERSION ✨

version 0.200007 β€” yes bestie, she's been through some things and she's thriving πŸ’…


🌸 OVERVIEW 🌸

ok so here's the tea. this is a role β€” meaning you don't just use it, you include it in classes that rewrite the documentation of a Perl document. the whole job is: strip out all the Pod, munge it (yes that's the technical term, it's giving mad scientist πŸ§ͺ), and stick it back into the Perl.

the only method that matters here is munge_perl_string, and heads up β€” the interface you implement is different from the interface that gets exposed. iconic of her honestly.

when you're calling the munge_perl_string method, you pass arguments like this:

$object->munge_perl_string($perl_string, \%arg);

$perl_string should be a character string containing Perl source code. yes, a character string, don't play with her πŸ’€

%arg may contain any input for the underlying procedure. the Defined keys for %arg are:

  • filename β€” the name of the file whose contents are being munged; it's optional, and it's only used for error messages. lowkey just there so your errors have a name to point at 🫢
  • no_strip_bom β€” if given, the BOM character (U+FEFF) won't be stripped from the input. probably best to leave this one off, ngl πŸ™ˆ

the method will return a character string containing the rewritten and combined document. slay.

now for the other side. classes including this role must implement a munge_perl_string that expects to be called like this:

$object->munge_perl_string(\%doc, \%arg);

and %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. no cap, same shape going out as coming in πŸ’«


🐚 PERL VERSION 🐚

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. she's got range πŸ‘‘

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. so don't come for her about backwards compat, fr fr πŸ’€


πŸŽ€ ATTRIBUTES πŸŽ€

replacer

the replacer is either a method name or code reference used to produces PPI elements used to replace removed Pod. (yes, "produces", we're quoting her verbatim, she said what she said πŸ’…)

by default, it's 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. so like, the numbers shift. that's the tradeoff bestie 😭

see also replace_with_comment and replace_with_blank.

if no further code follows the Pod being replaced, post_code_replacer is used instead. plot twist 🌈

post_code_replacer

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. it's giving strategic laziness and honestly? valid πŸ“


πŸ”₯ METHODS πŸ”₯

replace_with_nothing

this method returns nothing. it's the default replacer. it's not very interesting. she's the plain iced coffee of replacers β€” does the job, no notes β˜•

replace_with_comment

this replacer replaces removed Pod elements with a comment containing their text. in other words:

=head1 A header!

This is great!

=cut

...is replaced with:

# =head1 A header!
#
# This is great!
#
# =cut

the way she just wraps the whole thing in # and calls it a day 😌✨

replace_with_blank

this replacer replaces removed Pod elements with vertical whitespace of equal line count. in other words:

=head1 A header!

This is great!

=cut

...is replaced with five blank lines. literally just vibes and empty space 🫧 (count them: five. she's precise.)


πŸ‘‘ AUTHOR πŸ‘‘

Ricardo SIGNES <cpan@semiotic.systems>


πŸ’œ CONTRIBUTORS πŸ’œ

  • Christopher J. Madsen <perl@cjmweb.net>
  • Dave Rolsky <autarch@urth.org>
  • Karen Etheridge <ether@cpan.org>
  • perlancar (on PC, Bandung) <perlancar@gmail.com>
  • Ricardo Signes <rjbs@semiotic.systems>

look at this friend group. the way they all showed up for her πŸ₯ΉπŸ«Ά


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.


ok that's the whole page bestie!! πŸ’– this little masterpiece lives in the User Contributed Perl Documentation, it's Pod::E...Munger(3pm) (the long name got the βœ‚οΈ treatment in the header, you know how it is), and this specific rendition is version 0.200007, dated 2023-01-05, running on perl v5.36.0. go forth and munge, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from