[ 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/ -> Checker.pm (source)

   1  
   2  # A quite dimwitted pod2plaintext that need only know how to format whatever
   3  # text comes out of Pod::BlackBox's _gen_errata
   4  
   5  require 5;
   6  package Pod::Simple::Checker;
   7  use strict;
   8  use Carp ();
   9  use Pod::Simple::Methody ();
  10  use Pod::Simple ();
  11  use vars qw( @ISA $VERSION );
  12  $VERSION = '2.02';
  13  @ISA = ('Pod::Simple::Methody');
  14  BEGIN { *DEBUG = defined(&Pod::Simple::DEBUG)
  15            ? \&Pod::Simple::DEBUG
  16            : sub() {0}
  17        }
  18  
  19  use Text::Wrap 98.112902 (); # was 2001.0131, but I don't think we need that
  20  $Text::Wrap::wrap = 'overflow';
  21  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22  
  23  sub any_errata_seen {  # read-only accessor
  24    return $_[1]->{'Errata_seen'};
  25  }
  26  
  27  sub new {
  28    my $self = shift;
  29    my $new = $self->SUPER::new(@_);
  30    $new->{'output_fh'} ||= *STDOUT{IO};
  31    $new->nix_X_codes(1);
  32    $new->nbsp_for_S(1);
  33    $new->{'Thispara'} = '';
  34    $new->{'Indent'} = 0;
  35    $new->{'Indentstring'} = '   ';
  36    $new->{'Errata_seen'} = 0;
  37    return $new;
  38  }
  39  
  40  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  41  
  42  sub handle_text {  $_[0]{'Errata_seen'} and $_[0]{'Thispara'} .= $_[1] }
  43  
  44  sub start_Para  {  $_[0]{'Thispara'} = '' }
  45  
  46  sub start_head1 {
  47    if($_[0]{'Errata_seen'}) {
  48      $_[0]{'Thispara'} = '';
  49    } else {
  50      if($_[1]{'errata'}) { # start of errata!
  51        $_[0]{'Errata_seen'} = 1;
  52        $_[0]{'Thispara'} = $_[0]{'source_filename'} ?
  53          "$_[0]{'source_filename'} -- " : ''
  54      }
  55    }
  56  }
  57  sub start_head2 {  $_[0]{'Thispara'} = '' }
  58  sub start_head3 {  $_[0]{'Thispara'} = '' }
  59  sub start_head4 {  $_[0]{'Thispara'} = '' }
  60  
  61  sub start_Verbatim    { $_[0]{'Thispara'} = ''   }
  62  sub start_item_bullet { $_[0]{'Thispara'} = '* ' }
  63  sub start_item_number { $_[0]{'Thispara'} = "$_[1]{'number'}. "  }
  64  sub start_item_text   { $_[0]{'Thispara'} = ''   }
  65  
  66  sub start_over_bullet  { ++$_[0]{'Indent'} }
  67  sub start_over_number  { ++$_[0]{'Indent'} }
  68  sub start_over_text    { ++$_[0]{'Indent'} }
  69  sub start_over_block   { ++$_[0]{'Indent'} }
  70  
  71  sub   end_over_bullet  { --$_[0]{'Indent'} }
  72  sub   end_over_number  { --$_[0]{'Indent'} }
  73  sub   end_over_text    { --$_[0]{'Indent'} }
  74  sub   end_over_block   { --$_[0]{'Indent'} }
  75  
  76  
  77  # . . . . . Now the actual formatters:
  78  
  79  sub end_head1       { $_[0]->emit_par(-4) }
  80  sub end_head2       { $_[0]->emit_par(-3) }
  81  sub end_head3       { $_[0]->emit_par(-2) }
  82  sub end_head4       { $_[0]->emit_par(-1) }
  83  sub end_Para        { $_[0]->emit_par( 0) }
  84  sub end_item_bullet { $_[0]->emit_par( 0) }
  85  sub end_item_number { $_[0]->emit_par( 0) }
  86  sub end_item_text   { $_[0]->emit_par(-2) }
  87  
  88  sub emit_par {
  89    return unless $_[0]{'Errata_seen'};
  90    my($self, $tweak_indent) = splice(@_,0,2);
  91    my $indent = ' ' x ( 2 * $self->{'Indent'} + ($tweak_indent||0) );
  92     # Yes, 'STRING' x NEGATIVE gives '', same as 'STRING' x 0
  93  
  94    $self->{'Thispara'} =~ tr{\xAD}{}d if Pod::Simple::ASCII;
  95    my $out = Text::Wrap::wrap($indent, $indent, $self->{'Thispara'} .= "\n");
  96    $out =~ tr{\xA0}{ } if Pod::Simple::ASCII;
  97    print {$self->{'output_fh'}} $out,
  98      #"\n"
  99    ;
 100    $self->{'Thispara'} = '';
 101    
 102    return;
 103  }
 104  
 105  # . . . . . . . . . . And then off by its lonesome:
 106  
 107  sub end_Verbatim  {
 108    return unless $_[0]{'Errata_seen'};
 109    my $self = shift;
 110    if(Pod::Simple::ASCII) {
 111      $self->{'Thispara'} =~ tr{\xA0}{ };
 112      $self->{'Thispara'} =~ tr{\xAD}{}d;
 113    }
 114  
 115    my $i = ' ' x ( 2 * $self->{'Indent'} + 4);
 116    
 117    $self->{'Thispara'} =~ s/^/$i/mg;
 118    
 119    print { $self->{'output_fh'} }   '', 
 120      $self->{'Thispara'},
 121      "\n\n"
 122    ;
 123    $self->{'Thispara'} = '';
 124    return;
 125  }
 126  
 127  #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 128  1;
 129  
 130  __END__
 131  
 132  =head1 NAME
 133  
 134  Pod::Simple::Checker -- check the Pod syntax of a document
 135  
 136  =head1 SYNOPSIS
 137  
 138    perl -MPod::Simple::Checker -e \
 139     "exit Pod::Simple::Checker->filter(shift)->any_errata_seen" \
 140     thingy.pod
 141  
 142  =head1 DESCRIPTION
 143  
 144  This class is for checking the syntactic validity of Pod.
 145  It works by basically acting like a simple-minded version of
 146  L<Pod::Simple::Text> that formats only the "Pod Errors" section
 147  (if Pod::Simple even generates one for the given document).
 148  
 149  This is a subclass of L<Pod::Simple> and inherits all its methods.
 150  
 151  =head1 SEE ALSO
 152  
 153  L<Pod::Simple>, L<Pod::Simple::Text>, L<Pod::Checker>
 154  
 155  =head1 COPYRIGHT AND DISCLAIMERS
 156  
 157  Copyright (c) 2002 Sean M. Burke.  All rights reserved.
 158  
 159  This library is free software; you can redistribute it and/or modify it
 160  under the same terms as Perl itself.
 161  
 162  This program is distributed in the hope that it will be useful, but
 163  without any warranty; without even the implied warranty of
 164  merchantability or fitness for a particular purpose.
 165  
 166  =head1 AUTHOR
 167  
 168  Sean M. Burke C<sburke@cpan.org>
 169  
 170  =cut
 171  


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