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
195       "$parser->expand_verbatim_tabs( n )"
196           Default: 8
197
198           If after any stripping of indentation in verbatim blocks, there
199           remain tabs, this method call indicates what to do with them.  0
200           means leave them as tabs, any other number indicates that each tab
201           is to be translated so as to have tab stops every "n" columns.
202
203           This is independent of other methods (except that it operates after
204           any verbatim input stripping is done).
205
206           Like the other methods, the input parameter is not checked for
207           validity.  "undef" or containing non-digits has the same effect as
208           8.
209

TERTIARY METHODS

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

ENCODING

317       The Pod::Simple parser expects to read octets.  The parser will decode
318       the octets into Perl's internal character string representation using
319       the value of the "=encoding" declaration in the POD source.
320
321       If the POD source does not include an "=encoding" declaration, the
322       parser will attempt to guess the encoding (selecting one of UTF-8 or CP
323       1252) by examining the first non-ASCII bytes and applying the heuristic
324       described in perlpodspec.  (If the POD source contains only ASCII
325       bytes, the encoding is assumed to be ASCII.)
326
327       If you set the "parse_characters" option to a true value the parser
328       will expect characters rather than octets; will ignore any "=encoding";
329       and will make no attempt to decode the input.
330

SEE ALSO

332       Pod::Simple::Subclassing
333
334       perlpod
335
336       perlpodspec
337
338       Pod::Escapes
339
340       perldoc
341

SUPPORT

343       Questions or discussion about POD and Pod::Simple should be sent to the
344       pod-people@perl.org mail list. Send an empty email to
345       pod-people-subscribe@perl.org to subscribe.
346
347       This module is managed in an open GitHub repository,
348       <https://github.com/perl-pod/pod-simple/>. Feel free to fork and
349       contribute, or to clone <git://github.com/perl-pod/pod-simple.git> and
350       send patches!
351
352       Please use <https://github.com/perl-pod/pod-simple/issues/new> to file
353       a bug report.
354
356       Copyright (c) 2002 Sean M. Burke.
357
358       This library is free software; you can redistribute it and/or modify it
359       under the same terms as Perl itself.
360
361       This program is distributed in the hope that it will be useful, but
362       without any warranty; without even the implied warranty of
363       merchantability or fitness for a particular purpose.
364

AUTHOR

366       Pod::Simple was created by Sean M. Burke <sburke@cpan.org>.  But don't
367       bother him, he's retired.
368
369       Pod::Simple is maintained by:
370
371       ·   Allison Randal "allison@perl.org"
372
373       ·   Hans Dieter Pearcey "hdp@cpan.org"
374
375       ·   David E. Wheeler "dwheeler@cpan.org"
376
377       ·   Karl Williamson "khw@cpan.org"
378
379       Documentation has been contributed by:
380
381       ·   Gabor Szabo "szabgab@gmail.com"
382
383       ·   Shawn H Corey  "SHCOREY at cpan.org"
384
385
386
387perl v5.32.1                      2020-11-16                    Pod::Simple(3)
Impressum