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

NAME

6       Pod::Simple - framework for parsing Pod
7

SYNOPSIS

9        TODO
10

DESCRIPTION

12       Pod::Simple is a Perl library for parsing text in the Pod ("plain old
13       documentation") markup language that is typically used for writing
14       documentation for Perl and for Perl modules. The Pod format is
15       explained in perlpod; the most common formatter is called "perldoc".
16
17       Be sure to read "ENCODING" if your Pod contains non-ASCII characters.
18
19       Pod formatters can use Pod::Simple to parse Pod documents and render
20       them into plain text, HTML, or any number of other formats. Typically,
21       such formatters will be subclasses of Pod::Simple, and so they will
22       inherit its methods, like "parse_file".  But note that Pod::Simple
23       doesn't understand and properly parse Perl itself, so if you have a
24       file which contains a Perl program that has a multi-line quoted string
25       which has lines that look like pod, Pod::Simple will treat them as pod.
26       This can be avoided if the file makes these into indented here
27       documents instead.
28
29       If you're reading this document just because you have a Pod-processing
30       subclass that you want to use, this document (plus the documentation
31       for the subclass) is probably all you need to read.
32
33       If you're reading this document because you want to write a formatter
34       subclass, continue reading it and then read Pod::Simple::Subclassing,
35       and then possibly even read perlpodspec (some of which is for parser-
36       writers, but much of which is notes to formatter-writers).
37

MAIN METHODS

39       "$parser = SomeClass->new();"
40           This returns a new parser object, where "SomeClass" is a subclass
41           of Pod::Simple.
42
43       "$parser->output_fh( *OUT );"
44           This sets the filehandle that $parser's output will be written to.
45           You can pass *STDOUT or *STDERR, otherwise you should probably do
46           something like this:
47
48               my $outfile = "output.txt";
49               open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!";
50               $parser->output_fh(*TXTOUT);
51
52           ...before you call one of the "$parser->parse_whatever" methods.
53
54       "$parser->output_string( \$somestring );"
55           This sets the string that $parser's output will be sent to, instead
56           of any filehandle.
57
58       "$parser->parse_file( $some_filename );"
59       "$parser->parse_file( *INPUT_FH );"
60           This reads the Pod content of the file (or filehandle) that you
61           specify, and processes it with that $parser object, according to
62           however $parser's class works, and according to whatever parser
63           options you have set up for this $parser object.
64
65       "$parser->parse_string_document( $all_content );"
66           This works just like "parse_file" except that it reads the Pod
67           content not from a file, but from a string that you have already in
68           memory.
69
70       "$parser->parse_lines( ...@lines..., undef );"
71           This processes the lines in @lines (where each list item must be a
72           defined value, and must contain exactly one line of content -- so
73           no items like "foo\nbar" are allowed).  The final "undef" is used
74           to indicate the end of document being parsed.
75
76           The other "parser_whatever" methods are meant to be called only
77           once per $parser object; but "parse_lines" can be called as many
78           times per $parser object as you want, as long as the last call (and
79           only the last call) ends with an "undef" value.
80
81       "$parser->content_seen"
82           This returns true only if there has been any real content seen for
83           this document. Returns false in cases where the document contains
84           content, but does not make use of any Pod markup.
85
86       "SomeClass->filter( $filename );"
87       "SomeClass->filter( *INPUT_FH );"
88       "SomeClass->filter( \$document_content );"
89           This is a shortcut method for creating a new parser object, setting
90           the output handle to STDOUT, and then processing the specified file
91           (or filehandle, or in-memory document). This is handy for one-
92           liners like this:
93
94             perl -MPod::Simple::Text -e "Pod::Simple::Text->filter('thingy.pod')"
95

SECONDARY METHODS

97       Some of these methods might be of interest to general users, as well as
98       of interest to formatter-writers.
99
100       Note that the general pattern here is that the accessor-methods read
101       the attribute's value with "$value = $parser->attribute" and set the
102       attribute's value with "$parser->attribute(newvalue)".  For each
103       accessor, I typically only mention one syntax or another, based on
104       which I think you are actually most likely to use.
105
106       "$parser->parse_characters( SOMEVALUE )"
107           The Pod parser normally expects to read octets and to convert those
108           octets to characters based on the "=encoding" declaration in the
109           Pod source.  Set this option to a true value to indicate that the
110           Pod source is already a Perl character stream.  This tells the
111           parser to ignore any "=encoding" command and to skip all the code
112           paths involving decoding octets.
113
114       "$parser->no_whining( SOMEVALUE )"
115           If you set this attribute to a true value, you will suppress the
116           parser's complaints about irregularities in the Pod coding. By
117           default, this attribute's value is false, meaning that
118           irregularities will be reported.
119
120           Note that turning this attribute to true won't suppress one or two
121           kinds of complaints about rarely occurring unrecoverable errors.
122
123       "$parser->no_errata_section( SOMEVALUE )"
124           If you set this attribute to a true value, you will stop the parser
125           from generating a "POD ERRORS" section at the end of the document.
126           By default, this attribute's value is false, meaning that an errata
127           section will be generated, as necessary.
128
129       "$parser->complain_stderr( SOMEVALUE )"
130           If you set this attribute to a true value, it will send reports of
131           parsing errors to STDERR. By default, this attribute's value is
132           false, meaning that no output is sent to STDERR.
133
134           Setting "complain_stderr" also sets "no_errata_section".
135
136       "$parser->source_filename"
137           This returns the filename that this parser object was set to read
138           from.
139
140       "$parser->doc_has_started"
141           This returns true if $parser has read from a source, and has seen
142           Pod content in it.
143
144       "$parser->source_dead"
145           This returns true if $parser has read from a source, and come to
146           the end of that source.
147
148       "$parser->strip_verbatim_indent( SOMEVALUE )"
149           The perlpod spec for a Verbatim paragraph is "It should be
150           reproduced exactly...", which means that the whitespace you've used
151           to indent your verbatim blocks will be preserved in the output.
152           This can be annoying for outputs such as HTML, where that
153           whitespace will remain in front of every line. It's an unfortunate
154           case where syntax is turned into semantics.
155
156           If the POD you're parsing adheres to a consistent indentation
157           policy, you can have such indentation stripped from the beginning
158           of every line of your verbatim blocks. This method tells
159           Pod::Simple what to strip. For two-space indents, you'd use:
160
161             $parser->strip_verbatim_indent('  ');
162
163           For tab indents, you'd use a tab character:
164
165             $parser->strip_verbatim_indent("\t");
166
167           If the POD is inconsistent about the indentation of verbatim
168           blocks, but you have figured out a heuristic to determine how much
169           a particular verbatim block is indented, you can pass a code
170           reference instead. The code reference will be executed with one
171           argument, an array reference of all the lines in the verbatim
172           block, and should return the value to be stripped from each line.
173           For example, if you decide that you're fine to use the first line
174           of the verbatim block to set the standard for indentation of the
175           rest of the block, you can look at the first line and return the
176           appropriate value, like so:
177
178             $new->strip_verbatim_indent(sub {
179                 my $lines = shift;
180                 (my $indent = $lines->[0]) =~ s/\S.*//;
181                 return $indent;
182             });
183
184           If you'd rather treat each line individually, you can do that, too,
185           by just transforming them in-place in the code reference and
186           returning "undef". Say that you don't want any lines indented. You
187           can do something like this:
188
189             $new->strip_verbatim_indent(sub {
190                 my $lines = shift;
191                 sub { s/^\s+// for @{ $lines },
192                 return undef;
193             });
194

TERTIARY METHODS

196       "$parser->abandon_output_fh()"
197           Cancel output to the file handle. Any POD read by the $parser is
198           not effected.
199
200       "$parser->abandon_output_string()"
201           Cancel output to the output string. Any POD read by the $parser is
202           not effected.
203
204       "$parser->accept_code( @codes )"
205           Alias for accept_codes.
206
207       "$parser->accept_codes( @codes )"
208           Allows $parser to accept a list of "Formatting Codes" in perlpod.
209           This can be used to implement user-defined codes.
210
211       "$parser->accept_directive_as_data( @directives )"
212           Allows $parser to accept a list of directives for data paragraphs.
213           A directive is the label of a "Command Paragraph" in perlpod. A
214           data paragraph is one delimited by "=begin/=for/=end" directives.
215           This can be used to implement user-defined directives.
216
217       "$parser->accept_directive_as_processed( @directives )"
218           Allows $parser to accept a list of directives for processed
219           paragraphs. A directive is the label of a "Command Paragraph" in
220           perlpod. A processed paragraph is also known as "Ordinary
221           Paragraph" in perlpod. This can be used to implement user-defined
222           directives.
223
224       "$parser->accept_directive_as_verbatim( @directives )"
225           Allows $parser to accept a list of directives for "Verbatim
226           Paragraph" in perlpod. A directive is the label of a "Command
227           Paragraph" in perlpod. This can be used to implement user-defined
228           directives.
229
230       "$parser->accept_target( @targets )"
231           Alias for accept_targets.
232
233       "$parser->accept_target_as_text( @targets )"
234           Alias for accept_targets_as_text.
235
236       "$parser->accept_targets( @targets )"
237           Accepts targets for "=begin/=for/=end" sections of the POD.
238
239       "$parser->accept_targets_as_text( @targets )"
240           Accepts targets for "=begin/=for/=end" sections that should be
241           parsed as POD. For details, see "About Data Paragraphs" in
242           perlpodspec.
243
244       "$parser->any_errata_seen()"
245           Used to check if any errata was seen.
246
247           Example:
248
249             die "too many errors\n" if $parser->any_errata_seen();
250
251       "$parser->errata_seen()"
252           Returns a hash reference of all errata seen, both whines and
253           screams. The hash reference's keys are the line number and the
254           value is an array reference of the errors for that line.
255
256           Example:
257
258             if ( $parser->any_errata_seen() ) {
259                $logger->log( $parser->errata_seen() );
260             }
261
262       "$parser->detected_encoding()"
263           Return the encoding corresponding to "=encoding", but only if the
264           encoding was recognized and handled.
265
266       "$parser->encoding()"
267           Return encoding of the document, even if the encoding is not
268           correctly handled.
269
270       "$parser->parse_from_file( $source, $to )"
271           Parses from $source file to $to file. Similar to "parse_from_file"
272           in Pod::Parser.
273
274       "$parser->scream( @error_messages )"
275           Log an error that can't be ignored.
276
277       "$parser->unaccept_code( @codes )"
278           Alias for unaccept_codes.
279
280       "$parser->unaccept_codes( @codes )"
281           Removes @codes as valid codes for the parse.
282
283       "$parser->unaccept_directive( @directives )"
284           Alias for unaccept_directives.
285
286       "$parser->unaccept_directives( @directives )"
287           Removes @directives as valid directives for the parse.
288
289       "$parser->unaccept_target( @targets )"
290           Alias for unaccept_targets.
291
292       "$parser->unaccept_targets( @targets )"
293           Removes @targets as valid targets for the parse.
294
295       "$parser->version_report()"
296           Returns a string describing the version.
297
298       "$parser->whine( @error_messages )"
299           Log an error unless "$parser->no_whining( TRUE );".
300

ENCODING

302       The Pod::Simple parser expects to read octets.  The parser will decode
303       the octets into Perl's internal character string representation using
304       the value of the "=encoding" declaration in the POD source.
305
306       If the POD source does not include an "=encoding" declaration, the
307       parser will attempt to guess the encoding (selecting one of UTF-8 or CP
308       1252) by examining the first non-ASCII bytes and applying the heuristic
309       described in perlpodspec.  (If the POD source contains only ASCII
310       bytes, the encoding is assumed to be ASCII.)
311
312       If you set the "parse_characters" option to a true value the parser
313       will expect characters rather than octets; will ignore any "=encoding";
314       and will make no attempt to decode the input.
315

SEE ALSO

317       Pod::Simple::Subclassing
318
319       perlpod
320
321       perlpodspec
322
323       Pod::Escapes
324
325       perldoc
326

SUPPORT

328       Questions or discussion about POD and Pod::Simple should be sent to the
329       pod-people@perl.org mail list. Send an empty email to
330       pod-people-subscribe@perl.org to subscribe.
331
332       This module is managed in an open GitHub repository,
333       <https://github.com/perl-pod/pod-simple/>. Feel free to fork and
334       contribute, or to clone <git://github.com/perl-pod/pod-simple.git> and
335       send patches!
336
337       Please use <https://github.com/perl-pod/pod-simple/issues/new> to file
338       a bug report.
339
341       Copyright (c) 2002 Sean M. Burke.
342
343       This library is free software; you can redistribute it and/or modify it
344       under the same terms as Perl itself.
345
346       This program is distributed in the hope that it will be useful, but
347       without any warranty; without even the implied warranty of
348       merchantability or fitness for a particular purpose.
349

AUTHOR

351       Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.  But don't
352       bother him, he's retired.
353
354       Pod::Simple is maintained by:
355
356       ·   Allison Randal "allison@perl.org"
357
358       ·   Hans Dieter Pearcey "hdp@cpan.org"
359
360       ·   David E. Wheeler "dwheeler@cpan.org"
361
362       ·   Karl Williamson "khw@cpan.org"
363
364       Documentation has been contributed by:
365
366       ·   Gabor Szabo "szabgab@gmail.com"
367
368       ·   Shawn H Corey  "SHCOREY at cpan.org"
369
370
371
372perl v5.30.0                      2019-07-26                    Pod::Simple(3)
Impressum