Commit | Line | Data |
---|---|---|
8294bf44 TC |
1 | #!perl -w |
2 | use strict; | |
3 | use Test::More; | |
4 | use ExtUtils::Manifest qw(maniread); | |
5 | use File::Temp; | |
2e3f6334 TC |
6 | eval "use Pod::Spell 1.15"; |
7 | plan skip_all => "Pod::Spell 1.15 required for spellchecking POD" if $@; | |
8 | my @pod = @ARGV; | |
9 | unless (@pod) { | |
10 | my $manifest = maniread(); | |
11 | @pod = sort grep !/^inc/ && /\.(pm|pl|pod|PL)$/, keys %$manifest; | |
12 | } | |
8294bf44 | 13 | plan tests => scalar(@pod); |
2e3f6334 | 14 | my $my_stopwords = <<'WORDS'; |
2c331f9f | 15 | API |
94995883 TC |
16 | Addi |
17 | Addi's | |
2c331f9f TC |
18 | Arnar |
19 | BMP | |
20 | Blit | |
21 | CGI | |
22 | CMYK | |
23 | CPAN | |
75e155e1 | 24 | EXIF |
2c331f9f | 25 | FreeType |
ec5d8b5c | 26 | GDI |
2c331f9f TC |
27 | GIF |
28 | HSV | |
29 | Hrafnkelsson | |
30 | ICO | |
31 | IMAGER | |
8294bf44 TC |
32 | Imager |
33 | Imager's | |
8294bf44 TC |
34 | JPEG |
35 | PNG | |
2c331f9f | 36 | PNM |
94995883 | 37 | POSIX |
2c331f9f TC |
38 | RGB |
39 | RGBA | |
8294bf44 TC |
40 | SGI |
41 | TGA | |
2c331f9f TC |
42 | TIFF |
43 | UTF-8 | |
44 | Uncategorized | |
94995883 TC |
45 | affine |
46 | allocator | |
8294bf44 | 47 | bilevel |
94995883 | 48 | chromaticities |
2c331f9f | 49 | const |
94995883 | 50 | convolve |
8294bf44 | 51 | dpi |
8294bf44 | 52 | eg |
94995883 | 53 | equalities |
67d441b2 | 54 | gaussian |
35db02fc | 55 | grayscale |
8294bf44 | 56 | ie |
8294bf44 | 57 | infix |
c18dd26e | 58 | invocant |
2c331f9f | 59 | metadata |
abffffed | 60 | multi-threaded |
24c9233d | 61 | mutex |
2c331f9f | 62 | paletted |
94995883 | 63 | parsers |
2c331f9f TC |
64 | postfix |
65 | preload | |
66 | preloading | |
67 | preloads | |
94995883 TC |
68 | quantization |
69 | quantize | |
70 | quantized | |
71 | radians | |
130225b1 | 72 | renderer |
94995883 TC |
73 | resizing |
74 | sRGB | |
75 | specular | |
76 | stereoscopy | |
d2549cc4 | 77 | tuple |
2c331f9f | 78 | unary |
94995883 | 79 | unassociated |
9d5ff8a6 | 80 | unseekable |
94995883 | 81 | untransformed |
2c331f9f | 82 | varargs |
2e3f6334 | 83 | WORDS |
8294bf44 TC |
84 | |
85 | # see for example: | |
86 | # https://bugs.launchpad.net/ubuntu/+source/aspell/+bug/71322 | |
87 | $ENV{LANG} = "C"; | |
88 | $ENV{LC_ALL} = "C"; | |
89 | for my $file (@pod) { | |
90 | my $check_fh = File::Temp->new; | |
91 | my $check_filename = $check_fh->filename; | |
2e3f6334 TC |
92 | my $work_fh = File::Temp->new; |
93 | my $work_filename = $work_fh->filename; | |
94 | open my $pod, "<", $file | |
8294bf44 | 95 | or die "Cannot open $file for spell check: $!\n"; |
2e3f6334 TC |
96 | my @local_stop; |
97 | my $stop_re = qr/\b(xxxxx)\b/; | |
98 | while (<$pod>) { | |
99 | if (/^=for\s+stopwords\s+(.*)/) { | |
100 | push @local_stop, map quotemeta, split ' ', $1; | |
101 | my $stop_re_str = join('|', @local_stop); | |
102 | $stop_re = qr/\b($stop_re_str)\b/; | |
103 | } | |
104 | else { | |
105 | s/$stop_re/ /g; | |
106 | } | |
107 | print $work_fh $_; | |
108 | } | |
109 | seek $work_fh, 0, SEEK_SET; | |
110 | my $spell = Pod::Spell->new; | |
111 | $spell->stopwords->learn_stopwords($my_stopwords); | |
112 | $spell->parse_from_filehandle($work_fh, $check_fh); | |
113 | close $work_fh; | |
8294bf44 TC |
114 | close $check_fh; |
115 | ||
116 | my @out = `aspell list <$check_filename`; | |
117 | unless (ok(@out == 0, "spell check $file")) { | |
118 | chomp @out; | |
125e8835 | 119 | diag $_ for @out; |
8294bf44 TC |
120 | print "#----\n"; |
121 | open my $fh, "<", $check_filename; | |
122 | while (<$fh>) { | |
123 | chomp; | |
124 | print "# $_\n"; | |
125 | } | |
126 | print "#----\n"; | |
127 | } | |
128 | } |