我编写了一个小示例文件来了解有关 Perl 6 POD 的更多信息,我正在使用 p6doc
从 POD 文档中呈现一个小的手册页。但是,p6doc
还尝试解析 POD 文档之外的声明符 block 。这在输出中看起来并不是特别好。使用 p6doc
时有没有办法忽略声明符 block ? ?
我正在使用的代码示例是:
#! /usr/bin/env perl6
use v6.c;
#| Greet people on the command line.
sub MAIN (
#| A name to greet.
$names,
#| Optional. Additional names to greet.
*@names,
) {
*
}
=begin pod
=NAME greeter
=AUTHOR Patrick Spek
=VERSION 0.0.1
The greeter application greets someone via a terminal. At least 1 name is
required, but multiple names can be given to greet many people in one go.
=end pod
p6doc
给出的输出是:sub MAIN(
$names, # A name to greet.
*@names, # Optional. Additional names to greet.
)
Greet people on the command line.
class $names
A name to greet.
class *@names
Optional. Additional names to greet.
NAME
greeter
AUTHOR
Patrick Spek
VERSION
0.0.1
The greeter application greets someone via a terminal. At least 1 name is
required, but multiple names can be given to greet many people in one go.
NAME
之前的所有内容部分是我想从 p6doc
中删除的内容输出。
最佳答案
declarator blocks outside the POD document.
一些小事似乎仍然值得首先快速提及:
=begin pod ... =end pod
没有声明“pod 文档”。它声明了一个 pod block ,它是构成整个 pod 文档的众多 block 之一。你可以有几个。之所以提到这一点,是因为声明器 block 也是 pod block 。这就是他们被包括在内的原因。 Is there a way to ignore the declarator blocks when using
p6doc
?
您可以通过 shell 命令级别的过滤器运行输出。
但请参阅我的下一条评论,了解可能是更好的方法。
I'm using
p6doc
p6doc
是 perl6 --doc
的包装器.perl6 --doc
提供与您在问题中显示的完全相同的结果,但具有输出后处理选项(并且不仅限于已安装的模块)。假设您可以切换到使用
perl6 --doc
反而:perl6 -doc
, 没有参数到 --doc
选项,使用 the default pod output filter .使用
perl6 --doc=MyFilter.pm6
您可以通过安装的自定义过滤器模块运行 pod Pod::To::MyFilter.pm6
.见 a search of modules.perl6.org for
pod::to
获取可用作示例的过滤器的完整列表。
关于documentation - 不要使用 p6doc 显示声明符 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50983870/