1Pod::InputObjects(3pm) Perl Programmers Reference Guide Pod::InputObjects(3pm)
2
3
4

NAME

6       Pod::InputObjects - objects representing POD input paragraphs, com‐
7       mands, etc.
8

SYNOPSIS

10           use Pod::InputObjects;
11

REQUIRES

13       perl5.004, Carp
14

EXPORTS

16       Nothing.
17

DESCRIPTION

19       This module defines some basic input objects used by Pod::Parser when
20       reading and parsing POD text from an input source. The following
21       objects are defined:
22
23       package Pod::Paragraph
24           An object corresponding to a paragraph of POD input text. It may be
25           a plain paragraph, a verbatim paragraph, or a command paragraph
26           (see perlpod).
27
28       package Pod::InteriorSequence
29           An object corresponding to an interior sequence command from the
30           POD input text (see perlpod).
31
32       package Pod::ParseTree
33           An object corresponding to a tree of parsed POD text. Each "node"
34           in a parse-tree (or ptree) is either a text-string or a reference
35           to a Pod::InteriorSequence object. The nodes appear in the parse-
36           tree in the order in which they were parsed from left-to-right.
37
38       Each of these input objects are described in further detail in the sec‐
39       tions which follow.
40

Pod::Paragraph

42       An object representing a paragraph of POD input text.  It has the fol‐
43       lowing methods/attributes:
44
45       Pod::Paragraph->new()
46
47               my $pod_para1 = Pod::Paragraph->new(-text => $text);
48               my $pod_para2 = Pod::Paragraph->new(-name => $cmd,
49                                                   -text => $text);
50               my $pod_para3 = new Pod::Paragraph(-text => $text);
51               my $pod_para4 = new Pod::Paragraph(-name => $cmd,
52                                                  -text => $text);
53               my $pod_para5 = Pod::Paragraph->new(-name => $cmd,
54                                                   -text => $text,
55                                                   -file => $filename,
56                                                   -line => $line_number);
57
58       This is a class method that constructs a "Pod::Paragraph" object and
59       returns a reference to the new paragraph object. It may be given one or
60       two keyword arguments. The "-text" keyword indicates the corresponding
61       text of the POD paragraph. The "-name" keyword indicates the name of
62       the corresponding POD command, such as "head1" or "item" (it should not
63       contain the "=" prefix); this is needed only if the POD paragraph cor‐
64       responds to a command paragraph. The "-file" and "-line" keywords indi‐
65       cate the filename and line number corresponding to the beginning of the
66       paragraph
67
68       $pod_para->cmd_name()
69
70               my $para_cmd = $pod_para->cmd_name();
71
72       If this paragraph is a command paragraph, then this method will return
73       the name of the command (without any leading "=" prefix).
74
75       $pod_para->text()
76
77               my $para_text = $pod_para->text();
78
79       This method will return the corresponding text of the paragraph.
80
81       $pod_para->raw_text()
82
83               my $raw_pod_para = $pod_para->raw_text();
84
85       This method will return the raw text of the POD paragraph, exactly as
86       it appeared in the input.
87
88       $pod_para->cmd_prefix()
89
90               my $prefix = $pod_para->cmd_prefix();
91
92       If this paragraph is a command paragraph, then this method will return
93       the prefix used to denote the command (which should be the string "="
94       or "==").
95
96       $pod_para->cmd_separator()
97
98               my $separator = $pod_para->cmd_separator();
99
100       If this paragraph is a command paragraph, then this method will return
101       the text used to separate the command name from the rest of the para‐
102       graph (if any).
103
104       $pod_para->parse_tree()
105
106               my $ptree = $pod_parser->parse_text( $pod_para->text() );
107               $pod_para->parse_tree( $ptree );
108               $ptree = $pod_para->parse_tree();
109
110       This method will get/set the corresponding parse-tree of the para‐
111       graph's text.
112
113       $pod_para->file_line()
114
115               my ($filename, $line_number) = $pod_para->file_line();
116               my $position = $pod_para->file_line();
117
118       Returns the current filename and line number for the paragraph object.
119       If called in a list context, it returns a list of two elements: first
120       the filename, then the line number. If called in a scalar context, it
121       returns a string containing the filename, followed by a colon (':'),
122       followed by the line number.
123

Pod::InteriorSequence

