不要使用p6doc显示声明符块 [英] Don't show declarator blocks with p6doc

查看:72
本文介绍了不要使用p6doc显示声明符块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个小示例文件来了解有关Perl 6 POD的更多信息,并且我正在使用 p6doc 从POD文档中呈现一个小的手册页。但是, p6doc 也会尝试解析POD文档外部的声明符块。在输出中看起来并不特别好。使用 p6doc 时是否可以忽略声明程序块?

I've written a small example file to learn more about Perl 6 POD, and I'm using p6doc to render a small manual page from the POD document. However, p6doc also tries to parse the declarator blocks outside the POD document. This doesn't look particularly great in the output. Is there a way to ignore the declarator blocks when using p6doc?

我正在使用的代码示例为:

The code sample I'm using is:

#! /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 输出中删除。

Everything before the NAME part is what I want to remove from the p6doc output.

推荐答案


声明符会阻止POD文档之外。

declarator blocks outside the POD document.

一些小事情似乎还是值得一提的:

A couple minor things that still seem worth a quick mention first:


  • 将其称为Pod(或Pod或Pod6或POD6)而不是POD被认为是最佳做法,以将其与P5的POD区别开来,因为它不会倒退P6与P5不向后兼容;

  • It's considered best practice to call it pod (or Pod or Pod6 or POD6) rather than POD to distinguish it from P5's POD because it's not backwards compatible, in the same way P6 isn't backwards compatible with P5;

语法 = begin pod ... = end pod 不声明 pod文档。它声明了一个Pod块,它是构成整个Pod文档的众多块之一。您可以有几个。之所以这样说是因为声明符块也是pod块。这就是为什么它们被包括在内的原因。

The syntax =begin pod ... =end pod doesn't declare "the pod document". It declares a pod block that's one of many that comprise the overall pod document. You can have several of them. And the reason for mentioning this is because declarator blocks are also pod blocks. This is why they get included.


是否有一种方法可以忽略声明符块使用 p6doc 时?

您可以通过过滤器在shell命令级别。

You could run the output through a filter at the shell command level.

但请参阅我的下一条注释,以寻求一种更好的方法。

But see my next comment for what's likely a better way.


我正在使用 p6doc

p6doc perl6 --doc 的包装。

perl6 --doc 提供与您在问题中显示的结果完全相同的结果,但是具有输出后处理选项(并且不仅限于已安装的模块)。

perl6 --doc provides exactly the same result as you've shown in your question, but has an output post-processing option (and isn't limited to installed modules only).

假设您可以改用 perl6 --doc 来代替:

Assuming you can switch to using perl6 --doc instead:

perl6 -doc ,不带-doc 选项,使用默认广告连播输出过滤器

perl6 -doc, without an argument to the --doc option, uses the default pod output filter.

使用 perl6 --doc = MyFilter.pm6 ,您可以通过已安装的自定义过滤器模块<$运行Pod c $ c> Pod :: To :: MyFilter.pm6 。

Using perl6 --doc=MyFilter.pm6 you can run the pod through an installed custom filter module Pod::To::MyFilter.pm6.

请参见在modules.perl6.org中搜索 pod :: to 可以用作示例的过滤器的完整列表。

See a search of modules.perl6.org for pod::to for a full list of filters that you can use as examples.

这篇关于不要使用p6doc显示声明符块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