MozRepl::Plugin::Repl::Util::DocFor - Variable information.


MozRepl documentation Contained in the MozRepl distribution.

Index


Code Index:

NAME

Top

MozRepl::Plugin::Repl::Util::DocFor - Variable information.

VERSION

Top

version 0.01

SYNOPSIS

Top

    use MozRepl;
    use Data::Dump qw(dump);

    my $repl = MozRepl->new;
    $repl->setup({ plugins => { plugins => [qw/Repl::Util::DocFor/] } });

    my $doc = $repl->repl_doc_for({ source => 'document.getElementById' });
    print dump $doc;

DESCRIPTION

Top

Add repl_doc_for() method to MozRepl.

METHODS

Top

execute($ctx, $args)

Return variable information as hash reference.

If variable is function, then may be return value within correct arguments list. (Depend on whether toSource() return value is complete function definition or not.)

If variable is DOM Node, then return value within nodename value.

If variable has "doc" property, then return value within doc value.

$ctx

Context object. See MozRepl.

$args

Hash reference.

source

JavaScript variable or value.

method_name()

Return constant value, "repl_doc_for". Used by method name adding method to MozRepl object.

SEE ALSO

Top

MozRepl::Plugin::Base
MozRepl::Plugin::Repl::Util::HelpUrlFor

AUTHOR

Top

Toru Yamaguchi, <zigorou@cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-mozrepl-plugin-repl-util-docfor@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


MozRepl documentation Contained in the MozRepl distribution.
package MozRepl::Plugin::Repl::Util::DocFor;

use strict;
use warnings;

use base qw(MozRepl::Plugin::Base);

our $VERSION = '0.01';

sub execute {
    my ($self, $ctx, $args) = @_;

    my $cmd = $self->process('execute', { repl => $ctx->repl, source => $args->{source} });
    my @response = $ctx->execute($cmd);
    my $result = {};

    for my $line (@response) {
        my ($key, $value) = ($line =~ /^(TYPE|NAME|NODENAME|ARGS): (.*)/);

        if ($key) {
            $key = lc($key);
            $result->{$key} = $value;
            $result->{$key} = [split(/, /, $value)] if ($key eq "args" && $value !~ /^\[.*\]$/);
        }
        else {
            $result->{doc} .= $line . "\n";
        }
    }

    return $result;
}

sub method_name {
    return "repl_doc_for";
}

1; # End of MozRepl::Plugin::Repl::Util::DocFor

__DATA__
__execute__
[% repl %].util.docFor([% source %]);
__END__