1Pod::Checker(3pm) Perl Programmers Reference Guide Pod::Checker(3pm)
2
3
4
6 Pod::Checker, podchecker() - check pod documents for syntax errors
7
9 use Pod::Checker;
10
11 $syntax_okay = podchecker($filepath, $outputpath, %options);
12
13 my $checker = new Pod::Checker %options;
14 $checker->parse_from_file($filepath, \*STDERR);
15
17 $filepath is the input POD to read and $outputpath is where to write
18 POD syntax error messages. Either argument may be a scalar indicating a
19 file-path, or else a reference to an open filehandle. If unspecified,
20 the input-file it defaults to "\*STDIN", and the output-file defaults
21 to "\*STDERR".
22
23 podchecker()
24 This function can take a hash of options:
25
26 -warnings => val
27 Turn warnings on/off. val is usually 1 for on, but higher values
28 trigger additional warnings. See "Warnings".
29
31 podchecker will perform syntax checking of Perl5 POD format
32 documentation.
33
34 Curious/ambitious users are welcome to propose additional features they
35 wish to see in Pod::Checker and podchecker and verify that the checks
36 are consistent with perlpod.
37
38 The following checks are currently performed:
39
40 · Unknown '=xxxx' commands, unknown 'X<...>' interior-sequences, and
41 unterminated interior sequences.
42
43 · Check for proper balancing of "=begin" and "=end". The contents of
44 such a block are generally ignored, i.e. no syntax checks are
45 performed.
46
47 · Check for proper nesting and balancing of "=over", "=item" and
48 "=back".
49
50 · Check for same nested interior-sequences (e.g. "L<...L<...>...>").
51
52 · Check for malformed or non-existing entities "E<...>".
53
54 · Check for correct syntax of hyperlinks "L<...>". See perlpod for
55 details.
56
57 · Check for unresolved document-internal links. This check may also
58 reveal misspelled links that seem to be internal links but should
59 be links to something else.
60
62 Errors
63 · empty =headn
64
65 A heading ("=head1" or "=head2") without any text? That ain't no
66 heading!
67
68 · =over on line N without closing =back
69
70 The "=over" command does not have a corresponding "=back" before
71 the next heading ("=head1" or "=head2") or the end of the file.
72
73 · =item without previous =over
74
75 · =back without previous =over
76
77 An "=item" or "=back" command has been found outside a
78 "=over"/"=back" block.
79
80 · No argument for =begin
81
82 A "=begin" command was found that is not followed by the formatter
83 specification.
84
85 · =end without =begin
86
87 A standalone "=end" command was found.
88
89 · Nested =begin's
90
91 There were at least two consecutive "=begin" commands without the
92 corresponding "=end". Only one "=begin" may be active at a time.
93
94 · =for without formatter specification
95
96 There is no specification of the formatter after the "=for"
97 command.
98
99 · unresolved internal link NAME
100
101 The given link to NAME does not have a matching node in the current
102 POD. This also happened when a single word node name is not
103 enclosed in "".
104
105 · Unknown command "CMD"
106
107 An invalid POD command has been found. Valid are "=head1",
108 "=head2", "=head3", "=head4", "=over", "=item", "=back", "=begin",
109 "=end", "=for", "=pod", "=cut"
110
111 · Unknown interior-sequence "SEQ"
112
113 An invalid markup command has been encountered. Valid are: "B<>",
114 "C<>", "E<>", "F<>", "I<>", "L<>", "S<>", "X<>", "Z<>"
115
116 · nested commands CMD<...CMD<...>...>
117
118 Two nested identical markup commands have been found. Generally
119 this does not make sense.
120
121 · garbled entity STRING
122
123 The STRING found cannot be interpreted as a character entity.
124
125 · Entity number out of range
126
127 An entity specified by number (dec, hex, oct) is out of range
128 (1-255).
129
130 · malformed link L<>
131
132 The link found cannot be parsed because it does not conform to the
133 syntax described in perlpod.
134
135 · nonempty Z<>
136
137 The "Z<>" sequence is supposed to be empty.
138
139 · empty X<>
140
141 The index entry specified contains nothing but whitespace.
142
143 · Spurious text after =pod / =cut
144
145 The commands "=pod" and "=cut" do not take any arguments.
146
147 · Spurious character(s) after =back
148
149 The "=back" command does not take any arguments.
150
151 Warnings
152 These may not necessarily cause trouble, but indicate mediocre style.
153
154 · multiple occurrence of link target name
155
156 The POD file has some "=item" and/or "=head" commands that have the
157 same text. Potential hyperlinks to such a text cannot be unique
158 then. This warning is printed only with warning level greater than
159 one.
160
161 · line containing nothing but whitespace in paragraph
162
163 There is some whitespace on a seemingly empty line. POD is very
164 sensitive to such things, so this is flagged. vi users switch on
165 the list option to avoid this problem.
166
167 · previous =item has no contents
168
169 There is a list "=item" right above the flagged line that has no
170 text contents. You probably want to delete empty items.
171
172 · preceding non-item paragraph(s)
173
174 A list introduced by "=over" starts with a text or verbatim
175 paragraph, but continues with "=item"s. Move the non-item paragraph
176 out of the "=over"/"=back" block.
177
178 · =item type mismatch (one vs. two)
179
180 A list started with e.g. a bullet-like "=item" and continued with a
181 numbered one. This is obviously inconsistent. For most translators
182 the type of the first "=item" determines the type of the list.
183
184 · N unescaped "<>" in paragraph
185
186 Angle brackets not written as "<lt>" and "<gt>" can potentially
187 cause errors as they could be misinterpreted as markup commands.
188 This is only printed when the -warnings level is greater than 1.
189
190 · Unknown entity
191
192 A character entity was found that does not belong to the standard
193 ISO set or the POD specials "verbar" and "sol".
194
195 · No items in =over
196
197 The list opened with "=over" does not contain any items.
198
199 · No argument for =item
200
201 "=item" without any parameters is deprecated. It should either be
202 followed by "*" to indicate an unordered list, by a number
203 (optionally followed by a dot) to indicate an ordered (numbered)
204 list or simple text for a definition list.
205
206 · empty section in previous paragraph
207
208 The previous section (introduced by a "=head" command) does not
209 contain any text. This usually indicates that something is missing.
210 Note: A "=head1" followed immediately by "=head2" does not trigger
211 this warning.
212
213 · Verbatim paragraph in NAME section
214
215 The NAME section ("=head1 NAME") should consist of a single
216 paragraph with the script/module name, followed by a dash `-' and a
217 very short description of what the thing is good for.
218
219 · =headn without preceding higher level
220
221 For example if there is a "=head2" in the POD file prior to a
222 "=head1".
223
224 Hyperlinks
225 There are some warnings with respect to malformed hyperlinks:
226
227 · ignoring leading/trailing whitespace in link
228
229 There is whitespace at the beginning or the end of the contents of
230 L<...>.
231
232 · (section) in '$page' deprecated
233
234 There is a section detected in the page name of L<...>, e.g.
235 "L<passwd(2)>". POD hyperlinks may point to POD documents only.
236 Please write "C<passwd(2)>" instead. Some formatters are able to
237 expand this to appropriate code. For links to (builtin) functions,
238 please say "L<perlfunc/mkdir>", without ().
239
240 · alternative text/node '%s' contains non-escaped | or /
241
242 The characters "|" and "/" are special in the L<...> context.
243 Although the hyperlink parser does its best to determine which "/"
244 is text and which is a delimiter in case of doubt, one ought to
245 escape these literal characters like this:
246
247 / E<sol>
248 | E<verbar>
249
251 podchecker returns the number of POD syntax errors found or -1 if there
252 were no POD commands at all found in the file.
253
255 See "SYNOPSIS"
256
258 While checking, this module collects document properties, e.g. the
259 nodes for hyperlinks ("=headX", "=item") and index entries ("X<>").
260 POD translators can use this feature to syntax-check and get the nodes
261 in a first pass before actually starting to convert. This is expensive
262 in terms of execution time, but allows for very robust conversions.
263
264 Since PodParser-1.24 the Pod::Checker module uses only the poderror
265 method to print errors and warnings. The summary output (e.g. "Pod
266 syntax OK") has been dropped from the module and has been included in
267 podchecker (the script). This allows users of Pod::Checker to control
268 completely the output behavior. Users of podchecker (the script) get
269 the well-known behavior.
270
271 "Pod::Checker->new( %options )"
272 Return a reference to a new Pod::Checker object that inherits from
273 Pod::Parser and is used for calling the required methods later. The
274 following options are recognized:
275
276 "-warnings => num"
277 Print warnings if "num" is true. The higher the value of "num",
278 the more warnings are printed. Currently there are only levels 1
279 and 2.
280
281 "-quiet => num"
282 If "num" is true, do not print any errors/warnings. This is
283 useful when Pod::Checker is used to munge POD code into plain text
284 from within POD formatters.
285
286 "$checker->poderror( @args )"
287 "$checker->poderror( {%opts}, @args )"
288 Internal method for printing errors and warnings. If no options are
289 given, simply prints "@_". The following options are recognized and
290 used to form the output:
291
292 -msg
293
294 A message to print prior to @args.
295
296 -line
297
298 The line number the error occurred in.
299
300 -file
301
302 The file (name) the error occurred in.
303
304 -severity
305
306 The error level, should be 'WARNING' or 'ERROR'.
307
308 "$checker->num_errors()"
309 Set (if argument specified) and retrieve the number of errors
310 found.
311
312 "$checker->num_warnings()"
313 Set (if argument specified) and retrieve the number of warnings
314 found.
315
316 "$checker->name()"
317 Set (if argument specified) and retrieve the canonical name of POD
318 as found in the "=head1 NAME" section.
319
320 "$checker->node()"
321 Add (if argument specified) and retrieve the nodes (as defined by
322 "=headX" and "=item") of the current POD. The nodes are returned in
323 the order of their occurrence. They consist of plain text, each
324 piece of whitespace is collapsed to a single blank.
325
326 "$checker->idx()"
327 Add (if argument specified) and retrieve the index entries (as
328 defined by "X<>") of the current POD. They consist of plain text,
329 each piece of whitespace is collapsed to a single blank.
330
331 "$checker->hyperlink()"
332 Add (if argument specified) and retrieve the hyperlinks (as defined
333 by "L<>") of the current POD. They consist of a 2-item array: line
334 number and "Pod::Hyperlink" object.
335
337 Please report bugs using <http://rt.cpan.org>.
338
339 Brad Appleton <bradapp@enteract.com> (initial version), Marek Rouchal
340 <marekr@cpan.org>
341
342 Based on code for Pod::Text::pod2text() written by Tom Christiansen
343 <tchrist@mox.perl.com>
344
345
346
347perl v5.10.1 2009-04-14 Pod::Checker(3pm)