Skip to content

Commit

Permalink
Get all docs from Perl6::Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hinrik committed Jul 14, 2009
1 parent b5f78bd commit a968748
Show file tree
Hide file tree
Showing 39 changed files with 30 additions and 31,668 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fix a bug causing "grok s32-str" to deliver s32-abstraction instead
of s32-str
- If the pager is less(1), tell it to display colors without a fuss
- Removed all docs from the distribution, rely on Perl6::Doc instead

0.11 Mon Jul 6 23:36:06 EDT 2009
- Use PAGER environment variable if set
Expand Down
33 changes: 0 additions & 33 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,6 @@ xt/perl_critic.t
xt/perl_critic_tests.t
xt/pod_coverage.t
xt/pod.t
share/Spec/S01-overview.pod
share/Spec/S02-bits.pod
share/Spec/S03-operators.pod
share/Spec/S04-control.pod
share/Spec/S05-regex.pod
share/Spec/S06-routines.pod
share/Spec/S07-iterators.pod
share/Spec/S09-data.pod
share/Spec/S10-packages.pod
share/Spec/S11-modules.pod
share/Spec/S12-objects.pod
share/Spec/S13-overloading.pod
share/Spec/S14-roles-and-parametric-types.pod
share/Spec/S16-io.pod
share/Spec/S17-concurrency.pod
share/Spec/S19-commandline.pod
share/Spec/S21-calling-foreign-code.pod
share/Spec/S22-package-format.pod
share/Spec/S26-documentation.pod
share/Spec/S28-special-names.pod
share/Spec/S29-functions.pod
share/Spec/S31-pragmatic-modules.pod
share/Spec/S32-setting-library/Abstraction.pod
share/Spec/S32-setting-library/Basics.pod
share/Spec/S32-setting-library/Callable.pod
share/Spec/S32-setting-library/Containers.pod
share/Spec/S32-setting-library/Exception.pod
share/Spec/S32-setting-library/IO.pod
share/Spec/S32-setting-library/Numeric.pod
share/Spec/S32-setting-library/Rules.pod
share/Spec/S32-setting-library/Str.pod
share/Spec/S32-setting-library/Temporal.pod
inc/Module/Install.pm
inc/Module/Install/AuthorRequires.pm
inc/Module/Install/AuthorTests.pm
Expand All @@ -72,6 +40,5 @@ inc/Module/Install/GithubMeta.pm
inc/Module/Install/Makefile.pm
inc/Module/Install/Metadata.pm
inc/Module/Install/Scripts.pm
inc/Module/Install/Share.pm
inc/Module/Install/Win32.pm
inc/Module/Install/WriteAll.pm
2 changes: 1 addition & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ abstract ('Perl 6 documentation reader');
version_from ('lib/App/Grok.pm');
install_script ('script/grok');
no_index (directory => 't_source');
install_share ();
license ('artistic_2');
homepage ('http://svn.pugscode.org/pugs/docs/u4x/README');
githubmeta ();
requires ('Getopt::Long' => '2.33');
requires ('IO::Interactive' => '0');
requires ('File::ShareDir' => '0');
requires ('File::Temp' => '0');
requires ('Perl6::Doc' => '0.40');
requires ('Perl6::Perldoc' => '0.0.5');
requires ('Perl6::Perldoc::To::Ansi' => '0.07');
requires ('Pod::Text::Ansi' => '0.03');
Expand Down
54 changes: 28 additions & 26 deletions lib/App/Grok.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ my %opt;

sub new {
my ($package, %self) = @_;

$self{share_dir} = defined $ENV{GROK_SHAREDIR}
? $ENV{GROK_SHAREDIR}
: dist_dir('grok')
;

return bless \%self, $package;
}

Expand Down Expand Up @@ -88,7 +82,7 @@ sub read_functions {
return $self->{functions} if defined $self->{functions};

my %functions;
my $S29_file = catfile($self->{share_dir}, 'Spec', 'S29-functions.pod');
my $S29_file = catfile(dist_dir('Perl6-Doc'), 'Synopsis', 'S29-functions.pod');

## no critic (InputOutput::RequireBriefOpen)
open my $S29, '<', $S29_file or die "Can't open '$S29_file': $!";
Expand Down Expand Up @@ -137,23 +131,27 @@ sub read_functions {

sub target_index {
my ($self) = @_;
my $dir = catdir($self->{share_dir}, 'Spec');

my @index;

# synopses
my @synopses = map { (splitpath($_))[2] } glob "$dir/*.pod";
s/\.pod$// for @synopses;
push @index, @synopses;
my %docs = map {
substr($_, 0, 1) => catdir(dist_dir('Perl6-Doc'), $_)
} qw<Apocalypse Exegesis Magazine Synopsis>;

while (my ($type, $dir) = each %docs) {
my @parts = map { (splitpath($_))[2] } glob "$dir/*.pod";
s/\.pod$// for @parts;
push @index, @parts;
}

# synopsis 32
my $S32_dir = catdir($dir, 'S32-setting-library');
my $S32_dir = catdir($docs{S}, 'S32-setting-library');
my @sections = map { (splitpath($_))[2] } glob "$S32_dir/*.pod";
s/\.pod$// for @sections;
push @index, map { "S32-$_" } @sections;

# functions from synopsis 29
push @index, sort keys %{ $self->read_functions() };

return @index;
}

Expand All @@ -180,32 +178,36 @@ sub detect_source {
sub find_target_file {
my ($self, $arg) = @_;

my $target = $self->find_synopsis($arg);
my $target = $self->find_perl6_doc($arg);
$target = $self->find_module_or_program($arg) if !defined $target;

return if !defined $target;
return $target;
}

sub find_synopsis {
my ($self, $syn) = @_;
my $dir = catdir($self->{share_dir}, 'Spec');
sub find_perl6_doc {
my ($self, $doc) = @_;

my %docs = map {
substr($_, 0, 1) => catdir(dist_dir('Perl6-Doc'), $_)
} qw<Apocalypse Exegesis Magazine Synopsis>;

if (my ($section) = $syn =~ /^S32-(\S+)$/i) {
my $S32_dir = catdir($dir, 'S32-setting-library');
# S32 is split up, need to special-case it
if (my ($section) = $doc =~ /^S32-(\S+)$/i) {
my $S32_dir = catdir($docs{S}, 'S32-setting-library');
my @sections = map { (splitpath($_))[2] } glob "$S32_dir/*.pod";
my $found = first { /^$section/i } @sections;

if (defined $found) {
return catfile($S32_dir, $found);
}
}
elsif ($syn =~ /^S\d+/i) {
my @synopses = map { (splitpath($_))[2] } glob "$dir/*.pod";
my $found = first { /\Q$syn/i } @synopses;
elsif (my ($type) = $doc =~ /^(\w)\d+/i) {
my @parts = map { (splitpath($_))[2] } glob "$docs{uc $type}/*.pod";
my $found = first { /\Q$doc/i } @parts;

return if !defined $found;
return catfile($dir, $found);
return catfile($docs{uc $type}, $found);
}

return;
Expand Down Expand Up @@ -322,7 +324,7 @@ any Pod.
Takes a valid C<grok> target as an argument. If found, it will return a path
to a matching file, otherwise it returns nothing.
=head2 C<find_synopsis>
=head2 C<find_perl6_doc>
Takes the name (or a substring of a name) of a Synopsis as an argument.
Returns a path to a matching file if one is found, otherwise returns nothing.
Expand Down
165 changes: 0 additions & 165 deletions share/Spec/S01-overview.pod

This file was deleted.

Loading

0 comments on commit a968748

Please sign in to comment.