NAME

Dist::Zilla::Plugin::InsertBlock - Insert a block of text from another file

VERSION

This document describes version 0.103 of Dist::Zilla::Plugin::InsertBlock (from Perl distribution Dist-Zilla-Plugin-InsertBlock), released on 2021-09-16.

SYNOPSIS

In dist.ini:

 [InsertBlock]

In lib/Baz.pm:

 ...

 # BEGIN_BLOCK: some_code

 ...

 # END_BLOCK

In lib/Foo/Base.pm:

 ...

 =head1 ATTRIBUTES

 =for BEGIN_BLOCK: base_attributes

 =head2 attr1

 =head2 attr2

 =for END_BLOCK: base_attributes

 ...

 =head1 METHODS

 =over 11

 =back BEGIN_BLOCK: base_methods

 =head2 meth1

 =head2 meth2

 =over 11

 =back END_BLOCK: base_methods

In lib/Foo/Bar.pm:

 ...

 # INSERT_BLOCK: lib/Baz.pm some_code

 ...

 =head1 ATTRIBUTES

 # INSERT_BLOCK: lib/Foo/Base.pm base_attributes

 =head2 attr3

 ...

 =head1 METHODS

 =INSERT_BLOCK: lib/Foo/Base.pm base_methods

 =head2 meth3

 ...

DESCRIPTION

This plugin finds # INSERT_BLOCK: <file> <name> directives in your POD/code. It then searches for a block of text named name in file file, and inserts the content of the block to replace the directive.

A block is marked/defined using either this syntax:

 # BEGIN_BLOCK: Name
 ...
 # END_BLOCK: Name

or this (for block inside POD):

 =for BEGIN_BLOCK: Name

 ...

 =for END_BLOCK: Name

or this =over 11 workaround syntax (for blocks inside POD, in case tools like Pod::Weaver remove =for directives):

 =over 11

 =back BEGIN_BLOCK: Name

 ...

 =over 11

 =back END_BLOCK: Name

Block name is case-sensitive.

This plugin can be useful to avoid repetition/manual copy-paste, e.g. when you want to list POD attributes, methods, etc from a base class into a subclass.

Options

The # INSERT_BLOCK directive accepts an optional third argument for options. Known options:

  • pod_verbatim

    This option pads each line of the block content with whitespace. Suitable for when you are inserting a block into a POD and you want to make the content of the block as POD verbatim.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Dist-Zilla-Plugin-InsertBlock.

SOURCE

Source repository is at https://github.com/perlancar/perl-Dist-Zilla-Plugin-InsertBlock.

SEE ALSO

Dist::Zilla::Plugin::InsertBlock::FromModule

Dist::Zilla::Plugin::InsertCodeResult

Dist::Zilla::Plugin::InsertCodeOutput

Dist::Zilla::Plugin::InsertCommandOutput

Dist::Zilla::Plugin::InsertExample - which basically insert whole files instead of just a block of text from a file

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

 % prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla plugin and/or Pod::Weaver::Plugin. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2020, 2016, 2015 by perlancar <perlancar@cpan.org>.

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

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-InsertBlock

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.