Skip to content

Commit 28e6394

Browse files
committed
teach p6doc about the existance of panda installed precomp ecosystem modules. Unlikely to work with zef
1 parent 74e295f commit 28e6394

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

bin/p6doc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env perl6
22
use MONKEY-SEE-NO-EVAL; # until we have a better serialisation
3+
use JSON::Fast;
4+
use Panda::Installer;
35

46
my $PROGRAM-NAME="p6doc";
57

@@ -43,6 +45,12 @@ sub locate-module(Str $modulename) {
4345
my @candidates = (search-paths() X~ </ Type/ Language/> X~ module-names($modulename).list);
4446
DEBUG and warn :@candidates.perl;
4547
my $m = @candidates.first: *.IO.f;
48+
49+
unless $m.defined {
50+
# not "core" pod now try for panda installed module XXX not zef
51+
$m = locate-curli-module($modulename);
52+
}
53+
4654
unless $m.defined {
4755
my $message = join "\n",
4856
"Cannot locate $modulename in any of the following paths:",
@@ -219,4 +227,23 @@ sub prompt-with-options( %options, %found ) {
219227
return $final-docee;
220228
}
221229

230+
sub locate-curli-module($module) {
231+
my $prefix = Panda::Installer.new.default-prefix();
232+
my $dist = $prefix ~ '/dist';
233+
my $hdist;
234+
my @modules;
235+
for dir($dist) -> $f {
236+
my $d = from-json $f.slurp;
237+
my @keys = $d<provides>.keys.list;
238+
$hdist{$_} = $d<provides>{$_} for @keys;
239+
@modules.append: @keys;
240+
}
241+
242+
if any(@modules) eq $module {
243+
my $sha = $hdist{$module}<pm><file>;
244+
return "{$prefix}/sources/{$sha}";
245+
}
246+
return;
247+
}
248+
222249
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)