Warm tip: This article is reproduced from serverfault.com, please click

perl-如果PodSpelling是文件名的一部分,为什么PodSpelling会抱怨被忽略的单词?

(perl - Why does PodSpelling complain about an ignored word if it's part of a file name?)

发布于 2020-11-27 21:38:15

PodSpelling(通过Perlcritic运行)抱怨“ html”,即使我已将其添加到stopwords

=for stopwords html

=head2 some function

Generates an index.html page.

=cut

得到:

robert@saaz:~$ perlcritic --brutal  test.pl | grep html
Check the spelling in your POD: html at line 1, column 1.  See page 148 of PBP.  (Severity: 1)

grep在这个最小的示例中,我通过管道输出忽略了与拼写无关的其他抱怨。)

如果我将POD更改为使用C<index.html>F<index.html>,或者将其重写为a .html file,或者添加“ index.html”作为停用词,则拼写检查器很高兴。第一个对我来说有意义(不要检查代码段或文件名),但是我看不出“ index.html”和“ .html”之间的最大区别是什么。

它可以工作,=for stopwords index.html因为当它紧挨空格时会忽略该点吗?不过,我只是在猜测。

为什么我stopword html不适合“ index.html”,如果我不想使用C<...>或,该如何解决F<...>呢?

Questioner
Robert
Viewed
11
clamp 2020-11-28 16:12:44

Pod :: Wordlist的作者以这种方式实现了它。他们希望确保将诸如“ eg ”之类的缩写作为一个整体传递给拼写检查器。由于停用词的拆分和剥离是在将单词表传递给拼写检查器之前完成的,因此你不能同时拥有两者。另一方面,默认拼写检查器为aspell在我看来,无论缩写是否按期分割,缩写都可以通过检查。

因此,你可以像这样更改Pod / Wordlist.pm:

#line 129
sub _strip_a_word {
    my ($self, $word) = @_;
    my $remainder;

    # try word as-is, including possible hyphenation vs stoplist
    if ($self->is_stopword($word) ) {
        $remainder = '';
    }

        # check individual parts of hyphenated or period separated word,
        # keep whatever isn't a stopword as individual words
        # aspell will accept split words for abbreviations as well
        # 'e.g' passes like 'e g' does
    elsif ( $word =~ /-|\./ ) {
            my @keep;
            for my $part ( split /-|\./, $word ) {
                push @keep, $part if ! $self->is_stopword( $part );
            }
            $remainder = join(" ", @keep) if @keep;
    }
    # otherwise, we just keep it
    else {
        $remainder = $word;
    }
    return $remainder;
}