【发布时间】:2019-03-10 02:46:53
【问题描述】:
假设我在Foo 目录中有以下两个.pm6 文件:
-
Vehicle.pm6- 车辆接口。
=TITLE C<Vehicle> interface
unit role Foo::Vehicle;
#| Get the vehicle to move
method run(--> Nil) { ... }
#| Get fuel into the vehicle
method get-fuel(--> Nil) { ... }
-
Car.pm6- 一个实现Vehicle接口的类。
=TITLE C<Car> class
use Foo::Vehicle;
unit class Foo::Car does Foo::Vehicle;
has $!speed = 2;
#| Get the car to move
method run(--> Str) {
"{::?CLASS.perl} is moving at {$!speed}km/h."
}
#| Get fuel into the car
method get-fuel(--> Str) {
"Getting some fuel..."
}
在与Foo 相同的级别,我有一个main.p6 文件,它实例化Car 类:
#!/usr/bin/env perl6
use lib '.';
use Foo::Car;
my Foo::Car $car .= new;
say $car.run; #=> Foo::Car is moving at 2km/h.
say $car.get-fuel; #=> Getting some fuel...
到目前为止,一切正常。但是,当我尝试从Car.pm6(使用p6doc Foo/Car.pm6)获取文档时,出现以下错误:
===SORRY!===
Could not find Foo::Vehicle at line 1 in:
/home/cosmos/.perl6
/opt/rakudo/install/share/perl6/site
/opt/rakudo/install/share/perl6/vendor
/opt/rakudo/install/share/perl6
CompUnit::Repository::AbsolutePath<94376788126208>
CompUnit::Repository::NQP<94376768814296>
CompUnit::Repository::Perl5<94376768814336>
【问题讨论】:
-
由于您在脚本中使用
use lib '.',我认为您需要将当前目录添加到perl6 搜索路径中,以便p6doc找到您的模块 -
设置 perl6 搜索路径到当前目录 do:
PERL6LIB=. p6doc Foo/Car.pm6
标签: raku