Skip to content

Commit 28f2111

Browse files
committed
Allow -n flag on method/routine docs
Previously would just revert to `more`/`less` when faced with a method/routine, now it properly passes the flag along to `MAIN` or `show-docs`.
1 parent e089b27 commit 28f2111

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

bin/p6doc

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ sub show-docs(Str $path, :$section, :$no-pager) {
6969
shell "$*EXECUTABLE-NAME -I$i --doc=SectionFilter $path $fmt-string | $pager";
7070
}
7171
else {
72+
say "launching '$*EXECUTABLE-NAME --doc $path $fmt-string | $pager'" if DEBUG;
7273
shell "$*EXECUTABLE-NAME --doc $path $fmt-string | $pager";
7374
}
7475
}
@@ -88,22 +89,18 @@ multi sub MAIN() {
8889
}
8990

9091
multi sub MAIN($docee, Bool :$n) {
91-
return MAIN($docee, :f) if defined $docee.index('.') ;
92+
return MAIN($docee, :f, :$n) if defined $docee.index('.') ;
9293
if INDEX.IO ~~ :e {
9394
my %data = EVALFILE INDEX;
9495
if %data{$docee} {
9596
my $newdoc = %data{$docee}[0][0];
96-
return MAIN($newdoc);
97+
return MAIN($newdoc, :$n);
9798
}
9899
}
99-
if $n {
100-
show-docs(locate-module($docee), :no-pager)
101-
} else {
102-
show-docs(locate-module($docee));
103-
}
100+
show-docs(locate-module($docee), :no-pager($n));
104101
}
105102

106-
multi sub MAIN($docee, Bool :$f!) {
103+
multi sub MAIN($docee, Bool :$f!, Bool :$n) {
107104
my ($package, $method) = $docee.split('.');
108105
if ! $method {
109106
my %hits;
@@ -114,7 +111,7 @@ multi sub MAIN($docee, Bool :$f!) {
114111
($package, $method) = $final-docee.split('.');
115112

116113
my $m = locate-module($package);
117-
show-docs($m, :section($method));
114+
show-docs($m, :section($method), :no-pager($n));
118115
} else {
119116
say 'In order to use unqualified sub and method names like "p6doc -f say"';
120117
say 'you will need to run "p6doc-index build" to build index.data.';
@@ -123,12 +120,12 @@ multi sub MAIN($docee, Bool :$f!) {
123120
}
124121
} else {
125122
my $m = locate-module($package);
126-
show-docs($m, :section($method));
123+
show-docs($m, :section($method), :no-pager($n));
127124
}
128125
}
129126

130-
multi sub MAIN(Str $file where $file.IO ~~ :e) {
131-
show-docs($file);
127+
multi sub MAIN(Str $file where $file.IO ~~ :e, Bool :$n) {
128+
show-docs($file, :no-pager($n));
132129
}
133130

134131
sub disambiguate-f-search( $docee, %data ) {

0 commit comments

Comments
 (0)