increment $VERSION after 1.003027 release
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / PPI.pm
1 use strict;
2 use warnings;
3 package Devel::REPL::Plugin::PPI;
4 # ABSTRACT: PPI dumping of Perl code
5
6 our $VERSION = '1.003028';
7
8 use Devel::REPL::Plugin;
9 use PPI;
10 use PPI::Dumper;
11 use namespace::autoclean;
12
13 sub BEFORE_PLUGIN {
14     my $self = shift;
15     $self->load_plugin('Turtles');
16 }
17
18 sub expr_command_ppi {
19   my ( $self, $eval, $code ) = @_;
20
21   my $document = PPI::Document->new(\$code);
22   my $dumper   = PPI::Dumper->new($document);
23   return $dumper->string;
24 }
25
26 __PACKAGE__
27
28 __END__
29
30 =pod
31
32 =head1 SYNOPSIS
33
34   repl> #ppi Devel::REPL
35   PPI::Document
36     PPI::Statement
37       PPI::Token::Word    'Devel::REPL'
38
39   repl> #ppi {
40   > warn $];
41   > }
42   PPI::Document
43     PPI::Statement::Compound
44       PPI::Structure::Block       { ... }
45         PPI::Token::Whitespace    '\n'
46         PPI::Statement
47           PPI::Token::Word        'warn'
48           PPI::Token::Whitespace          ' '
49           PPI::Token::Magic       '$]'
50           PPI::Token::Structure   ';'
51         PPI::Token::Whitespace    '\n'
52
53 =head1 DESCRIPTION
54
55 This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump
56 L<PPI>-parsed Perl documents.
57
58 The code is not actually executed, which means that when used with
59 L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>.
60
61 =head1 AUTHOR
62
63 Shawn M Moore E<lt>sartak@gmail.comE<gt>
64
65 =cut