App-RoboBot

 view release on metacpan or  search on metacpan

lib/App/RoboBot/Doc.pm  view on Meta::CPAN

package App::RoboBot::Doc;
$App::RoboBot::Doc::VERSION = '4.004';
use v5.20;

use namespace::autoclean;
use Moose;

use Pod::Simple::SimpleTree;

has 'bot' => (
    is       => 'ro',
    isa      => 'App::RoboBot',
    required => 1,
);

has 'parser' => (
    is      => 'ro',
    isa     => 'Pod::Simple::SimpleTree',
    default => sub { my $p = Pod::Simple::SimpleTree->new; $p->merge_text(1); return $p },
);

has 'pod_cache' => (
    is      => 'rw',
    isa     => 'HashRef',
    default => sub { {} },
);

has 'module_cache' => (
    is      => 'rw',
    isa     => 'HashRef',
    default => sub { {} },
);

has 'function_cache' => (
    is      => 'rw',
    isa     => 'HashRef',
    default => sub { {} },
);

sub list_modules {
    my ($self) = @_;

    return sort map { $_->ns } @{$self->bot->plugins};
}

sub list_module_functions {
    my ($self, $module) = @_;

    return unless defined $module;

    my $plugin = (grep { $_->ns eq $module } @{$self->bot->plugins})[0];
    return unless defined $plugin;

    return sort keys %{$plugin->commands};
}

sub module {
    my ($self, $module) = @_;

    return unless defined $module;
    return $self->module_cache->{$module} if exists $self->module_cache->{$module};

    my $pm_file = $self->_find_pm($module);
    my $pod = $self->_extract_pod($pm_file);



( run in 0.871 second using v1.01-cache-2.11-cpan-39bf76dae61 )