[Bast-commits] r3134 - in trunk: . Test-POD-Examples Test-POD-Examples/lib Test-POD-Examples/lib/Test Test-POD-Examples/lib/Test/POD

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Mon Mar 19 17:52:03 GMT 2007


Author: matthewt
Date: 2007-03-19 17:51:56 +0000 (Mon, 19 Mar 2007)
New Revision: 3134

Added:
   trunk/Test-POD-Examples/
   trunk/Test-POD-Examples/Makefile.PL
   trunk/Test-POD-Examples/do.sh
   trunk/Test-POD-Examples/lib/
   trunk/Test-POD-Examples/lib/Test/
   trunk/Test-POD-Examples/lib/Test/POD/
   trunk/Test-POD-Examples/lib/Test/POD/Examples.pm
   trunk/Test-POD-Examples/t/
Log:
skeleton committed for ideas

Added: trunk/Test-POD-Examples/Makefile.PL
===================================================================
--- trunk/Test-POD-Examples/Makefile.PL	                        (rev 0)
+++ trunk/Test-POD-Examples/Makefile.PL	2007-03-19 17:51:56 UTC (rev 3134)
@@ -0,0 +1,5 @@
+use inc::Module::Install;
+
+requires 'Pod::Parser';
+requires 'Class::Inspector';
+requires 'Class::Accessor::Fast';

Added: trunk/Test-POD-Examples/do.sh
===================================================================
--- trunk/Test-POD-Examples/do.sh	                        (rev 0)
+++ trunk/Test-POD-Examples/do.sh	2007-03-19 17:51:56 UTC (rev 3134)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+perl -Ilib -MTest::POD::Examples -e 'Test::POD::Examples->extract_for_module("Test::POD::Examples");'


Property changes on: trunk/Test-POD-Examples/do.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/Test-POD-Examples/lib/Test/POD/Examples.pm
===================================================================
--- trunk/Test-POD-Examples/lib/Test/POD/Examples.pm	                        (rev 0)
+++ trunk/Test-POD-Examples/lib/Test/POD/Examples.pm	2007-03-19 17:51:56 UTC (rev 3134)
@@ -0,0 +1,88 @@
+package Test::POD::Examples;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Test::POD::Examples - test POD-embedded examples
+
+=head1 SYNOPSIS
+
+In My/Module.pm:
+
+=for example My::Module setup
+
+  package My::Module;
+
+  sub new { bless({}, shift); }
+
+  sub spoon { "Spoon!" }
+
+  sub preferred_implement {
+    my $self = shift;
+    my $method = $self->preferred_implement_method;
+    return $self->$method;
+  }
+
+  sub preferred_implement_method {
+    die "Virtual method!";
+  }
+
+  =head1 NAME My::Module
+
+  Cutlery management
+
+  =head1 SYNOPSIS
+
+  =for example My::Module usage
+
+    my $cutlery = My::Module->new;
+
+    $cutlery->spoon; # returns 'Spoon!'
+
+    $cutlery->preferred_implement; # throws 'Virtual method!'
+
+  =for example My::Module end
+
+  =cut
+
+=for example My::Module end
+
+=cut
+
+use base qw/Pod::Parser Class::Accessor::Fast/;
+
+use Class::Inspector;
+
+sub command {
+  my $self = shift;
+  #warn "command: ".join(', ', @_)."\n";
+}
+
+sub textblock {
+  my $self = shift;
+  #warn "textblock: ".join(', ', @_)."\n";
+}
+
+sub verbatim {
+  my $self = shift;
+  #warn "verbatim: ".join(', ', @_)."\n";
+}
+
+sub extract_for_module {
+  my ($class, $module) = @_;
+  my $file = Class::Inspector->resolved_filename($module);
+  my $parser = $class->new;
+  #warn "Parsing ${file} for ${module}\n\n";
+  $parser->parse_from_file($file);
+}
+
+sub new {
+  my $class = shift;
+  my $new = $class->SUPER::new(@_);
+  $new->parseopts(-want_nonPODS => 1);
+  return $new;
+}
+
+1;  




More information about the Bast-commits mailing list