[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/linuxaux/opt/perl/lib/5.10.0/pod/Simple/ -> Methody.pm (source)

   1  
   2  require 5;
   3  package Pod::Simple::Methody;
   4  use strict;
   5  use Pod::Simple ();
   6  use vars qw(@ISA $VERSION);
   7  $VERSION = '2.02';
   8  @ISA = ('Pod::Simple');
   9  
  10  # Yes, we could use named variables, but I want this to be impose
  11  # as little an additional performance hit as possible.
  12  
  13  sub _handle_element_start {
  14    $_[1] =~ tr/-:./__/;
  15    ( $_[0]->can( 'start_' . $_[1] )
  16      || return
  17    )->(
  18      $_[0], $_[2]
  19    );
  20  }
  21  
  22  sub _handle_text {
  23    ( $_[0]->can( 'handle_text' )
  24      || return
  25    )->(
  26      @_
  27    );
  28  }
  29  
  30  sub _handle_element_end {
  31    $_[1] =~ tr/-:./__/;
  32    ( $_[0]->can( 'end_' . $_[1] )
  33      || return
  34    )->(
  35      $_[0]
  36    );
  37  }
  38  
  39  1;
  40  
  41  
  42  __END__
  43  
  44  =head1 NAME
  45  
  46  Pod::Simple::Methody -- turn Pod::Simple events into method calls
  47  
  48  =head1 SYNOPSIS
  49  
  50   require 5;
  51   use strict;
  52   package SomePodFormatter;
  53   use base qw(Pod::Simple::Methody);
  54   
  55   sub handle_text {
  56     my($self, $text) = @_;
  57     ...
  58   }
  59   
  60   sub start_head1 {
  61     my($self, $attrs) = @_;
  62     ...
  63   }
  64   sub end_head1 {
  65     my($self) = @_;
  66     ...
  67   }
  68   
  69  ...and start_/end_ methods for whatever other events you want to catch.
  70  
  71  =head1 DESCRIPTION
  72  
  73  This class is of
  74  interest to people writing Pod formatters based on Pod::Simple.
  75  
  76  This class (which is very small -- read the source) overrides
  77  Pod::Simple's _handle_element_start, _handle_text, and
  78  _handle_element_end methods so that parser events are turned into method
  79  calls. (Otherwise, this is a subclass of L<Pod::Simple> and inherits all
  80  its methods.)
  81  
  82  You can use this class as the base class for a Pod formatter/processor.
  83  
  84  =head1 METHOD CALLING
  85  
  86  When Pod::Simple sees a "=head1 Hi there", for example, it basically does
  87  this:
  88  
  89    $parser->_handle_element_start( "head1", \%attributes );
  90    $parser->_handle_text( "Hi there" );
  91    $parser->_handle_element_end( "head1" );
  92  
  93  But if you subclass Pod::Simple::Methody, it will instead do this
  94  when it sees a "=head1 Hi there":
  95  
  96    $parser->start_head1( \%attributes ) if $parser->can('start_head1');
  97    $parser->handle_text( "Hi there" )   if $parser->can('handle_text');
  98    $parser->end_head1()                 if $parser->can('end_head1');
  99  
 100  If Pod::Simple sends an event where the element name has a dash,
 101  period, or colon, the corresponding method name will have a underscore
 102  in its place.  For example, "foo.bar:baz" becomes start_foo_bar_baz
 103  and end_foo_bar_baz.
 104  
 105  See the source for Pod::Simple::Text for an example of using this class.
 106  
 107  =head1 SEE ALSO
 108  
 109  L<Pod::Simple>, L<Pod::Simple::Subclassing>
 110  
 111  =head1 COPYRIGHT AND DISCLAIMERS
 112  
 113  Copyright (c) 2002 Sean M. Burke.  All rights reserved.
 114  
 115  This library is free software; you can redistribute it and/or modify it
 116  under the same terms as Perl itself.
 117  
 118  This program is distributed in the hope that it will be useful, but
 119  without any warranty; without even the implied warranty of
 120  merchantability or fitness for a particular purpose.
 121  
 122  =head1 AUTHOR
 123  
 124  Sean M. Burke C<sburke@cpan.org>
 125  
 126  =cut
 127  


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1