在Perl 6的POD文档对使用访问当前文件的POD文档一节$=pod.没有关于访问另一个文件的POD文档的信息.
如何在不改变当前文件的情况下访问另一个文件的POD结构$=pod?
我找不到正确访问已安装发行版资源的方法.例如,动态加载模块时:
require ::($module);
获取它的一种方法%?RESOURCES是让模块有一个可以返回此哈希的sub:
sub resources { %?RESOURCES }
但这增加了样板代码.
另一种方法是深度扫描$*REPO和获取模块的分布元.
有没有更好的选择来完成这项任务?
假设我.pm6在目录中有以下两个文件Foo:
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) { ... }
Run Code Online (Sandbox Code Playgroud)
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) …Run Code Online (Sandbox Code Playgroud)