File: PodDESCRIPTIONParser.pm

package info (click to toggle)
libvcp-perl 0.9-20050110-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,608 kB
  • ctags: 827
  • sloc: perl: 18,194; makefile: 42; sh: 11
file content (98 lines) | stat: -rw-r--r-- 2,034 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package VCP::PodDESCRIPTIONParser;

=head1 NAME

VCP::PodDESCRIPTIONParser - Parse DESCRIPTION sections from a set of source files.

=head1 SYNOPSIS

   use VCP::PodDESCRIPTIONParser;
   my $p = VCP::PodDESCRIPTIONParser->new;
   my $options_hash = $p->parse( @packages_or_filenames );

=head1 DESCRIPTION

Returns a hash of all C<=item>s found in all DESCRIPTION sections in the
given filenames.  Warns if duplicate options are found.

ASSUMES ALL PACKAGES REFERRED TO ARE ALREADY LOADED.  %INC is used to
locate their source code.

Converts packages (any string matching /\w[:\w]+/) to filenames.

=cut

$VERSION = 0.1 ;

use Pod::Text;
@ISA = qw( Pod::Text );

use strict;

use VCP::Logger qw( BUG );

sub verbatim {
   my $self = shift;
   my ( $paragraph ) = @_;

   1 while chomp $paragraph;
   push @{$self->{Paragraphs}}, $paragraph;
}

sub textblock {
   my $self = shift;
   my ( $paragraph, $line ) = @_;

   $paragraph =~ s/\s+/ /g;
   $paragraph =~ s/\A\s+//g;
   $paragraph =~ s/\s+\z//g;

   push @{$self->{Paragraphs}}, $self->interpolate( $paragraph, $line );
}

sub command {
   my $self = shift;
   my ( $command, $paragraph, $line ) = @_;

   return if $command eq "head1";  ## The reader already
                                   ## knows it's a DESCRIPTION

   $paragraph =~ s/\s+/ /g;
   $paragraph =~ s/\A\s+//g;
   $paragraph =~ s/\s+\z//g;

   $paragraph .= "\n" . "=" x length $paragraph;
   push @{$self->{Paragraphs}}, $self->interpolate( $paragraph, $line );
}


sub parse {
   my $self = shift;
   $self = $self->new unless ref $self;
   my ( $fn ) = @_;

   $self->select( "DESCRIPTION" );

   $self->{Paragraphs} = [];


   $self->parse_from_file( $fn );

   return $self->{Paragraphs};
}

=head1 COPYRIGHT

Copyright 2000, Perforce Software, Inc.  All Rights Reserved.

This module and the VCP package are licensed according to the terms given in
the file LICENSE accompanying this distribution, a copy of which is included in
L<vcp>.

=head1 AUTHOR

Barrie Slaymaker <barries@slaysys.com>

=cut

1