125       An object representing a POD interior sequence command.  It has the
126       following methods/attributes:
127
128       Pod::InteriorSequence->new()
129
130               my $pod_seq1 = Pod::InteriorSequence->new(-name => $cmd
131                                                         -ldelim => $delimiter);
132               my $pod_seq2 = new Pod::InteriorSequence(-name => $cmd,
133                                                        -ldelim => $delimiter);
134               my $pod_seq3 = new Pod::InteriorSequence(-name => $cmd,
135                                                        -ldelim => $delimiter,
136                                                        -file => $filename,
137                                                        -line => $line_number);
138
139               my $pod_seq4 = new Pod::InteriorSequence(-name => $cmd, $ptree);
140               my $pod_seq5 = new Pod::InteriorSequence($cmd, $ptree);
141
142       This is a class method that constructs a "Pod::InteriorSequence" object
143       and returns a reference to the new interior sequence object. It should
144       be given two keyword arguments.  The "-ldelim" keyword indicates the
145       corresponding left-delimiter of the interior sequence (e.g. '<').  The
146       "-name" keyword indicates the name of the corresponding interior
147       sequence command, such as "I" or "B" or "C". The "-file" and "-line"
148       keywords indicate the filename and line number corresponding to the
149       beginning of the interior sequence. If the $ptree argument is given, it
150       must be the last argument, and it must be either string, or else an
151       array-ref suitable for passing to Pod::ParseTree::new (or it may be a
152       reference to a Pod::ParseTree object).
153
154       $pod_seq->cmd_name()
155
156               my $seq_cmd = $pod_seq->cmd_name();
157
158       The name of the interior sequence command.
159
160       $pod_seq->prepend()
161
162               $pod_seq->prepend($text);
163               $pod_seq1->prepend($pod_seq2);
164
165       Prepends the given string or parse-tree or sequence object to the
166       parse-tree of this interior sequence.
167
168       $pod_seq->append()
169
170               $pod_seq->append($text);
171               $pod_seq1->append($pod_seq2);
172
173       Appends the given string or parse-tree or sequence object to the parse-
174       tree of this interior sequence.
175
176       $pod_seq->nested()
177
178               $outer_seq = $pod_seq->nested ⎪⎪ print "not nested";
179
180       If this interior sequence is nested inside of another interior
181       sequence, then the outer/parent sequence that contains it is returned.
182       Otherwise "undef" is returned.
183
184       $pod_seq->raw_text()
185
186               my $seq_raw_text = $pod_seq->raw_text();
187
188       This method will return the raw text of the POD interior sequence,
189       exactly as it appeared in the input.
190
191       $pod_seq->left_delimiter()
192
193               my $ldelim = $pod_seq->left_delimiter();
194
195       The leftmost delimiter beginning the argument text to the interior
196       sequence (should be "<").
197
198       $pod_seq->right_delimiter()
199
200       The rightmost delimiter beginning the argument text to the interior
201       sequence (should be ">").
202
203       $pod_seq->parse_tree()
204
205               my $ptree = $pod_parser->parse_text($paragraph_text);
206               $pod_seq->parse_tree( $ptree );
207               $ptree = $pod_seq->parse_tree();
208
209       This method will get/set the corresponding parse-tree of the interior
210       sequence's text.
211
212       $pod_seq->file_line()
213
214               my ($filename, $line_number) = $pod_seq->file_line();
215               my $position = $pod_seq->file_line();
216
217       Returns the current filename and line number for the interior sequence
218       object.  If called in a list context, it returns a list of two ele‐
219       ments: first the filename, then the line number. If called in a scalar
220       context, it returns a string containing the filename, followed by a
221       colon (':'), followed by the line number.
222
223       Pod::InteriorSequence::DESTROY()
224
225       This method performs any necessary cleanup for the interior-sequence.
226       If you override this method then it is imperative that you invoke the
227       parent method from within your own method, otherwise interior-sequence
228       storage will not be reclaimed upon destruction!
229

Pod::ParseTree

231       This object corresponds to a tree of parsed POD text. As POD text is
232       scanned from left to right, it is parsed into an ordered list of text-
233       strings and Pod::InteriorSequence objects (in order of appearance). A
234       Pod::ParseTree object corresponds to this list of strings and
235       sequences. Each interior sequence in the parse-tree may itself contain
236       a parse-tree (since interior sequences may be nested).
237
238       Pod::ParseTree->new()
239
240               my $ptree1 = Pod::ParseTree->new;
241               my $ptree2 = new Pod::ParseTree;
242               my $ptree4 = Pod::ParseTree->new($array_ref);
243               my $ptree3 = new Pod::ParseTree($array_ref);
244
245       This is a class method that constructs a "Pod::Parse_tree" object and
246       returns a reference to the new parse-tree. If a single-argument is
247       given, it must be a reference to an array, and is used to initialize
248       the root (top) of the parse tree.
249
250       $ptree->top()
251
252               my $top_node = $ptree->top();
253               $ptree->top( $top_node );
254               $ptree->top( @children );
255
256       This method gets/sets the top node of the parse-tree. If no arguments
257       are given, it returns the topmost node in the tree (the root), which is
258       also a Pod::ParseTree. If it is given a single argument that is a ref‐
259       erence, then the reference is assumed to a parse-tree and becomes the
260       new top node.  Otherwise, if arguments are given, they are treated as
261       the new list of children for the top node.
262
263       $ptree->children()
264
265       This method gets/sets the children of the top node in the parse-tree.
266       If no arguments are given, it returns the list (array) of children
267       (each of which should be either a string or a Pod::InteriorSequence.
268       Otherwise, if arguments are given, they are treated as the new list of
269       children for the top node.
270
271       $ptree->prepend()
272
273       This method prepends the given text or parse-tree to the current
274       parse-tree.  If the first item on the parse-tree is text and the argu‐
275       ment is also text, then the text is prepended to the first item (not
276       added as a separate string).  Otherwise the argument is added as a new
277       string or parse-tree before the current one.
278
279       $ptree->append()
280
281       This method appends the given text or parse-tree to the current
282       parse-tree.  If the last item on the parse-tree is text and the argu‐
283       ment is also text, then the text is appended to the last item (not
284       added as a separate string).  Otherwise the argument is added as a new
285       string or parse-tree after the current one.
286
287       $ptree->raw_text()
288
289               my $ptree_raw_text = $ptree->raw_text();
290
291       This method will return the raw text of the POD parse-tree exactly as
292       it appeared in the input.
293
294       Pod::ParseTree::DESTROY()
295
296       This method performs any necessary cleanup for the parse-tree.  If you
297       override this method then it is imperative that you invoke the parent
298       method from within your own method, otherwise parse-tree storage will
299       not be reclaimed upon destruction!
300

SEE ALSO

302       See Pod::Parser, Pod::Select
303

AUTHOR

305       Please report bugs using <http://rt.cpan.org>.
306
307       Brad Appleton <bradapp@enteract.com>
308
309
310
311perl v5.8.8                       2001-09-21            Pod::InputObjects(3pm)
Impressum