| 1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
| 2 | .\" |
| 3 | .\" Standard preamble: |
| 4 | .\" ======================================================================== |
| 5 | .de Sh \" Subsection heading |
| 6 | .br |
| 7 | .if t .Sp |
| 8 | .ne 5 |
| 9 | .PP |
| 10 | \fB\\$1\fR |
| 11 | .PP |
| 12 | .. |
| 13 | .de Sp \" Vertical space (when we can't use .PP) |
| 14 | .if t .sp .5v |
| 15 | .if n .sp |
| 16 | .. |
| 17 | .de Vb \" Begin verbatim text |
| 18 | .ft CW |
| 19 | .nf |
| 20 | .ne \\$1 |
| 21 | .. |
| 22 | .de Ve \" End verbatim text |
| 23 | .ft R |
| 24 | .fi |
| 25 | .. |
| 26 | .\" Set up some character translations and predefined strings. \*(-- will |
| 27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left |
| 28 | .\" double quote, and \*(R" will give a right double quote. | will give a |
| 29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to |
| 30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' |
| 31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. |
| 32 | .tr \(*W-|\(bv\*(Tr |
| 33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' |
| 34 | .ie n \{\ |
| 35 | . ds -- \(*W- |
| 36 | . ds PI pi |
| 37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch |
| 38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch |
| 39 | . ds L" "" |
| 40 | . ds R" "" |
| 41 | . ds C` "" |
| 42 | . ds C' "" |
| 43 | 'br\} |
| 44 | .el\{\ |
| 45 | . ds -- \|\(em\| |
| 46 | . ds PI \(*p |
| 47 | . ds L" `` |
| 48 | . ds R" '' |
| 49 | 'br\} |
| 50 | .\" |
| 51 | .\" If the F register is turned on, we'll generate index entries on stderr for |
| 52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index |
| 53 | .\" entries marked with X<> in POD. Of course, you'll have to process the |
| 54 | .\" output yourself in some meaningful fashion. |
| 55 | .if \nF \{\ |
| 56 | . de IX |
| 57 | . tm Index:\\$1\t\\n%\t"\\$2" |
| 58 | .. |
| 59 | . nr % 0 |
| 60 | . rr F |
| 61 | .\} |
| 62 | .\" |
| 63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 64 | .\" way too many mistakes in technical documents. |
| 65 | .hy 0 |
| 66 | .if n .na |
| 67 | .\" |
| 68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). |
| 69 | .\" Fear. Run. Save yourself. No user-serviceable parts. |
| 70 | . \" fudge factors for nroff and troff |
| 71 | .if n \{\ |
| 72 | . ds #H 0 |
| 73 | . ds #V .8m |
| 74 | . ds #F .3m |
| 75 | . ds #[ \f1 |
| 76 | . ds #] \fP |
| 77 | .\} |
| 78 | .if t \{\ |
| 79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) |
| 80 | . ds #V .6m |
| 81 | . ds #F 0 |
| 82 | . ds #[ \& |
| 83 | . ds #] \& |
| 84 | .\} |
| 85 | . \" simple accents for nroff and troff |
| 86 | .if n \{\ |
| 87 | . ds ' \& |
| 88 | . ds ` \& |
| 89 | . ds ^ \& |
| 90 | . ds , \& |
| 91 | . ds ~ ~ |
| 92 | . ds / |
| 93 | .\} |
| 94 | .if t \{\ |
| 95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" |
| 96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' |
| 97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' |
| 98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' |
| 99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' |
| 100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' |
| 101 | .\} |
| 102 | . \" troff and (daisy-wheel) nroff accents |
| 103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' |
| 104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' |
| 105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] |
| 106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' |
| 107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' |
| 108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] |
| 109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] |
| 110 | .ds ae a\h'-(\w'a'u*4/10)'e |
| 111 | .ds Ae A\h'-(\w'A'u*4/10)'E |
| 112 | . \" corrections for vroff |
| 113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' |
| 114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' |
| 115 | . \" for low resolution devices (crt and lpr) |
| 116 | .if \n(.H>23 .if \n(.V>19 \ |
| 117 | \{\ |
| 118 | . ds : e |
| 119 | . ds 8 ss |
| 120 | . ds o a |
| 121 | . ds d- d\h'-1'\(ga |
| 122 | . ds D- D\h'-1'\(hy |
| 123 | . ds th \o'bp' |
| 124 | . ds Th \o'LP' |
| 125 | . ds ae ae |
| 126 | . ds Ae AE |
| 127 | .\} |
| 128 | .rm #[ #] #H #V #F C |
| 129 | .\" ======================================================================== |
| 130 | .\" |
| 131 | .IX Title "Pod::Select 3" |
| 132 | .TH Pod::Select 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide" |
| 133 | .SH "NAME" |
| 134 | Pod::Select, podselect() \- extract selected sections of POD from input |
| 135 | .SH "SYNOPSIS" |
| 136 | .IX Header "SYNOPSIS" |
| 137 | .Vb 1 |
| 138 | \& use Pod::Select; |
| 139 | .Ve |
| 140 | .PP |
| 141 | .Vb 3 |
| 142 | \& ## Select all the POD sections for each file in @filelist |
| 143 | \& ## and print the result on standard output. |
| 144 | \& podselect(@filelist); |
| 145 | .Ve |
| 146 | .PP |
| 147 | .Vb 2 |
| 148 | \& ## Same as above, but write to tmp.out |
| 149 | \& podselect({-output => "tmp.out"}, @filelist): |
| 150 | .Ve |
| 151 | .PP |
| 152 | .Vb 3 |
| 153 | \& ## Select from the given filelist, only those POD sections that are |
| 154 | \& ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS. |
| 155 | \& podselect({-sections => ["NAME|SYNOPSIS", "OPTIONS"]}, @filelist): |
| 156 | .Ve |
| 157 | .PP |
| 158 | .Vb 3 |
| 159 | \& ## Select the "DESCRIPTION" section of the PODs from STDIN and write |
| 160 | \& ## the result to STDERR. |
| 161 | \& podselect({-output => ">&STDERR", -sections => ["DESCRIPTION"]}, \e*STDIN); |
| 162 | .Ve |
| 163 | .PP |
| 164 | or |
| 165 | .PP |
| 166 | .Vb 1 |
| 167 | \& use Pod::Select; |
| 168 | .Ve |
| 169 | .PP |
| 170 | .Vb 2 |
| 171 | \& ## Create a parser object for selecting POD sections from the input |
| 172 | \& $parser = new Pod::Select(); |
| 173 | .Ve |
| 174 | .PP |
| 175 | .Vb 3 |
| 176 | \& ## Select all the POD sections for each file in @filelist |
| 177 | \& ## and print the result to tmp.out. |
| 178 | \& $parser->parse_from_file("<&STDIN", "tmp.out"); |
| 179 | .Ve |
| 180 | .PP |
| 181 | .Vb 4 |
| 182 | \& ## Select from the given filelist, only those POD sections that are |
| 183 | \& ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS. |
| 184 | \& $parser->select("NAME|SYNOPSIS", "OPTIONS"); |
| 185 | \& for (@filelist) { $parser->parse_from_file($_); } |
| 186 | .Ve |
| 187 | .PP |
| 188 | .Vb 5 |
| 189 | \& ## Select the "DESCRIPTION" and "SEE ALSO" sections of the PODs from |
| 190 | \& ## STDIN and write the result to STDERR. |
| 191 | \& $parser->select("DESCRIPTION"); |
| 192 | \& $parser->add_selection("SEE ALSO"); |
| 193 | \& $parser->parse_from_filehandle(\e*STDIN, \e*STDERR); |
| 194 | .Ve |
| 195 | .SH "REQUIRES" |
| 196 | .IX Header "REQUIRES" |
| 197 | perl5.005, Pod::Parser, Exporter, Carp |
| 198 | .SH "EXPORTS" |
| 199 | .IX Header "EXPORTS" |
| 200 | \&\fIpodselect()\fR |
| 201 | .SH "DESCRIPTION" |
| 202 | .IX Header "DESCRIPTION" |
| 203 | \&\fB\f(BIpodselect()\fB\fR is a function which will extract specified sections of |
| 204 | pod documentation from an input stream. This ability is provided by the |
| 205 | \&\fBPod::Select\fR module which is a subclass of \fBPod::Parser\fR. |
| 206 | \&\fBPod::Select\fR provides a method named \fB\f(BIselect()\fB\fR to specify the set of |
| 207 | \&\s-1POD\s0 sections to select for processing/printing. \fB\f(BIpodselect()\fB\fR merely |
| 208 | creates a \fBPod::Select\fR object and then invokes the \fB\f(BIpodselect()\fB\fR |
| 209 | followed by \fB\f(BIparse_from_file()\fB\fR. |
| 210 | .SH "SECTION SPECIFICATIONS" |
| 211 | .IX Header "SECTION SPECIFICATIONS" |
| 212 | \&\fB\f(BIpodselect()\fB\fR and \fB\f(BIPod::Select::select()\fB\fR may be given one or more |
| 213 | \&\*(L"section specifications\*(R" to restrict the text processed to only the |
| 214 | desired set of sections and their corresponding subsections. A section |
| 215 | specification is a string containing one or more Perl-style regular |
| 216 | expressions separated by forward slashes (\*(L"/\*(R"). If you need to use a |
| 217 | forward slash literally within a section title you can escape it with a |
| 218 | backslash (\*(L"\e/\*(R"). |
| 219 | .PP |
| 220 | The formal syntax of a section specification is: |
| 221 | .IP "\(bu" 4 |
| 222 | \&\fIhead1\-title\-regex\fR/\fIhead2\-title\-regex\fR/... |
| 223 | .PP |
| 224 | Any omitted or empty regular expressions will default to \*(L".*\*(R". |
| 225 | Please note that each regular expression given is implicitly |
| 226 | anchored by adding \*(L"^\*(R" and \*(L"$\*(R" to the beginning and end. Also, if a |
| 227 | given regular expression starts with a \*(L"!\*(R" character, then the |
| 228 | expression is \fInegated\fR (so \f(CW\*(C`!foo\*(C'\fR would match anything \fIexcept\fR |
| 229 | \&\f(CW\*(C`foo\*(C'\fR). |
| 230 | .PP |
| 231 | Some example section specifications follow. |
| 232 | .IP "\(bu" 4 |
| 233 | Match the \f(CW\*(C`NAME\*(C'\fR and \f(CW\*(C`SYNOPSIS\*(C'\fR sections and all of their subsections: |
| 234 | .Sp |
| 235 | \&\f(CW\*(C`NAME|SYNOPSIS\*(C'\fR |
| 236 | .IP "\(bu" 4 |
| 237 | Match only the \f(CW\*(C`Question\*(C'\fR and \f(CW\*(C`Answer\*(C'\fR subsections of the \f(CW\*(C`DESCRIPTION\*(C'\fR |
| 238 | section: |
| 239 | .Sp |
| 240 | \&\f(CW\*(C`DESCRIPTION/Question|Answer\*(C'\fR |
| 241 | .IP "\(bu" 4 |
| 242 | Match the \f(CW\*(C`Comments\*(C'\fR subsection of \fIall\fR sections: |
| 243 | .Sp |
| 244 | \&\f(CW\*(C`/Comments\*(C'\fR |
| 245 | .IP "\(bu" 4 |
| 246 | Match all subsections of \f(CW\*(C`DESCRIPTION\*(C'\fR \fIexcept\fR for \f(CW\*(C`Comments\*(C'\fR: |
| 247 | .Sp |
| 248 | \&\f(CW\*(C`DESCRIPTION/!Comments\*(C'\fR |
| 249 | .IP "\(bu" 4 |
| 250 | Match the \f(CW\*(C`DESCRIPTION\*(C'\fR section but do \fInot\fR match any of its subsections: |
| 251 | .Sp |
| 252 | \&\f(CW\*(C`DESCRIPTION/!.+\*(C'\fR |
| 253 | .IP "\(bu" 4 |
| 254 | Match all top level sections but none of their subsections: |
| 255 | .Sp |
| 256 | \&\f(CW\*(C`/!.+\*(C'\fR |
| 257 | .SH "OBJECT METHODS" |
| 258 | .IX Header "OBJECT METHODS" |
| 259 | The following methods are provided in this module. Each one takes a |
| 260 | reference to the object itself as an implicit first parameter. |
| 261 | .SH "\fB\fP\f(BIcurr_headings()\fP\fB\fP" |
| 262 | .IX Header "curr_headings()" |
| 263 | .Vb 2 |
| 264 | \& ($head1, $head2, $head3, ...) = $parser->curr_headings(); |
| 265 | \& $head1 = $parser->curr_headings(1); |
| 266 | .Ve |
| 267 | .PP |
| 268 | This method returns a list of the currently active section headings and |
| 269 | subheadings in the document being parsed. The list of headings returned |
| 270 | corresponds to the most recently parsed paragraph of the input. |
| 271 | .PP |
| 272 | If an argument is given, it must correspond to the desired section |
| 273 | heading number, in which case only the specified section heading is |
| 274 | returned. If there is no current section heading at the specified |
| 275 | level, then \f(CW\*(C`undef\*(C'\fR is returned. |
| 276 | .SH "\fB\fP\f(BIselect()\fP\fB\fP" |
| 277 | .IX Header "select()" |
| 278 | .Vb 1 |
| 279 | \& $parser->select($section_spec1,$section_spec2,...); |
| 280 | .Ve |
| 281 | .PP |
| 282 | This method is used to select the particular sections and subsections of |
| 283 | \&\s-1POD\s0 documentation that are to be printed and/or processed. The existing |
| 284 | set of selected sections is \fIreplaced\fR with the given set of sections. |
| 285 | See \fB\f(BIadd_selection()\fB\fR for adding to the current set of selected |
| 286 | sections. |
| 287 | .PP |
| 288 | Each of the \f(CW$section_spec\fR arguments should be a section specification |
| 289 | as described in \*(L"\s-1SECTION\s0 \s-1SPECIFICATIONS\s0\*(R". The section specifications |
| 290 | are parsed by this method and the resulting regular expressions are |
| 291 | stored in the invoking object. |
| 292 | .PP |
| 293 | If no \f(CW$section_spec\fR arguments are given, then the existing set of |
| 294 | selected sections is cleared out (which means \f(CW\*(C`all\*(C'\fR sections will be |
| 295 | processed). |
| 296 | .PP |
| 297 | This method should \fInot\fR normally be overridden by subclasses. |
| 298 | .SH "\fB\fP\f(BIadd_selection()\fP\fB\fP" |
| 299 | .IX Header "add_selection()" |
| 300 | .Vb 1 |
| 301 | \& $parser->add_selection($section_spec1,$section_spec2,...); |
| 302 | .Ve |
| 303 | .PP |
| 304 | This method is used to add to the currently selected sections and |
| 305 | subsections of \s-1POD\s0 documentation that are to be printed and/or |
| 306 | processed. See <\fIselect()\fR> for replacing the currently selected sections. |
| 307 | .PP |
| 308 | Each of the \f(CW$section_spec\fR arguments should be a section specification |
| 309 | as described in \*(L"\s-1SECTION\s0 \s-1SPECIFICATIONS\s0\*(R". The section specifications |
| 310 | are parsed by this method and the resulting regular expressions are |
| 311 | stored in the invoking object. |
| 312 | .PP |
| 313 | This method should \fInot\fR normally be overridden by subclasses. |
| 314 | .SH "\fB\fP\f(BIclear_selections()\fP\fB\fP" |
| 315 | .IX Header "clear_selections()" |
| 316 | .Vb 1 |
| 317 | \& $parser->clear_selections(); |
| 318 | .Ve |
| 319 | .PP |
| 320 | This method takes no arguments, it has the exact same effect as invoking |
| 321 | <\fIselect()\fR> with no arguments. |
| 322 | .SH "\fB\fP\f(BImatch_section()\fP\fB\fP" |
| 323 | .IX Header "match_section()" |
| 324 | .Vb 1 |
| 325 | \& $boolean = $parser->match_section($heading1,$heading2,...); |
| 326 | .Ve |
| 327 | .PP |
| 328 | Returns a value of true if the given section and subsection heading |
| 329 | titles match any of the currently selected section specifications in |
| 330 | effect from prior calls to \fB\f(BIselect()\fB\fR and \fB\f(BIadd_selection()\fB\fR (or if |
| 331 | there are no explictly selected/deselected sections). |
| 332 | .PP |
| 333 | The arguments \f(CW$heading1\fR, \f(CW$heading2\fR, etc. are the heading titles of |
| 334 | the corresponding sections, subsections, etc. to try and match. If |
| 335 | \&\f(CW$headingN\fR is omitted then it defaults to the current corresponding |
| 336 | section heading title in the input. |
| 337 | .PP |
| 338 | This method should \fInot\fR normally be overridden by subclasses. |
| 339 | .SH "\fB\fP\f(BIis_selected()\fP\fB\fP" |
| 340 | .IX Header "is_selected()" |
| 341 | .Vb 1 |
| 342 | \& $boolean = $parser->is_selected($paragraph); |
| 343 | .Ve |
| 344 | .PP |
| 345 | This method is used to determine if the block of text given in |
| 346 | \&\f(CW$paragraph\fR falls within the currently selected set of \s-1POD\s0 sections |
| 347 | and subsections to be printed or processed. This method is also |
| 348 | responsible for keeping track of the current input section and |
| 349 | subsections. It is assumed that \f(CW$paragraph\fR is the most recently read |
| 350 | (but not yet processed) input paragraph. |
| 351 | .PP |
| 352 | The value returned will be true if the \f(CW$paragraph\fR and the rest of the |
| 353 | text in the same section as \f(CW$paragraph\fR should be selected (included) |
| 354 | for processing; otherwise a false value is returned. |
| 355 | .SH "EXPORTED FUNCTIONS" |
| 356 | .IX Header "EXPORTED FUNCTIONS" |
| 357 | The following functions are exported by this module. Please note that |
| 358 | these are functions (not methods) and therefore \f(CW\*(C`do not\*(C'\fR take an |
| 359 | implicit first argument. |
| 360 | .SH "\fB\fP\f(BIpodselect()\fP\fB\fP" |
| 361 | .IX Header "podselect()" |
| 362 | .Vb 1 |
| 363 | \& podselect(\e%options,@filelist); |
| 364 | .Ve |
| 365 | .PP |
| 366 | \&\fBpodselect\fR will print the raw (untranslated) \s-1POD\s0 paragraphs of all |
| 367 | \&\s-1POD\s0 sections in the given input files specified by \f(CW@filelist\fR |
| 368 | according to the given options. |
| 369 | .PP |
| 370 | If any argument to \fBpodselect\fR is a reference to a hash |
| 371 | (associative array) then the values with the following keys are |
| 372 | processed as follows: |
| 373 | .IP "\fB\-output\fR" 4 |
| 374 | .IX Item "-output" |
| 375 | A string corresponding to the desired output file (or \*(L">&STDOUT\*(R" |
| 376 | or \*(L">&STDERR\*(R"). The default is to use standard output. |
| 377 | .IP "\fB\-sections\fR" 4 |
| 378 | .IX Item "-sections" |
| 379 | A reference to an array of sections specifications (as described in |
| 380 | \&\*(L"\s-1SECTION\s0 \s-1SPECIFICATIONS\s0\*(R") which indicate the desired set of \s-1POD\s0 |
| 381 | sections and subsections to be selected from input. If no section |
| 382 | specifications are given, then all sections of the PODs are used. |
| 383 | .PP |
| 384 | All other arguments should correspond to the names of input files |
| 385 | containing \s-1POD\s0 sections. A file name of \*(L"\-\*(R" or \*(L"<&STDIN\*(R" will |
| 386 | be interpeted to mean standard input (which is the default if no |
| 387 | filenames are given). |
| 388 | .SH "PRIVATE METHODS AND DATA" |
| 389 | .IX Header "PRIVATE METHODS AND DATA" |
| 390 | \&\fBPod::Select\fR makes uses a number of internal methods and data fields |
| 391 | which clients should not need to see or use. For the sake of avoiding |
| 392 | name collisions with client data and methods, these methods and fields |
| 393 | are briefly discussed here. Determined hackers may obtain further |
| 394 | information about them by reading the \fBPod::Select\fR source code. |
| 395 | .PP |
| 396 | Private data fields are stored in the hash-object whose reference is |
| 397 | returned by the \fB\f(BInew()\fB\fR constructor for this class. The names of all |
| 398 | private methods and data-fields used by \fBPod::Select\fR begin with a |
| 399 | prefix of \*(L"_\*(R" and match the regular expression \f(CW\*(C`/^_\ew+$/\*(C'\fR. |
| 400 | .SH "SEE ALSO" |
| 401 | .IX Header "SEE ALSO" |
| 402 | Pod::Parser |
| 403 | .SH "AUTHOR" |
| 404 | .IX Header "AUTHOR" |
| 405 | Brad Appleton <bradapp@enteract.com> |
| 406 | .PP |
| 407 | Based on code for \fBpod2text\fR written by |
| 408 | Tom Christiansen <tchrist@mox.perl.com> |