The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dist::Zilla::Plugin::InsertCodeOutput - Insert the output of Perl code into your POD

VERSION

This document describes version 0.046 of Dist::Zilla::Plugin::InsertCodeOutput (from Perl distribution Dist-Zilla-Plugin-InsertCodeOutput), released on 2023-12-11.

SYNOPSIS

In dist.ini:

 [InsertCodeOutput]
 ;make_verbatim=1

In your POD:

 # CODE: require MyLib; MyLib::gen_stuff("some", "param");

or for multiline code:

 # BEGIN_CODE
 require MyLib;
 MyLib::gen_stuff("some", "param");
 ...
 # END_CODE

(you can prefix each line in multiline code with comment, to prevent this code from being analyzed by other analyzers e.g. scan_prereqs):

 # BEGIN_CODE
 #require MyLib;
 #MyLib::gen_stuff("some", "param");
 #...
 # END_CODE

DESCRIPTION

This module finds # CODE: ... or # BEGIN_CODE and # END CODE directives in your POD, evals the specified Perl code while capturing the output using Capture::Tiny's capture_merged (which means STDOUT and STDERR output are both captured), and insert the output to your POD as verbatim paragraph (indented with a whitespace), unless when make_verbatim is set to 0 then it is inserted as-is. If eval fails ($@ is true), build will be aborted.

The directives must be at the first column of the line.

HOMEPAGE

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

SOURCE

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

SEE ALSO

Dist::Zilla::Plugin::InsertCodeResult which is similar and uses the same # CODE directive, but instead of inserting output, will insert the result of the code (which can be a reference, in which case will be dumped using Data::Dump).

Dist::Zilla::Plugin::InsertCommandOutput

Dist::Zilla::Plugin::InsertExample

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTOR

Steven Haryanto <stevenharyanto@gmail.com>

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, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2023, 2021, 2020, 2019, 2018, 2015, 2014 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-InsertCodeOutput

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.