.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Pod::Checker 3perl" .TH Pod::Checker 3perl 2024-03-06 "perl v5.38.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Pod::Checker \- check pod documents for syntax errors .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Pod::Checker; \& \& $syntax_okay = podchecker($filepath, $outputpath, %options); \& \& my $checker = Pod::Checker\->new(%options); \& $checker\->parse_from_file($filepath, \e*STDERR); .Ve .SH OPTIONS/ARGUMENTS .IX Header "OPTIONS/ARGUMENTS" \&\f(CW$filepath\fR is the input POD to read and \f(CW$outputpath\fR is where to write POD syntax error messages. Either argument may be a scalar indicating a file-path, or else a reference to an open filehandle. If unspecified, the input-file it defaults to \f(CW\*(C`\e*STDIN\*(C'\fR, and the output-file defaults to \f(CW\*(C`\e*STDERR\*(C'\fR. .SS \fBpodchecker()\fP .IX Subsection "podchecker()" This function can take a hash of options: .IP "\fB\-warnings\fR => \fIval\fR" 4 .IX Item "-warnings => val" Turn warnings on/off. \fIval\fR is usually 1 for on, but higher values trigger additional warnings. See "Warnings". .IP "\fB\-quiet\fR => \fIval\fR" 4 .IX Item "-quiet => val" If \f(CW\*(C`val\*(C'\fR is true, do not print any errors/warnings. .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBpodchecker\fR will perform syntax checking of Perl5 POD format documentation. .PP Curious/ambitious users are welcome to propose additional features they wish to see in \fBPod::Checker\fR and \fBpodchecker\fR and verify that the checks are consistent with perlpod. .PP The following checks are currently performed: .IP \(bu 4 Unknown '=xxxx' commands, unknown 'X<...>' interior-sequences, and unterminated interior sequences. .IP \(bu 4 Check for proper balancing of \f(CW\*(C`=begin\*(C'\fR and \f(CW\*(C`=end\*(C'\fR. The contents of such a block are generally ignored, i.e. no syntax checks are performed. .IP \(bu 4 Check for proper nesting and balancing of \f(CW\*(C`=over\*(C'\fR, \f(CW\*(C`=item\*(C'\fR and \f(CW\*(C`=back\*(C'\fR. .IP \(bu 4 Check for same nested interior-sequences (e.g. \&\f(CW\*(C`L<...L<...>...>\*(C'\fR). .IP \(bu 4 Check for malformed or non-existing entities \f(CW\*(C`E<...>\*(C'\fR. .IP \(bu 4 Check for correct syntax of hyperlinks \f(CW\*(C`L<...>\*(C'\fR. See perlpod for details. .IP \(bu 4 Check for unresolved document-internal links. This check may also reveal misspelled links that seem to be internal links but should be links to something else. .SH DIAGNOSTICS .IX Header "DIAGNOSTICS" .SS Errors .IX Subsection "Errors" .IP \(bu 4 empty =headn .Sp A heading (\f(CW\*(C`=head1\*(C'\fR or \f(CW\*(C`=head2\*(C'\fR) without any text? That ain't no heading! .IP \(bu 4 =over on line \fIN\fR without closing =back .IP \(bu 4 You forgot a '=back' before '=head\fIN\fR' .IP \(bu 4 =over is the last thing in the document?! .Sp The \f(CW\*(C`=over\*(C'\fR command does not have a corresponding \f(CW\*(C`=back\*(C'\fR before the next heading (\f(CW\*(C`=head1\*(C'\fR or \f(CW\*(C`=head2\*(C'\fR) or the end of the file. .IP \(bu 4 \&'=item' outside of any '=over' .IP \(bu 4 =back without =over .Sp An \f(CW\*(C`=item\*(C'\fR or \f(CW\*(C`=back\*(C'\fR command has been found outside a \&\f(CW\*(C`=over\*(C'\fR/\f(CW\*(C`=back\*(C'\fR block. .IP \(bu 4 Can't have a 0 in =over \fIN\fR .Sp You need to indent a strictly positive number of spaces, not 0. .IP \(bu 4 =over should be: '=over' or '=over positive_number' .Sp Either have an argumentless =over, or have its argument a strictly positive number. .IP \(bu 4 =begin \fITARGET\fR without matching =end \fITARGET\fR .Sp A \f(CW\*(C`=begin\*(C'\fR command was found that has no matching =end command. .IP \(bu 4 =begin without a target? .Sp A \f(CW\*(C`=begin\*(C'\fR command was found that is not followed by the formatter specification. .IP \(bu 4 =end \fITARGET\fR without matching =begin. .Sp A standalone \f(CW\*(C`=end\*(C'\fR command was found. .IP \(bu 4 \&'=end' without a target? .Sp \&'=end' directives need to have a target, just like =begin directives. .IP \(bu 4 \&'=end \fITARGET\fR' is invalid. .Sp \&\fITARGET\fR needs to be one word .IP \(bu 4 =end \fICONTENT\fR doesn't match =begin \fITARGET\fR .Sp \&\fICONTENT\fR needs to match =begin's \fITARGET\fR. .IP \(bu 4 =for without a target? .Sp There is no specification of the formatter after the \f(CW\*(C`=for\*(C'\fR command. .IP \(bu 4 unresolved internal link \fINAME\fR .Sp The given link to \fINAME\fR does not have a matching node in the current POD. This also happened when a single word node name is not enclosed in \&\f(CW""\fR. .IP \(bu 4 Unknown directive: \fICMD\fR .Sp An invalid POD command has been found. Valid are \f(CW\*(C`=head1\*(C'\fR, \f(CW\*(C`=head2\*(C'\fR, \&\f(CW\*(C`=head3\*(C'\fR, \f(CW\*(C`=head4\*(C'\fR, \f(CW\*(C`=over\*(C'\fR, \f(CW\*(C`=item\*(C'\fR, \f(CW\*(C`=back\*(C'\fR, \f(CW\*(C`=begin\*(C'\fR, \f(CW\*(C`=end\*(C'\fR, \&\f(CW\*(C`=for\*(C'\fR, \f(CW\*(C`=pod\*(C'\fR, \f(CW\*(C`=cut\*(C'\fR .IP \(bu 4 Deleting unknown formatting code \fISEQ\fR .Sp An invalid markup command has been encountered. Valid are: \&\f(CW\*(C`B<>\*(C'\fR, \f(CW\*(C`C<>\*(C'\fR, \f(CW\*(C`E<>\*(C'\fR, \f(CW\*(C`F<>\*(C'\fR, \&\f(CW\*(C`I<>\*(C'\fR, \f(CW\*(C`L<>\*(C'\fR, \f(CW\*(C`S<>\*(C'\fR, \f(CW\*(C`X<>\*(C'\fR, \&\f(CW\*(C`Z<>\*(C'\fR .IP \(bu 4 Unterminated \fISEQ\fR<> sequence .Sp An unclosed formatting code .IP \(bu 4 An E<...> surrounding strange content .Sp The \fISTRING\fR found cannot be interpreted as a character entity. .IP \(bu 4 An empty E<> .IP \(bu 4 An empty \f(CW\*(C`L<>\*(C'\fR .IP \(bu 4 An empty X<> .Sp There needs to be content inside E, L, and X formatting codes. .IP \(bu 4 Spurious text after =pod / =cut .Sp The commands \f(CW\*(C`=pod\*(C'\fR and \f(CW\*(C`=cut\*(C'\fR do not take any arguments. .IP \(bu 4 =back doesn't take any parameters, but you said =back \fIARGUMENT\fR .Sp The \f(CW\*(C`=back\*(C'\fR command does not take any arguments. .IP \(bu 4 =pod directives shouldn't be over one line long! Ignoring all \fIN\fR lines of content .Sp Self explanatory .IP \(bu 4 =cut found outside a pod block. .Sp A '=cut' directive found in the middle of non-POD .IP \(bu 4 Invalid =encoding syntax: \fICONTENT\fR .Sp Syntax error in =encoding directive .SS Warnings .IX Subsection "Warnings" These may not necessarily cause trouble, but indicate mediocre style. .IP \(bu 4 nested commands \fICMD\fR<...\fICMD\fR<...>...> .Sp Two nested identical markup commands have been found. Generally this does not make sense. .IP \(bu 4 multiple occurrences (\fIN\fR) of link target \fIname\fR .Sp The POD file has some \f(CW\*(C`=item\*(C'\fR and/or \f(CW\*(C`=head\*(C'\fR commands that have the same text. Potential hyperlinks to such a text cannot be unique then. This warning is printed only with warning level greater than one. .IP \(bu 4 line containing nothing but whitespace in paragraph .Sp There is some whitespace on a seemingly empty line. POD is very sensitive to such things, so this is flagged. \fBvi\fR users switch on the \fBlist\fR option to avoid this problem. .IP \(bu 4 =item has no contents .Sp There is a list \f(CW\*(C`=item\*(C'\fR that has no text contents. You probably want to delete empty items. .IP \(bu 4 You can't have =items (as at line \fIN\fR) unless the first thing after the =over is an =item .Sp A list introduced by \f(CW\*(C`=over\*(C'\fR starts with a text or verbatim paragraph, but continues with \f(CW\*(C`=item\*(C'\fRs. Move the non-item paragraph out of the \&\f(CW\*(C`=over\*(C'\fR/\f(CW\*(C`=back\*(C'\fR block. .IP \(bu 4 Expected '=item \fIEXPECTED VALUE\fR' .IP \(bu 4 Expected '=item *' .IP \(bu 4 Possible =item type mismatch: '\fIx\fR' found leading a supposed definition =item .Sp A list started with e.g. a bullet-like \f(CW\*(C`=item\*(C'\fR and continued with a numbered one. This is obviously inconsistent. For most translators the type of the \fIfirst\fR \f(CW\*(C`=item\*(C'\fR determines the type of the list. .IP \(bu 4 You have '=item x' instead of the expected '=item \fIN\fR' .Sp Erroneous numbering of =item numbers; they need to ascend consecutively. .IP \(bu 4 Unknown E content in E<\fICONTENT\fR> .Sp A character entity was found that does not belong to the standard ISO set or the POD specials \f(CW\*(C`verbar\*(C'\fR and \f(CW\*(C`sol\*(C'\fR. \fICurrently, this warning only appears if a character entity was found that does not have a Unicode character. This should be fixed to adhere to the original warning.\fR .IP \(bu 4 empty =over/=back block .Sp The list opened with \f(CW\*(C`=over\*(C'\fR does not contain anything. .IP \(bu 4 empty section in previous paragraph .Sp The previous section (introduced by a \f(CW\*(C`=head\*(C'\fR command) does not contain any valid content. This usually indicates that something is missing. Note: A \&\f(CW\*(C`=head1\*(C'\fR followed immediately by \f(CW\*(C`=head2\*(C'\fR does not trigger this warning. .IP \(bu 4 Verbatim paragraph in NAME section .Sp The NAME section (\f(CW\*(C`=head1 NAME\*(C'\fR) should consist of a single paragraph with the script/module name, followed by a dash `\-' and a very short description of what the thing is good for. .IP \(bu 4 =head\fIn\fR without preceding higher level .Sp For example if there is a \f(CW\*(C`=head2\*(C'\fR in the POD file prior to a \&\f(CW\*(C`=head1\*(C'\fR. .IP \(bu 4 A non-empty Z<> .Sp The \f(CW\*(C`Z<>\*(C'\fR sequence is supposed to be empty. Caveat: this issue is detected in Pod::Simple and will be flagged as an \fIERROR\fR by any client code; any contents of \f(CW\*(C`Z<...>\*(C'\fR will be disregarded, anyway. .SS Hyperlinks .IX Subsection "Hyperlinks" There are some warnings with respect to malformed hyperlinks: .IP \(bu 4 ignoring leading/trailing whitespace in link .Sp There is whitespace at the beginning or the end of the contents of L<...>. .IP \(bu 4 alternative text/node '%s' contains non-escaped | or / .Sp The characters \f(CW\*(C`|\*(C'\fR and \f(CW\*(C`/\*(C'\fR are special in the L<...> context. Although the hyperlink parser does its best to determine which "/" is text and which is a delimiter in case of doubt, one ought to escape these literal characters like this: .Sp .Vb 2 \& / E \& | E .Ve .PP Note that the line number of the error/warning may refer to the line number of the start of the paragraph in which the error/warning exists, not the line number that the error/warning is on. This bug is present in errors/warnings related to formatting codes. \fIThis should be fixed.\fR .SH "RETURN VALUE" .IX Header "RETURN VALUE" \&\fBpodchecker\fR returns the number of POD syntax errors found or \-1 if there were no POD commands at all found in the file. .SH EXAMPLES .IX Header "EXAMPLES" See "SYNOPSIS" .SH SCRIPTS .IX Header "SCRIPTS" The \fBpodchecker\fR script that comes with this distribution is a lean wrapper around this module. See the online manual with .PP .Vb 2 \& podchecker \-help \& podchecker \-man .Ve .SH INTERFACE .IX Header "INTERFACE" While checking, this module collects document properties, e.g. the nodes for hyperlinks (\f(CW\*(C`=headX\*(C'\fR, \f(CW\*(C`=item\*(C'\fR) and index entries (\f(CW\*(C`X<>\*(C'\fR). POD translators can use this feature to syntax-check and get the nodes in a first pass before actually starting to convert. This is expensive in terms of execution time, but allows for very robust conversions. .PP Since v1.24 the \fBPod::Checker\fR module uses only the \fBpoderror\fR method to print errors and warnings. The summary output (e.g. "Pod syntax OK") has been dropped from the module and has been included in \&\fBpodchecker\fR (the script). This allows users of \fBPod::Checker\fR to control completely the output behavior. Users of \fBpodchecker\fR (the script) get the well-known behavior. .PP v1.45 inherits from Pod::Simple as opposed to all previous versions inheriting from Pod::Parser. Do \fBnot\fR use Pod::Simple's interface when using Pod::Checker unless it is documented somewhere on this page. I repeat, DO \fBNOT\fR USE POD::SIMPLE'S INTERFACE. .PP The following list documents the overrides to Pod::Simple, primarily to make Pod::Coverage happy: .IP end_B 4 .IX Item "end_B" .PD 0 .IP end_C 4 .IX Item "end_C" .IP end_Document 4 .IX Item "end_Document" .IP end_F 4 .IX Item "end_F" .IP end_I 4 .IX Item "end_I" .IP end_L 4 .IX Item "end_L" .IP end_Para 4 .IX Item "end_Para" .IP end_S 4 .IX Item "end_S" .IP end_X 4 .IX Item "end_X" .IP end_fcode 4 .IX Item "end_fcode" .IP end_for 4 .IX Item "end_for" .IP end_head 4 .IX Item "end_head" .IP end_head1 4 .IX Item "end_head1" .IP end_head2 4 .IX Item "end_head2" .IP end_head3 4 .IX Item "end_head3" .IP end_head4 4 .IX Item "end_head4" .IP end_item 4 .IX Item "end_item" .IP end_item_bullet 4 .IX Item "end_item_bullet" .IP end_item_number 4 .IX Item "end_item_number" .IP end_item_text 4 .IX Item "end_item_text" .IP handle_pod_and_cut 4 .IX Item "handle_pod_and_cut" .IP handle_text 4 .IX Item "handle_text" .IP handle_whiteline 4 .IX Item "handle_whiteline" .IP hyperlink 4 .IX Item "hyperlink" .IP scream 4 .IX Item "scream" .IP start_B 4 .IX Item "start_B" .IP start_C 4 .IX Item "start_C" .IP start_Data 4 .IX Item "start_Data" .IP start_F 4 .IX Item "start_F" .IP start_I 4 .IX Item "start_I" .IP start_L 4 .IX Item "start_L" .IP start_Para 4 .IX Item "start_Para" .IP start_S 4 .IX Item "start_S" .IP start_Verbatim 4 .IX Item "start_Verbatim" .IP start_X 4 .IX Item "start_X" .IP start_fcode 4 .IX Item "start_fcode" .IP start_for 4 .IX Item "start_for" .IP start_head 4 .IX Item "start_head" .IP start_head1 4 .IX Item "start_head1" .IP start_head2 4 .IX Item "start_head2" .IP start_head3 4 .IX Item "start_head3" .IP start_head4 4 .IX Item "start_head4" .IP start_item_bullet 4 .IX Item "start_item_bullet" .IP start_item_number 4 .IX Item "start_item_number" .IP start_item_text 4 .IX Item "start_item_text" .IP start_over 4 .IX Item "start_over" .IP start_over_block 4 .IX Item "start_over_block" .IP start_over_bullet 4 .IX Item "start_over_bullet" .IP start_over_empty 4 .IX Item "start_over_empty" .IP start_over_number 4 .IX Item "start_over_number" .IP start_over_text 4 .IX Item "start_over_text" .IP whine 4 .IX Item "whine" .ie n .IP """Pod::Checker\->new( %options )""" 4 .el .IP "\f(CWPod::Checker\->new( %options )\fR" 4 .IX Item "Pod::Checker->new( %options )" .PD Return a reference to a new Pod::Checker object that inherits from Pod::Simple and is used for calling the required methods later. The following options are recognized: .Sp \&\f(CW\*(C`\-warnings => num\*(C'\fR Print warnings if \f(CW\*(C`num\*(C'\fR is true. The higher the value of \f(CW\*(C`num\*(C'\fR, the more warnings are printed. Currently there are only levels 1 and 2. .Sp \&\f(CW\*(C`\-quiet => num\*(C'\fR If \f(CW\*(C`num\*(C'\fR is true, do not print any errors/warnings. This is useful when Pod::Checker is used to munge POD code into plain text from within POD formatters. .ie n .IP """$checker\->poderror( @args )""" 4 .el .IP "\f(CW$checker\->poderror( @args )\fR" 4 .IX Item "$checker->poderror( @args )" .PD 0 .ie n .IP """$checker\->poderror( {%opts}, @args )""" 4 .el .IP "\f(CW$checker\->poderror( {%opts}, @args )\fR" 4 .IX Item "$checker->poderror( {%opts}, @args )" .PD Internal method for printing errors and warnings. If no options are given, simply prints "@_". The following options are recognized and used to form the output: .Sp .Vb 1 \& \-msg .Ve .Sp A message to print prior to \f(CW@args\fR. .Sp .Vb 1 \& \-line .Ve .Sp The line number the error occurred in. .Sp .Vb 1 \& \-file .Ve .Sp The file (name) the error occurred in. Defaults to the name of the current file being processed. .Sp .Vb 1 \& \-severity .Ve .Sp The error level, should be 'WARNING' or 'ERROR'. .ie n .IP """$checker\->num_errors()""" 4 .el .IP \f(CW$checker\->num_errors()\fR 4 .IX Item "$checker->num_errors()" Set (if argument specified) and retrieve the number of errors found. .ie n .IP """$checker\->num_warnings()""" 4 .el .IP \f(CW$checker\->num_warnings()\fR 4 .IX Item "$checker->num_warnings()" Set (if argument specified) and retrieve the number of warnings found. .ie n .IP """$checker\->name()""" 4 .el .IP \f(CW$checker\->name()\fR 4 .IX Item "$checker->name()" Set (if argument specified) and retrieve the canonical name of POD as found in the \f(CW\*(C`=head1 NAME\*(C'\fR section. .ie n .IP """$checker\->node()""" 4 .el .IP \f(CW$checker\->node()\fR 4 .IX Item "$checker->node()" Add (if argument specified) and retrieve the nodes (as defined by \f(CW\*(C`=headX\*(C'\fR and \f(CW\*(C`=item\*(C'\fR) of the current POD. The nodes are returned in the order of their occurrence. They consist of plain text, each piece of whitespace is collapsed to a single blank. .ie n .IP """$checker\->idx()""" 4 .el .IP \f(CW$checker\->idx()\fR 4 .IX Item "$checker->idx()" Add (if argument specified) and retrieve the index entries (as defined by \&\f(CW\*(C`X<>\*(C'\fR) of the current POD. They consist of plain text, each piece of whitespace is collapsed to a single blank. .ie n .IP """$checker\->hyperlinks()""" 4 .el .IP \f(CW$checker\->hyperlinks()\fR 4 .IX Item "$checker->hyperlinks()" Retrieve an array containing the hyperlinks to things outside the current POD (as defined by \f(CW\*(C`L<>\*(C'\fR). .Sp Each is an instance of a class with the following methods: .IP \fBline()\fR 4 .IX Item "line()" Returns the approximate line number in which the link was encountered .IP \fBtype()\fR 4 .IX Item "type()" Returns the type of the link; one of: \&\f(CW"url"\fR for things like \&\f(CW\*(C`http://www.foo\*(C'\fR, \f(CW"man"\fR for man pages, or \f(CW"pod"\fR. .IP \fBpage()\fR 4 .IX Item "page()" Returns the linked-to page or url. .IP \fBnode()\fR 4 .IX Item "node()" Returns the anchor or node within the linked-to page, or an empty string (\f(CW""\fR) if none appears in the link. .SH AUTHOR .IX Header "AUTHOR" Please report bugs using . .PP Brad Appleton (initial version), Marek Rouchal , Marc Green (port to Pod::Simple) Ricardo Signes (more porting to Pod::Simple) Karl Williamson (more porting to Pod::Simple) .PP Based on code for \fBPod::Text::pod2text()\fR written by Tom Christiansen