|
NAMEPod::Simple::Search - find POD documents in directory treesSYNOPSISuse Pod::Simple::Search; my $name2path = Pod::Simple::Search->new->limit_glob('LWP::*')->survey; print "Looky see what I found: ", join(' ', sort keys %$name2path), "\n"; print "LWPUA docs = ", Pod::Simple::Search->new->find('LWP::UserAgent') || "?", "\n"; DESCRIPTIONPod::Simple::Search is a class that you use for running searches for Pod files. An object of this class has several attributes (mostly options for controlling search options), and some methods for searching based on those attributes.The way to use this class is to make a new object of this class, set any options, and then call one of the search options (probably "survey" or "find"). The sections below discuss the syntaxes for doing all that. CONSTRUCTORThis class provides the one constructor, called "new". It takes no parameters:use Pod::Simple::Search; my $search = Pod::Simple::Search->new; ACCESSORSThis class defines several methods for setting (and, occasionally, reading) the contents of an object. With two exceptions (discussed at the end of this section), these attributes are just for controlling the way searches are carried out.Note that each of these return $self when you call them as "$self->whatever(value) ". That's so that you can chain together set-attribute calls like this: my $name2path = Pod::Simple::Search->new -> inc(0) -> verbose(1) -> callback(\&blab) ->survey(@there); ...which works exactly as if you'd done this: my $search = Pod::Simple::Search->new; $search->inc(0); $search->verbose(1); $search->callback(\&blab); my $name2path = $search->survey(@there);
MAIN SEARCH METHODSOnce you've actually set any options you want (if any), you can go ahead and use the following methods to search for Pod files in particular ways."$search->survey( @directories )"The method "survey" searches for POD documents in a given set of files and/or directories. This runs the search according to the various options set by the accessors above. (For example, if the "inc" attribute is on, as it is by default, then the perl @INC directories are implicitly added to the list of directories (if any) that you specify.)The return value of "survey" is two hashes:
Besides saving these hashes as the hashref attributes "name2path" and "path2name", calling this function also returns these hashrefs. In list context, the return value of "$search->survey" is the list "(\%name2path, \%path2name)". In scalar context, the return value is "\%name2path". Or you can just call this in void context. Regardless of calling context, calling "survey" saves its results in its "name2path" and "path2name" attributes. E.g., when searching in $HOME/perl5lib, the file $HOME/perl5lib/MyModule.pm would get the POD name MyModule, whereas $HOME/perl5lib/Myclass/Subclass.pm would be Myclass::Subclass. The name information can be used for POD translators. Only text files containing at least one valid POD command are found. In verbose mode, a warning is printed if shadows are found (i.e., more than one POD file with the same POD name is found, e.g. CPAN.pm in different directories). This usually indicates duplicate occurrences of modules in the @INC search path, which is occasionally inadvertent (but is often simply a case of a user's path dir having a more recent version than the system's general path dirs in general.) The options to this argument is a list of either directories that are searched recursively, or files. (Usually you wouldn't specify files, but just dirs.) Or you can just specify an empty-list, as in $name2path; with the "inc" option on, as it is by default. The POD names of files are the plain basenames with any Perl-like extension (.pm, .pl, .pod) stripped, and path separators replaced by "::"'s. Calling Pod::Simple::Search->search(...) is short for Pod::Simple::Search->new->search(...). That is, a throwaway object with default attribute values is used. "$search->simplify_name( $str )"The method simplify_name is equivalent to basename, but also strips Perl-like extensions (.pm, .pl, .pod) and extensions like .bat, .cmd on Win32 and OS/2, or .com on VMS, respectively."$search->find( $pod )""$search->find( $pod, @search_dirs )"Returns the location of a Pod file, given a Pod/module/script name (like "Foo::Bar" or "perlvar" or "perldoc"), and an idea of what files/directories to look in. It searches according to the various options set by the accessors above. (For example, if the "inc" attribute is on, as it is by default, then the perl @INC directories are implicitly added to the list of directories (if any) that you specify.)This returns the full path of the first occurrence to the file. Package names (eg 'A::B') are automatically converted to directory names in the selected directory. Additionally, '.pm', '.pl' and '.pod' are automatically appended to the search as required. (So, for example, under Unix, "A::B" is converted to "somedir/A/B.pm", "somedir/A/B.pod", or "somedir/A/B.pl", as appropriate.) If no such Pod file is found, this method returns undef. If any of the given search directories contains a pod/ subdirectory, then it is searched. (That's how we manage to find perlfunc, for example, which is usually in pod/perlfunc in most Perl dists.) The "verbose" and "inc" attributes influence the behavior of this search; notably, "inc", if true, adds @INC and also $Config::Config{'scriptdir'} to the list of directories to search. It is common to simply say "$filename = Pod::Simple::Search-> new ->find("perlvar")" so that just the @INC (well, and scriptdir) directories are searched. (This happens because the "inc" attribute is true by default.) Calling Pod::Simple::Search->find(...) is short for Pod::Simple::Search->new->find(...). That is, a throwaway object with default attribute values is used. "$self->contains_pod( $file )"Returns true if the supplied filename (not POD module) contains some Pod documentation.SUPPORTQuestions or discussion about POD and Pod::Simple should be sent to the pod-people@perl.org mail list. Send an empty email to pod-people-subscribe@perl.org to subscribe.This module is managed in an open GitHub repository, <https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or to clone <git://github.com/perl-pod/pod-simple.git> and send patches! Patches against Pod::Simple are welcome. Please send bug reports to <bug-pod-simple@rt.cpan.org>. COPYRIGHT AND DISCLAIMERSCopyright (c) 2002 Sean M. Burke.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. AUTHORPod::Simple was created by Sean M. Burke <sburke@cpan.org> with code borrowed from Marek Rouchal's Pod::Find, which in turn heavily borrowed code from Nick Ing-Simmons' "PodToHtml".But don't bother him, he's retired. Pod::Simple is maintained by:
Visit the GSP FreeBSD Man Page Interface. |