1Pod::InputObjects(3)  User Contributed Perl Documentation Pod::InputObjects(3)
2
3
4

NAME

6       Pod::InputObjects - objects representing POD input paragraphs,
7       commands, 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
39       sections which follow.
40

Pod::Paragraph

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

Pod::InteriorSequence

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

Pod::ParseTree

212       This object corresponds to a tree of parsed POD text. As POD text is
213       scanned from left to right, it is parsed into an ordered list of text-
214       strings and Pod::InteriorSequence objects (in order of appearance). A
215       Pod::ParseTree object corresponds to this list of strings and
216       sequences. Each interior sequence in the parse-tree may itself contain
217       a parse-tree (since interior sequences may be nested).
218
219   Pod::ParseTree->new()
220               my $ptree1 = Pod::ParseTree->new;
221               my $ptree2 = new Pod::ParseTree;
222               my $ptree4 = Pod::ParseTree->new($array_ref);
223               my $ptree3 = new Pod::ParseTree($array_ref);
224
225       This is a class method that constructs a "Pod::Parse_tree" object and
226       returns a reference to the new parse-tree. If a single-argument is
227       given, it must be a reference to an array, and is used to initialize
228       the root (top) of the parse tree.
229
230   $ptree->top()
231               my $top_node = $ptree->top();
232               $ptree->top( $top_node );
233               $ptree->top( @children );
234
235       This method gets/sets the top node of the parse-tree. If no arguments
236       are given, it returns the topmost node in the tree (the root), which is
237       also a Pod::ParseTree. If it is given a single argument that is a
238       reference, then the reference is assumed to a parse-tree and becomes
239       the new top node.  Otherwise, if arguments are given, they are treated
240       as the new list of children for the top node.
241
242   $ptree->children()
243       This method gets/sets the children of the top node in the parse-tree.
244       If no arguments are given, it returns the list (array) of children
245       (each of which should be either a string or a Pod::InteriorSequence.
246       Otherwise, if arguments are given, they are treated as the new list of
247       children for the top node.
248
249   $ptree->prepend()
250       This method prepends the given text or parse-tree to the current parse-
251       tree.  If the first item on the parse-tree is text and the argument is
252       also text, then the text is prepended to the first item (not added as a
253       separate string).  Otherwise the argument is added as a new string or
254       parse-tree before the current one.
255
256   $ptree->append()
257       This method appends the given text or parse-tree to the current parse-
258       tree.  If the last item on the parse-tree is text and the argument is
259       also text, then the text is appended to the last item (not added as a
260       separate string).  Otherwise the argument is added as a new string or
261       parse-tree after the current one.
262
263   $ptree->raw_text()
264               my $ptree_raw_text = $ptree->raw_text();
265
266       This method will return the raw text of the POD parse-tree exactly as
267       it appeared in the input.
268
269   Pod::ParseTree::DESTROY()
270       This method performs any necessary cleanup for the parse-tree.  If you
271       override this method then it is imperative that you invoke the parent
272       method from within your own method, otherwise parse-tree storage will
273       not be reclaimed upon destruction!
274

SEE ALSO

276       Pod::InputObjects is part of the Pod::Parser distribution.
277
278       See Pod::Parser, Pod::Select
279

AUTHOR

281       Please report bugs using <http://rt.cpan.org>.
282
283       Brad Appleton <bradapp@enteract.com>
284
285
286
287perl v5.16.3                      2013-06-01              Pod::InputObjects(3)
Impressum