Access POD from another Perl 6 file
Asked Answered
I

2

7

The Perl 6 POD documentation has a section on accessing the current file's POD document by using $=pod. There is no information on accessing another file's POD document.

How can I access another file's POD structure, without altering the current file's $=pod?

Incrustation answered 22/6, 2018 at 14:58 Comment(0)
S
4

You can now do that with Pod::Load. From the README in the examples directory

  perl6 -e 'use Pod::Load; .perl.say for load("pod-load-clean.pod6")'

Please note that the Pod6 file has to be "clean", that is, not use any external module that is not generally available or it might fail.

Senskell answered 18/12, 2018 at 7:11 Comment(0)
D
2

I have created a filesystem-agnostic solution in Module::Pod (soon to be published) at [email protected]:dmaestro/Module-Pod.git

use Module::Pod;

# Get all Pod::Block::* objects in the module, from its own $=pod
my @pod = pod-from-module(<My::Module>);

Pros:

  • No direct EVALS of file code (even within Module::Pod)
  • Uses CompUnit::Repository and kin to locate the module
  • May be used with or without use-ing the module for other purposes in your code
  • If module is already loaded, you may call with its Type Object

Cons:

  • Module uses nqp: methods directly, as in Pod::Convenience (maybe not really a con?)
  • Not able to retrieve pod from *.pod files

Intended for use in Pod6-checking tests, etc.

Dorthadorthea answered 29/7, 2019 at 4:56 Comment(1)
Published to ecosystem and CPAN today.Dorthadorthea

© 2022 - 2024 — McMap. All rights reserved.