NAME
Perinci::Gen::ForModule - Generate metadata for a module
VERSION
This document describes version 0.110 of Perinci::Gen::ForModule (from
Perl distribution Perinci-Gen-ForModule), released on 2017-12-15.
SYNOPSIS
In Foo/Bar.pm:
package Foo::Bar;
sub sub1 { ... }
sub sub2 { ... }
1;
In another script:
use Perinci::Gen::FromModule qw(gen_meta_for_module);
gen_meta_for_module(module=>'Foo::Bar');
Now Foo::Bar has metadata stored in %Foo::Bar::SPEC.
FUNCTIONS
gen_meta_for_module
Usage:
gen_meta_for_module(%args) -> [status, msg, result, meta]
Generate metadata for a module.
This function can be used to automatically generate Rinci metadata for a
"traditional" Perl module which do not have any. Currently, only a plain
and generic package and function metadata are generated.
The resulting metadata will be put in %<PACKAGE>::SPEC. Functions that
already have metadata in the %SPEC will be skipped. The metadata will
have "result_naked" property set to true, "args_as" set to "array", and
"args" set to "{args =" ["any" => {schema=>'any', pos=>0, greedy=>1}]}>.
In the future, function's arguments (and other properties) will be
parsed from POD (and other indicators).
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
* exclude_subs => *array[str]|str* (default: "^_")
If specified, exclude these subs.
By default, exclude private subroutines (subroutines which have _
prefix in their names).
* include_subs => *array[str]|str*
If specified, only include these subs.
* load => *bool* (default: 1)
Whether to load the module using require().
* module => *str*
The module name.
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code (200
means OK, 4xx caller error, 5xx function error). Second element (msg) is
a string containing error message, or 'OK' if status is 200. Third
element (result) is optional, the actual result. Fourth element (meta)
is called result metadata and is optional, a hash that contains extra
information.
Return value: (any)
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/Perinci-Gen-ForModule>.
SOURCE
Source repository is at
<https://github.com/perlancar/perl-Perinci-Gen-ForModule>.
BUGS
Please report any bugs or feature requests on the bugtracker website
<https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Gen-ForModule
>
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.
SEE ALSO
Perinci, Rinci
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017, 2016, 2015, 2014, 2012 by
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.