为什么Test :: Spelling标记函数/方法名称有拼写错误?

时间:2012-09-26 09:54:57

标签: perl spell-checking pod

假设我在test.pm中有这个虚拟的Perl包:

package test;

use strict;
use warnings;

=head1 DESCRIPTION

=head2 env

Return the environment name.

=cut

sub env { return "environment name"; }

=head2 hst

Return the history file name.

=cut

sub hst { return "history file"; }

=head2 hst_dir

Return the directory containing the history file.

=cut

sub hst_dir { return "history directory"; }

1;

然后,我使用Test::Spelling ...

从命令行运行拼写检查
$ perl -MTest::More -MTest::Spelling \
> -e 'pod_file_spelling_ok("test.pm", "spell check"); done_testing;'

...,我的函数名称envhst被标记为拼写错误,但hst_dir被接受:

not ok 1 - spell check
#   Failed test 'spell check'
#   at -e line 1.
# Errors:
#     env
#     hst
1..1
# Looks like you failed 1 test of 1.

我知道我可以列出add_stopwords()的自定义词典,但在我看来,功能名称根本不应该进行拼写检查。

我是否遗漏了文档中的一些细则?

1 个答案:

答案 0 :(得分:4)

你是在拼写你的POD,而不是你的代码。

Test::Spelling看到了:

=head2 env
=head2 hst

怎么知道那是函数名(不是它完全知道函数名的概念)?

它确实将hst_dir视为perlish关键字,因为下划线,whixh不是单词中的普通字符。但这是最好的,没有停止的话......