NAME

Pod::Knit::Plugin - base class for Pod::Knit transforming modules

VERSION

version 0.0.1

SYNOPSIS

use Pod::Knit::Document;
use Pod::Knit::Plugin;

my $doc = Pod::Knit::Document->new( file => 'Foo.pm' );

my $new_doc = Pod::Knit::Plugin->new()->munge($doc);

DESCRIPTION

Pod::Knit::Plugin is the base class for the transforming modules of the Pod::Knit system.

A plugin should override the munge method, and may implement a setup_podparser method that is invoked when the podparser of a Pod::Knit::Document is created. For example, if a plugin is to introduce two new tags, method and signature, it should have

sub setup_podparser ( $self, $parser ) {

    $parser->accept_directive_as_processed( qw/
        method signature
    /);

    $parser->commands->{method}    = { alias => 'head3' };
    $parser->commands->{signature} = { alias => 'verbatim' };
}

Because munging XML with regular expressions and the like is no fun, you most probably want your plugins to consume either one of the Pod::Knit::DOM::WebQuery or Pod::Knit::DOM::Mojo roles, which augment the doc passed to the plugin with yummilicious DOM manipulating methods.

attributes

knit

Orchestrating Pod::Knit object. Optional.

stash

Hashref of variables typically passed by the knit object.

methods

munge

$new_doc = $self->munge( $doc )

Takes in a Pod::Knit::Document, and returns a new one.

For the base Pod::Knit::Plugin class, the method is a pass-through that returns the exact same document.

AUTHOR

Yanick Champoux <yanick@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2018 by Yanick Champoux.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Full text of the license can be found in the LICENSE file included in this distribution.