Ricardo SIGNES > Pod-Elemental-PerlMunger > Pod::Elemental::PerlMunger

Download:
Pod-Elemental-PerlMunger-0.200002.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.200002   Source  

NAME ^

Pod::Elemental::PerlMunger - a thing that takes a string of Perl and rewrites its documentation

VERSION ^

version 0.200002

OVERVIEW ^

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:

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

$perl_string should be a character string containing Perl source code.

%arg may contain any input for the underlying procedure. The only key with associated meaning is filename which may be omitted. If given, it should be the name of the file whose contents are being munged.

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:

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

%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.

ATTRIBUTES ^

replacer

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.

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.

METHODS ^

replace_with_nothing

This method returns nothing. It's the default "replacer". It's not very interesting.

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

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.

AUTHOR ^

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 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.

syntax highlighting: