@@ -1,5 +1,12 @@
Revision history for Pod-Abstract
+0.20 03/01/2010
+ Removed usage of UNIVERSAL isa and can as functions, will correct
+ a deprecation warning with Perl 5.11. Fixed a bug with
+ nodes->from_pod which did not work as documented. Corrected some
+ minor errors with documentation formatting. Added test coverage
+ for from_pod.
+
0.19 21/06/2009
Added =head1 NAME blocks to those modules missing them. Added some
additional Pod. Added "Task::Weaken" dependancy to ensure that the
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Pod-Abstract
-version: 0.19
+version: 0.20
version_from: lib/Pod/Abstract.pm
installdirs: site
requires:
@@ -6,7 +6,6 @@ use warnings;
use Pod::Abstract;
use Pod::Abstract::Filter;
-use UNIVERSAL qw(isa);
use File::Temp qw(tempfile tempdir);
@@ -207,7 +206,7 @@ sub main {
($out, $tmpfilename) = tempfile;
}
- if(isa($next, 'Pod::Abstract::Node')) {
+ if(eval { $next->isa( 'Pod::Abstract::Node' ) }) {
if($flags{d}) {
print $out $next->ptree;
} else {
@@ -7,7 +7,7 @@ use Pod::Abstract::Parser;
use Pod::Abstract::Node;
use base qw(Exporter);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
our @EXPORT_OK = qw(node nodes);
@@ -75,8 +75,9 @@ sub from_pod {
my $str = shift;
my $root = Pod::Abstract->load_string($str);
+ return undef unless $root;
- my @r = map { $_->detach } $root->children;
+ my @r = map { $_->detach; $_ } $root->children;
return @r;
}
@@ -161,6 +162,7 @@ sub paragraph {
);
my $parser = Pod::Abstract::Parser->new;
my $pt = $parser->parse_text($str);
+
if($pt) {
$parser->load_pt($para,$pt);
} else {
@@ -4,7 +4,7 @@ use strict;
use base qw(Pod::Abstract::Filter);
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -3,7 +3,7 @@ use strict;
use base qw(Pod::Abstract::Filter);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -4,7 +4,7 @@ use warnings;
use base qw(Pod::Abstract::Filter);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -5,7 +5,7 @@ use warnings;
use base qw(Pod::Abstract::Filter);
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -27,7 +27,7 @@ head4 or list item, we're fine. If you use head1 then it won't be useful.
In order to be useful as an end user tool, head1 nodes (...) are added
between the found nodes. This stops perldoc from dying with no
documentation. These can be easily stripped using:
-C<<$pa->select('/head1')>>, then hoist and detach, or reparent to other
+C<< $pa->select('/head1') >>, then hoist and detach, or reparent to other
Node types.
A good example of this working as intended is:
@@ -5,7 +5,7 @@ use warnings;
use base qw( Pod::Abstract::Filter );
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -6,7 +6,7 @@ use base qw(Pod::Abstract::Filter);
use Pod::Abstract;
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -13,7 +13,7 @@ sub-sections within a Pod section
=cut
-our $VERSION = '0.19';
+our $VERSION = '0.20';
sub filter {
my $self = shift;
@@ -4,7 +4,7 @@ use strict;
use base qw(Pod::Abstract::Filter);
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -5,7 +5,7 @@ use warnings;
use base qw(Pod::Abstract::Filter);
use Pod::Abstract::BuildNode qw(node);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -4,7 +4,7 @@ use warnings;
use base qw(Pod::Abstract::Filter);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -3,9 +3,8 @@ use strict;
use warnings;
use Pod::Abstract;
-use UNIVERSAL qw(isa);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -108,7 +107,7 @@ sub run {
my $self = shift;
my $arg = shift;
- if( isa($arg, 'Pod::Abstract::Node') ) {
+ if( eval { $arg->isa( 'Pod::Abstract::Node' ) } ) {
return $self->filter($arg);
} else {
my $pa = Pod::Abstract->load_string($arg);
@@ -7,7 +7,7 @@ use Pod::Abstract::Serial;
use Scalar::Util qw(weaken);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -229,7 +229,7 @@ sub pod {
if($body_attr) {
$body = $self->param($body_attr)->pod;
}
- if(defined $body) {
+ if(defined $body && $body ne '') {
$r .= "=$type $body$p_break";
} else {
$r .= "=$type$p_break";
@@ -368,7 +368,7 @@ sub duplicate {
my %new_params = ( );
foreach my $param (keys %$params) {
my $pv = $params->{$param};
- if(ref $pv && UNIVERSAL::can($pv, 'duplicate')) {
+ if(ref $pv && eval { $pv->can('duplicate') } ) {
$new_params{$param} = $pv->duplicate;
} elsif(! ref $pv) {
$new_params{$param} = $pv;
@@ -6,7 +6,7 @@ use Pod::Abstract::Node;
use Data::Dumper;
use base qw(Pod::Parser);
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -136,7 +136,9 @@ sub command {
if($no_parse{$top->type} && !$top->param('parse_me')) {
my $t_node = Pod::Abstract::Node->new(
type => ':text',
- body => "=$command $paragraph$p_break",
+ body => ($paragraph ne '' ?
+ "=$command $paragraph$p_break" :
+ "=$command$p_break"),
);
$top->push($t_node);
return;
@@ -4,12 +4,11 @@ use warnings;
use Data::Dumper;
-use UNIVERSAL qw(isa can);
use Pod::Abstract::BuildNode qw(node);
$Data::Dumper::Indent = 1;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
use constant CHILDREN => 1; # /
use constant ALL => 2; # //
@@ -469,7 +468,7 @@ sub match_expression {
my $t_result;
# Allow for r_exp to be another expression - generate both
# node lists if required.
- if(can($r_exp, 'process')) {
+ if( eval { $r_exp->can('process') } ) {
my @r_list = $r_exp->process($n);
$t_result = $self->$test_action(\@t_list, \@r_list, $op);
} else {
@@ -489,7 +488,7 @@ sub test_cmp_op {
my $r_exp = shift;
my $op = shift;
- if(scalar(@$r_exp) == 0 || isa($r_exp->[0],'Pod::Abstract::Node')) {
+ if(scalar(@$r_exp) == 0 || eval { $r_exp->[0]->isa('Pod::Abstract::Node') }) {
# combination test
my $match = 0;
foreach my $l (@$l_list) {
@@ -1,6 +1,6 @@
package Pod::Abstract::Serial;
use strict;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
my $serial_number = 0;
@@ -18,7 +18,7 @@ This will cause problems with Pod::Abstract documents frozen to disk
using Data::Dumper etc, unless C<set> is used to bump the number above
the highest number read.
-Or just serialise your document with C<<$node->pod>> instead!
+Or just serialise your document with C<< $node->pod >> instead!
=cut
@@ -1,7 +1,7 @@
package Pod::Abstract::Tree;
use strict;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -7,7 +7,7 @@ use Pod::Abstract::Path;
use Pod::Abstract::Parser;
use IO::String;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
=head1 NAME
@@ -155,7 +155,7 @@ See L<Pod::Abstract::Node>
L<Pod::Abstract::Path>, the node selection expression language. This
is generally called by doing
-C<<$node->select(PATH_EXP)>>. Pod::Abstract::Path is the most complex
+C<< $node->select(PATH_EXP) >>. Pod::Abstract::Path is the most complex
and powerful component of this module, and if you're not using it you
should be. ;)
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 11;
use Pod::Abstract;
use Pod::Abstract::BuildNode qw(node nodes);
@@ -39,4 +39,11 @@ Test Item
is( $root->pod, $pod, "Generated correct Pod" );
+my @nodes = nodes->from_pod($pod);
+my $root_2 = node->root;
+$root_2->nest(@nodes);
+
+my $pod_2 = $root_2->pod;
+is( $pod_2, $pod, "Round tripped same Pod with ->from_pod" );
+
1;