]>
iEval git - zeal.git/blob - lib/Zeal.pm
8 our $VERSION = '0.000_003';
10 use File
::Spec
::Functions qw
/catfile/;
16 my ($class, $path) = @_;
17 $path //= $ENV{ZEAL_PATH
};
18 my $self = bless {sets
=> {}}, $class;
20 $self->add($_) for split /:/, $path;
26 my ($self, $path) = @_;
27 return unless -d
$path;
28 if ($path =~ /[.]docset$/) {
29 my $ds = Zeal
::Docset
->new($path);
30 $self->{sets
}{$ds->family} //= [];
31 push @
{$self->{sets
}{$ds->family}}, $ds;
35 my @entries = grep { !/^[.]{1,2}$/ } readdir $dir;
37 $self->add(catfile
$path, $_) for @entries
42 my ($self, $family) = @_;
43 return map { @
$_ } values %{$self->{sets
}} unless $family;
44 die "No docsets in family '$family'\n" unless $self->{sets
}{$family};
45 @
{$self->{sets
}{$family}}
49 my ($self, $query, $family) = @_;
50 ($family, $query) = split /:/, $query, 2 if !$family && $query =~ /^\w+:[^:]/;
51 my @res = map { $_->query($query) } $self->sets($family);
52 wantarray ?
@res : $res[0]
62 Zeal - Read and query Dash/Zeal docsets
67 my $zeal = Zeal->new("/home/mgv/docsets/:/home/mgv/something.docset");
68 $zeal->add('/home/mgv/somethingelse.docset'); # Add another docset
69 $zeal->add('/home/mgv/moredocsets/'); # Add a directory containing docsets
71 my $doc = $zeal->query('length'); # Documentation for 'length' in all docsets
72 my @docs = $zeal->query('Test::%', 'perl'); # Documentation for all Test:: perl modules
73 @docs = $zeal->query('perl:Test::%); # Alternative syntax
77 Dash is an offline API documentation browser. Zeal.pm is a module for
78 reading and querying Dash documentation sets.
80 This module queries multiple docsets. If you only have one docset, you
81 should use the L<Zeal::Docset> module directly.
87 =item Zeal->B<new>([I<$path>])
89 Create a new Zeal object. I<$path> is an optional colon delimited
90 string for initializing the object. Each of its components is
91 recursively scanned for docsets (and can also be a docset itself). If
92 I<$path> is not provided, the value of I<$ENV{ZEAL_PATH}> (if defined)
95 =item $zeal->B<add>(I<$path>)
97 Recursively scan a path for docsets, adding them to this object.
99 =item $zeal->B<sets>([I<$family>])
101 Return a list of docsets (L<Zeal::Docset> objects) in the given
102 family, or in all families if I<$family> is not provided.
104 =item $zeal->B<query>(I<"$family:$query">)
106 =item $zeal->B<query>(I<$query>, [I<$family>])
108 Return a list of documents (L<Zeal::Document> objects) matching a
109 query, optionally restricted to a family. In scalar context only one
110 such document is returned. I<$query> is a SQL LIKE condition.
116 L<http://kapeli.com/dash>, L<http://zealdocs.org>
120 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
122 =head1 COPYRIGHT AND LICENSE
124 Copyright (C) 2014-2015 by Marius Gavrilescu
126 This library is free software; you can redistribute it and/or modify
127 it under the same terms as Perl itself, either Perl version 5.20.1 or,
128 at your option, any later version of Perl 5 you may have available.
This page took 0.059739 seconds and 4 git commands to generate.