Skip to content

Commit 8093e18

Browse files
committed
experimental -f support for methods if index.data exists
1 parent c24c97d commit 8093e18

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bin/p6doc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,18 @@ multi sub MAIN($docee) {
8282
multi sub MAIN($docee, Bool :$f!) {
8383
my ($package, $method) = $docee.split('.');
8484
unless $method {
85-
say 'unqualified sub and method names are not yet implemented';
86-
say 'For example use "p6doc -f Str.split" instead of "p6doc -f split" for now';
85+
if 'index.data'.IO ~~ :e {
86+
my %data = EVAL slurp 'index.data';
87+
my $ndocee = "method "~$docee;
88+
if %data{$ndocee} {
89+
my $newdoc = %data{$ndocee}[0][0] ~ "." ~ $docee;
90+
return MAIN($newdoc, :f);
91+
}
92+
show-docs(locate-module($docee));
93+
}
94+
say 'Unqualified sub and method names like "p6doc -f say" are experimental';
95+
say 'in order to use them you will need to run index.p6 to build index.data';
96+
say 'otherwise use "p6doc -f Str.split" instead of "p6doc -f split" for now';
8797
exit 2;
8898
}
8999
my $m = locate-module($package);

index.p6

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ multi sub MAIN('index') {
2424
#if $row ~~ /^\=(item|head\d) \s+ X\<(.*)\> \s*$/ {
2525
if $row ~~ /^\=(item|head\d) \s+ (.*?) \s*$/ {
2626
$section = $1.Str;
27-
$section.=subst(/\|/,"",:g);
2827
%words{$section}.push([$pod, $section]);
2928
}
3029
if $row ~~ /X\<(.*?)\>/ and $section {

0 commit comments

Comments
 (0)