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