home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _0b650366fad5c455f18302531a27cf5f < prev    next >
Text File  |  2000-03-23  |  15KB  |  318 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>podselect - extract selected sections of POD from input</TITLE>
  5. <LINK REL="stylesheet" HREF="../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> podselect - extract selected sections of POD from input</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#requires">REQUIRES</A></LI>
  25.     <LI><A HREF="#exports">EXPORTS</A></LI>
  26.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  27.     <LI><A HREF="#section specifications">SECTION SPECIFICATIONS</A></LI>
  28.     <LI><A HREF="#range specifications">RANGE SPECIFICATIONS</A></LI>
  29.     <LI><A HREF="#object methods">OBJECT METHODS</A></LI>
  30.     <LI><A HREF="#curr_headings()"><STRONG>curr_headings()</STRONG></A></LI>
  31.     <LI><A HREF="#select()"><STRONG>select()</STRONG></A></LI>
  32.     <LI><A HREF="#add_selection()"><STRONG>add_selection()</STRONG></A></LI>
  33.     <LI><A HREF="#clear_selections()"><STRONG>clear_selections()</STRONG></A></LI>
  34.     <LI><A HREF="#match_section()"><STRONG>match_section()</STRONG></A></LI>
  35.     <LI><A HREF="#is_selected()"><STRONG>is_selected()</STRONG></A></LI>
  36.     <LI><A HREF="#exported functions">EXPORTED FUNCTIONS</A></LI>
  37.     <LI><A HREF="#podselect()"><STRONG>podselect()</STRONG></A></LI>
  38.     <LI><A HREF="#private methods and data">PRIVATE METHODS AND DATA</A></LI>
  39.     <LI><A HREF="#_compile_section_spec()"><STRONG>_compile_section_spec()</STRONG></A></LI>
  40.     <UL>
  41.  
  42.         <LI><A HREF="#$self>{_section_headings}">$self->{_SECTION_HEADINGS}</A></LI>
  43.         <LI><A HREF="#$self>{_selected_sections}">$self->{_SELECTED_SECTIONS}</A></LI>
  44.     </UL>
  45.  
  46.     <LI><A HREF="#see also">SEE ALSO</A></LI>
  47.     <LI><A HREF="#author">AUTHOR</A></LI>
  48. </UL>
  49. <!-- INDEX END -->
  50.  
  51. <HR>
  52. <P>
  53. <H1><A NAME="name">NAME</A></H1>
  54. <P>Pod::Select, <CODE>podselect()</CODE> - extract selected sections of POD from input</P>
  55. <P>
  56. <HR>
  57. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  58. <UL>
  59. <LI>Linux</LI>
  60. <LI>Solaris</LI>
  61. <LI>Windows</LI>
  62. </UL>
  63. <HR>
  64. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  65. <PRE>
  66.     use Pod::Select;</PRE>
  67. <PRE>
  68.     ## Select all the POD sections for each file in @filelist
  69.     ## and print the result on standard output.
  70.     podselect(@filelist);</PRE>
  71. <PRE>
  72.     ## Same as above, but write to tmp.out
  73.     podselect({-output => "tmp.out"}, @filelist):</PRE>
  74. <PRE>
  75.     ## Select from the given filelist, only those POD sections that are
  76.     ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS.
  77.     podselect({-sections => ["NAME|SYNOPSIS", "OPTIONS"]}, @filelist):</PRE>
  78. <PRE>
  79.     ## Select the "DESCRIPTION" section of the PODs from STDIN and write
  80.     ## the result to STDERR.
  81.     podselect({-output => ">&STDERR", -sections => ["DESCRIPTION"]}, \*STDIN);</PRE>
  82. <P>or</P>
  83. <PRE>
  84.     use Pod::Select;</PRE>
  85. <PRE>
  86.     ## Create a parser object for selecting POD sections from the input
  87.     $parser = new Pod::Select();</PRE>
  88. <PRE>
  89.     ## Select all the POD sections for each file in @filelist
  90.     ## and print the result to tmp.out.
  91.     $parser->parse_from_file("<&STDIN", "tmp.out");</PRE>
  92. <PRE>
  93.     ## Select from the given filelist, only those POD sections that are
  94.     ## within a 1st level section named any of: NAME, SYNOPSIS, OPTIONS.
  95.     $parser->select("NAME|SYNOPSIS", "OPTIONS");
  96.     for (@filelist) { $parser->parse_from_file($_); }</PRE>
  97. <PRE>
  98.     ## Select the "DESCRIPTION" and "SEE ALSO" sections of the PODs from
  99.     ## STDIN and write the result to STDERR.
  100.     $parser->select("DESCRIPTION");
  101.     $parser->add_selection("SEE ALSO");
  102.     $parser->parse_from_filehandle(\*STDIN, \*STDERR);</PRE>
  103. <P>
  104. <HR>
  105. <H1><A NAME="requires">REQUIRES</A></H1>
  106. <P>perl5.005, Pod::Parser, Exporter, Carp</P>
  107. <P>
  108. <HR>
  109. <H1><A NAME="exports">EXPORTS</A></H1>
  110. <P><CODE>podselect()</CODE></P>
  111. <P>
  112. <HR>
  113. <H1><A NAME="description">DESCRIPTION</A></H1>
  114. <P><STRONG>podselect()</STRONG> is a function which will extract specified sections of
  115. pod documentation from an input stream. This ability is provided by the
  116. <STRONG>Pod::Select</STRONG> module which is a subclass of <STRONG>Pod::Parser</STRONG>.
  117. <STRONG>Pod::Select</STRONG> provides a method named <STRONG>select()</STRONG> to specify the set of
  118. POD sections to select for processing/printing. <STRONG>podselect()</STRONG> merely
  119. creates a <STRONG>Pod::Select</STRONG> object and then invokes the <STRONG>podselect()</STRONG>
  120. followed by <STRONG>parse_from_file()</STRONG>.</P>
  121. <P>
  122. <HR>
  123. <H1><A NAME="section specifications">SECTION SPECIFICATIONS</A></H1>
  124. <P><STRONG>podselect()</STRONG> and <STRONG>Pod::Select::select()</STRONG> may be given one or more
  125. ``section specifications'' to restrict the text processed to only the
  126. desired set of sections and their corresponding subsections.  A section
  127. specification is a string containing one or more Perl-style regular
  128. expressions separated by forward slashes (``/'').  If you need to use a
  129. forward slash literally within a section title you can escape it with a
  130. backslash (``\/'').</P>
  131. <P>The formal syntax of a section specification is:</P>
  132. <DL>
  133. <DT><DD>
  134. <EM>head1-title-regex</EM>/<EM>head2-title-regex</EM>/...
  135. <P></P></DL>
  136. <P>Any omitted or empty regular expressions will default to ``.*''.
  137. Please note that each regular expression given is implicitly
  138. anchored by adding ``^'' and ``$'' to the beginning and end.  Also, if a
  139. given regular expression starts with a ``!'' character, then the
  140. expression is <EM>negated</EM> (so <CODE>!foo</CODE> would match anything <EM>except</EM>
  141. <CODE>foo</CODE>).</P>
  142. <P>Some example section specifications follow.</P>
  143. <DL>
  144. <DT><STRONG><A NAME="item_Match_the_NAME_and_SYNOPSIS_sections_and_all_of_th">Match the <CODE>NAME</CODE> and <CODE>SYNOPSIS</CODE> sections and all of their subsections:</A></STRONG><BR>
  145. <DD>
  146. <CODE>NAME|SYNOPSIS</CODE>
  147. <P></P>
  148. <DT><STRONG><A NAME="item_Match_only_the_Question_and_Answer_subsections_of_">Match only the <CODE>Question</CODE> and <CODE>Answer</CODE> subsections of the <CODE>DESCRIPTION</CODE>
  149. section:</A></STRONG><BR>
  150. <DD>
  151. <CODE>DESCRIPTION/Question|Answer</CODE>
  152. <P></P>
  153. <DT><STRONG><A NAME="item_Match_the_Comments_subsection_of_all_sections%3A">Match the <CODE>Comments</CODE> subsection of <EM>all</EM> sections:</A></STRONG><BR>
  154. <DD>
  155. <CODE>/Comments</CODE>
  156. <P></P>
  157. <DT><STRONG><A NAME="item_Match_all_subsections_of_DESCRIPTION_except_for_Co">Match all subsections of <CODE>DESCRIPTION</CODE> <EM>except</EM> for <CODE>Comments</CODE>:</A></STRONG><BR>
  158. <DD>
  159. <CODE>DESCRIPTION/!Comments</CODE>
  160. <P></P>
  161. <DT><STRONG><A NAME="item_Match_the_DESCRIPTION_section_but_do_not_match_any">Match the <CODE>DESCRIPTION</CODE> section but do <EM>not</EM> match any of its subsections:</A></STRONG><BR>
  162. <DD>
  163. <CODE>DESCRIPTION/!.+</CODE>
  164. <P></P>
  165. <DT><STRONG><A NAME="item_Match_all_top_level_sections_but_none_of_their_sub">Match all top level sections but none of their subsections:</A></STRONG><BR>
  166. <DD>
  167. <CODE>/!.+</CODE>
  168. <P></P></DL>
  169. <P>
  170. <HR>
  171. <H1><A NAME="object methods">OBJECT METHODS</A></H1>
  172. <P>The following methods are provided in this module. Each one takes a
  173. reference to the object itself as an implicit first parameter.</P>
  174. <P>
  175. <HR>
  176. <H1><A NAME="curr_headings()"><STRONG>curr_headings()</STRONG></A></H1>
  177. <PRE>
  178.             ($head1, $head2, $head3, ...) = $parser->curr_headings();
  179.             $head1 = $parser->curr_headings(1);</PRE>
  180. <P>This method returns a list of the currently active section headings and
  181. subheadings in the document being parsed. The list of headings returned
  182. corresponds to the most recently parsed paragraph of the input.</P>
  183. <P>If an argument is given, it must correspond to the desired section
  184. heading number, in which case only the specified section heading is
  185. returned. If there is no current section heading at the specified
  186. level, then <A HREF="../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> is returned.</P>
  187. <P>
  188. <HR>
  189. <H1><A NAME="select()"><STRONG>select()</STRONG></A></H1>
  190. <PRE>
  191.             $parser->select($section_spec1,$section_spec2,...);</PRE>
  192. <P>This method is used to select the particular sections and subsections of
  193. POD documentation that are to be printed and/or processed. The existing
  194. set of selected sections is <EM>replaced</EM> with the given set of sections.
  195. See <STRONG>add_selection()</STRONG> for adding to the current set of selected
  196. sections.</P>
  197. <P>Each of the <CODE>$section_spec</CODE> arguments should be a section specification
  198. as described in <A HREF="#section specifications">SECTION SPECIFICATIONS</A>.  The section specifications
  199. are parsed by this method and the resulting regular expressions are
  200. stored in the invoking object.</P>
  201. <P>If no <CODE>$section_spec</CODE> arguments are given, then the existing set of
  202. selected sections is cleared out (which means <CODE>all</CODE> sections will be
  203. processed).</P>
  204. <P>This method should <EM>not</EM> normally be overridden by subclasses.</P>
  205. <P>
  206. <HR>
  207. <H1><A NAME="add_selection()"><STRONG>add_selection()</STRONG></A></H1>
  208. <PRE>
  209.             $parser->add_selection($section_spec1,$section_spec2,...);</PRE>
  210. <P>This method is used to add to the currently selected sections and
  211. subsections of POD documentation that are to be printed and/or
  212. processed. See <select()> for replacing the currently selected sections.</P>
  213. <P>Each of the <CODE>$section_spec</CODE> arguments should be a section specification
  214. as described in <A HREF="#section specifications">SECTION SPECIFICATIONS</A>. The section specifications
  215. are parsed by this method and the resulting regular expressions are
  216. stored in the invoking object.</P>
  217. <P>This method should <EM>not</EM> normally be overridden by subclasses.</P>
  218. <P>
  219. <HR>
  220. <H1><A NAME="clear_selections()"><STRONG>clear_selections()</STRONG></A></H1>
  221. <PRE>
  222.             $parser->clear_selections();</PRE>
  223. <P>This method takes no arguments, it has the exact same effect as invoking
  224. <select()> with no arguments.</P>
  225. <P>
  226. <HR>
  227. <H1><A NAME="match_section()"><STRONG>match_section()</STRONG></A></H1>
  228. <PRE>
  229.             $boolean = $parser->match_section($heading1,$heading2,...);</PRE>
  230. <P>Returns a value of true if the given section and subsection heading
  231. titles match any of the currently selected section specifications in
  232. effect from prior calls to <STRONG>select()</STRONG> and <STRONG>add_selection()</STRONG> (or if
  233. there are no explictly selected/deselected sections).</P>
  234. <P>The arguments <CODE>$heading1</CODE>, <CODE>$heading2</CODE>, etc. are the heading titles of
  235. the corresponding sections, subsections, etc. to try and match.  If
  236. <CODE>$headingN</CODE> is omitted then it defaults to the current corresponding
  237. section heading title in the input.</P>
  238. <P>This method should <EM>not</EM> normally be overridden by subclasses.</P>
  239. <P>
  240. <HR>
  241. <H1><A NAME="is_selected()"><STRONG>is_selected()</STRONG></A></H1>
  242. <PRE>
  243.             $boolean = $parser->is_selected($paragraph);</PRE>
  244. <P>This method is used to determine if the block of text given in
  245. <CODE>$paragraph</CODE> falls within the currently selected set of POD sections
  246. and subsections to be printed or processed. This method is also
  247. responsible for keeping track of the current input section and
  248. subsections. It is assumed that <CODE>$paragraph</CODE> is the most recently read
  249. (but not yet processed) input paragraph.</P>
  250. <P>The value returned will be true if the <CODE>$paragraph</CODE> and the rest of the
  251. text in the same section as <CODE>$paragraph</CODE> should be selected (included)
  252. for processing; otherwise a false value is returned.</P>
  253. <P>
  254. <HR>
  255. <H1><A NAME="exported functions">EXPORTED FUNCTIONS</A></H1>
  256. <P>The following functions are exported by this module. Please note that
  257. these are functions (not methods) and therefore <CODE>do not</CODE> take an
  258. implicit first argument.</P>
  259. <P>
  260. <HR>
  261. <H1><A NAME="podselect()"><STRONG>podselect()</STRONG></A></H1>
  262. <PRE>
  263.             podselect(\%options,@filelist);</PRE>
  264. <P><STRONG>podselect</STRONG> will print the raw (untranslated) POD paragraphs of all
  265. POD sections in the given input files specified by <CODE>@filelist</CODE>
  266. according to the given options.</P>
  267. <P>If any argument to <STRONG>podselect</STRONG> is a reference to a hash
  268. (associative array) then the values with the following keys are
  269. processed as follows:</P>
  270. <DL>
  271. <DT><STRONG><A NAME="item_%2Doutput"><STRONG>-output</STRONG></A></STRONG><BR>
  272. <DD>
  273. A string corresponding to the desired output file (or ``>&STDOUT''
  274. or ``>&STDERR''). The default is to use standard output.
  275. <P></P>
  276. <DT><STRONG><A NAME="item_%2Dsections"><STRONG>-sections</STRONG></A></STRONG><BR>
  277. <DD>
  278. A reference to an array of sections specifications (as described in
  279. <A HREF="#section specifications">SECTION SPECIFICATIONS</A>) which indicate the desired set of POD
  280. sections and subsections to be selected from input. If no section
  281. specifications are given, then all sections of the PODs are used.
  282. <P></P></DL>
  283. <P>All other arguments should correspond to the names of input files
  284. containing POD sections. A file name of ``-'' or ``<&STDIN'' will
  285. be interpeted to mean standard input (which is the default if no
  286. filenames are given).</P>
  287. <P>
  288. <HR>
  289. <H1><A NAME="private methods and data">PRIVATE METHODS AND DATA</A></H1>
  290. <P><STRONG>Pod::Select</STRONG> makes uses a number of internal methods and data fields
  291. which clients should not need to see or use. For the sake of avoiding
  292. name collisions with client data and methods, these methods and fields
  293. are briefly discussed here. Determined hackers may obtain further
  294. information about them by reading the <STRONG>Pod::Select</STRONG> source code.</P>
  295. <P>Private data fields are stored in the hash-object whose reference is
  296. returned by the <STRONG>new()</STRONG> constructor for this class. The names of all
  297. private methods and data-fields used by <STRONG>Pod::Select</STRONG> begin with a
  298. prefix of ``_'' and match the regular expression <CODE>/^_\w+$/</CODE>.</P>
  299. <P>
  300. <HR>
  301. <H1><A NAME="see also">SEE ALSO</A></H1>
  302. <P><A HREF="../../lib/Pod/Parser.html">the Pod::Parser manpage</A></P>
  303. <P>
  304. <HR>
  305. <H1><A NAME="author">AUTHOR</A></H1>
  306. <P>Brad Appleton <<A HREF="mailto:bradapp@enteract.com">bradapp@enteract.com</A>></P>
  307. <P>Based on code for <STRONG>pod2text</STRONG> written by
  308. Tom Christiansen <<A HREF="mailto:tchrist@mox.perl.com">tchrist@mox.perl.com</A>></P>
  309. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  310. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  311. <STRONG><P CLASS=block> podselect - extract selected sections of POD from input</P></STRONG>
  312. </TD></TR>
  313. </TABLE>
  314.  
  315. </BODY>
  316.  
  317. </HTML>
  318.