| 1 | package Pod::Index::Entry; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | $VERSION = '0.14'; | |||||||||
| 5 | |||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use Pod::Index::Extract; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 29 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 11 | 29 | my ($class, %args) = @_; | |||||||||
| 12 | 29 | my $self = bless { | |||||||||
| 13 | %args, | ||||||||||
| 14 | }, $class; | ||||||||||
| 15 | 29 | return $self; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub podname { shift->{podname} } | ||||||||
|
Subroutine
podname: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 19 | 6 | ▶ | sub line { shift->{line} } | ||||||||
|
Subroutine
line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 12 | ▶ | sub filename { shift->{filename} } | ||||||||
|
Subroutine
filename: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 21 | 0 | ▶ | sub context { shift->{context} } | ||||||||
|
Subroutine
context: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 0 | ▶ | sub keyword { shift->{keyword} } | ||||||||
|
Subroutine
keyword: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 23 | |||||||||||
| 24 | 6 | ▶ | sub pod { | ||||||||
|
Subroutine
pod: called CC=5 SCAR=16.5
Pod
documented
| |||||||||||
| 25 | 6 | my ($self) = @_; | |||||||||
| 26 | |||||||||||
| 27 | 6 | ▶ | return $self->{pod} if defined $self->{pod}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | |||||||||||
| 29 | 6 | my $filename = $self->filename; | |||||||||
| 30 | |||||||||||
| 31 | 6 | ▶ | open my $in, "<", $filename or die "couldn't open $filename $!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 6 | ▶ | open my $out, ">", \(my $pod) or die "couldn't open output fh: $!\n"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | |||||||||||
| 34 | 6 | my $parser = Pod::Index::Extract->new( | |||||||||
| 35 | ppi_entry => $self, | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 6 | <$in> for (1 .. $self->{line} - 1); # skip lines | |||||||||
| 39 | 6 | $parser->parse_from_filehandle($in, $out); | |||||||||
| 40 | |||||||||||
| 41 | 6 | return $self->{pod} = $pod; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 4 | 1; | |||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | =head1 NAME | ||||||||||
| 48 | |||||||||||
| 49 | Pod::Index::Entry - Represents Pod search result | ||||||||||
| 50 | |||||||||||
| 51 | =head1 SYNOPSIS | ||||||||||
| 52 | |||||||||||
| 53 | use Pod::Index::Entry; | ||||||||||
| 54 | |||||||||||
| 55 | my $entry = Pod::Index::Entry->new( | ||||||||||
| 56 | keyword => 'constructors', | ||||||||||
| 57 | podname => 'perlobj', | ||||||||||
| 58 | line => 42, | ||||||||||
| 59 | filename => '/usr/lib/perl5/5.8.7/pod/perlobj.pod', | ||||||||||
| 60 | context => 'Using POD', | ||||||||||
| 61 | ); | ||||||||||
| 62 | |||||||||||
| 63 | # trivial accessors | ||||||||||
| 64 | my $podname = $entry->podname; | ||||||||||
| 65 | my $filename = $entry->filename; | ||||||||||
| 66 | my $line = $entry->line; | ||||||||||
| 67 | my $context = $entry->context; | ||||||||||
| 68 | my $keyword = $entry->keyword; | ||||||||||
| 69 | |||||||||||
| 70 | # extract the POD for this entry | ||||||||||
| 71 | my $pod = $entry->pod; | ||||||||||
| 72 | |||||||||||
| 73 | =head1 DESCRIPTION | ||||||||||
| 74 | |||||||||||
| 75 | This class represents a POD index entry. An entry is defined by the | ||||||||||
| 76 | podname/filename, line number, and context. The entry object also has the | ||||||||||
| 77 | ability to extract the POD "scope" from the filename. | ||||||||||
| 78 | |||||||||||
| 79 | =head1 METHODS | ||||||||||
| 80 | |||||||||||
| 81 | =over | ||||||||||
| 82 | |||||||||||
| 83 | =item new | ||||||||||
| 84 | |||||||||||
| 85 | my $q = Pod::Index::Entry->new(%args); | ||||||||||
| 86 | |||||||||||
| 87 | Create a new search object. Possible arguments are: | ||||||||||
| 88 | |||||||||||
| 89 | =over | ||||||||||
| 90 | |||||||||||
| 91 | =item podname | ||||||||||
| 92 | |||||||||||
| 93 | The name of the pod, such as X<Data::Dumper>. | ||||||||||
| 94 | |||||||||||
| 95 | =item filename | ||||||||||
| 96 | |||||||||||
| 97 | The filename for the pod, such as F<Data/Dumper.pm>. | ||||||||||
| 98 | |||||||||||
| 99 | =item line | ||||||||||
| 100 | |||||||||||
| 101 | The line number where the scope of this entry begins. | ||||||||||
| 102 | |||||||||||
| 103 | =item context | ||||||||||
| 104 | |||||||||||
| 105 | The title of the section that contains this entry. | ||||||||||
| 106 | |||||||||||
| 107 | =back | ||||||||||
| 108 | |||||||||||
| 109 | =item podname | ||||||||||
| 110 | |||||||||||
| 111 | =item filename | ||||||||||
| 112 | |||||||||||
| 113 | =item line | ||||||||||
| 114 | |||||||||||
| 115 | =item context | ||||||||||
| 116 | |||||||||||
| 117 | These are just simple accessors that return the value of these properties, | ||||||||||
| 118 | as given to the constructor. | ||||||||||
| 119 | |||||||||||
| 120 | =item pod | ||||||||||
| 121 | |||||||||||
| 122 | Extracts the POD for the scope of the entry from $self->filename, beginning at | ||||||||||
| 123 | $self->line. For a definition of I<scope>, see L<Pod::Index>. The POD | ||||||||||
| 124 | extraction is delegated to the L<Pod::Index::Extract> module. | ||||||||||
| 125 | |||||||||||
| 126 | =back | ||||||||||
| 127 | |||||||||||
| 128 | =head1 VERSION | ||||||||||
| 129 | |||||||||||
| 130 | 0.14 | ||||||||||
| 131 | |||||||||||
| 132 | =head1 SEE ALSO | ||||||||||
| 133 | |||||||||||
| 134 | L<Pod::Index>, | ||||||||||
| 135 | L<Pod::Index::Search>, | ||||||||||
| 136 | L<Pod::Index::Extract> | ||||||||||
| 137 | |||||||||||
| 138 | =head1 AUTHOR | ||||||||||
| 139 | |||||||||||
| 140 | Ivan Tubert-Brohman E<lt>itub@cpan.orgE<gt> | ||||||||||
| 141 | |||||||||||
| 142 | =head1 COPYRIGHT | ||||||||||
| 143 | |||||||||||
| 144 | Copyright (c) 2005 Ivan Tubert-Brohman. All rights reserved. This program is | ||||||||||
| 145 | free software; you can redistribute it and/or modify it under the same terms as | ||||||||||
| 146 | Perl itself. | ||||||||||
| 147 | |||||||||||
| 148 | =cut | ||||||||||
| 149 | |||||||||||
| 150 | |||||||||||
| 151 | |||||||||||