Skip to content

Commit 1d9a369

Browse files
committed
Added an 'extra_manify_args' parameter to facilitate man pages
containing Unicode. [Joenio Costa]
1 parent 47054f3 commit 1d9a369

File tree

4 files changed

+76
-3
lines changed

4 files changed

+76
-3
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Revision history for Perl extension Module::Build.
1313
- Removed dependence on IO::File, replacing it with safe invocations
1414
of open(). [Sven Dowideit]
1515

16+
- Added an 'extra_manify_args' parameter to facilitate man pages
17+
containing Unicode. [Joenio Costa]
18+
1619
0.4005 - Thu Apr 25 15:10:14 CEST 2013
1720

1821
[ENHANCEMENTS]

lib/Module/Build/API.pod

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ To link your XS code against glib you might write something like:
395395
extra_linker_flags => scalar `glib-config --libs`,
396396
);
397397

398+
=item extra_manify_args
399+
400+
[version 0.4006]
401+
402+
Any extra arguments to pass to C<< Pod::Man->new() >> when building
403+
man pages. One common choice might be C<< utf8 => 1 >> to get Unicode
404+
support.
405+
398406
=item get_options
399407

400408
[version 0.26]

lib/Module/Build/Base.pm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ __PACKAGE__->add_property($_) for qw(
10061006
verbose
10071007
debug
10081008
xs_files
1009+
extra_manify_args
10091010
);
10101011

10111012
sub config {
@@ -3237,19 +3238,22 @@ sub ACTION_manpages {
32373238

32383239
$self->depends_on('code');
32393240

3241+
my %extra_manify_args = $self->{properties}{'extra_manify_args'} ? %{ $self->{properties}{'extra_manify_args'} } : ();
3242+
32403243
foreach my $type ( qw(bin lib) ) {
32413244
next unless ( $self->invoked_action eq 'manpages' || $self->_is_default_installable("${type}doc"));
32423245
my $files = $self->_find_pods( $self->{properties}{"${type}doc_dirs"},
32433246
exclude => [ $self->file_qr('\.bat$') ] );
32443247
next unless %$files;
32453248

32463249
my $sub = $self->can("manify_${type}_pods");
3247-
$self->$sub() if defined( $sub );
3250+
$self->$sub( %extra_manify_args ) if defined( $sub );
32483251
}
32493252
}
32503253

32513254
sub manify_bin_pods {
32523255
my $self = shift;
3256+
my %podman_args = (section => 1, @_); # binaries go in section 1
32533257

32543258
my $files = $self->_find_pods( $self->{properties}{bindoc_dirs},
32553259
exclude => [ $self->file_qr('\.bat$') ] );
@@ -3262,7 +3266,7 @@ sub manify_bin_pods {
32623266
foreach my $file (keys %$files) {
32633267
# Pod::Simple based parsers only support one document per instance.
32643268
# This is expected to change in a future version (Pod::Simple > 3.03).
3265-
my $parser = Pod::Man->new( section => 1 ); # binaries go in section 1
3269+
my $parser = Pod::Man->new( %podman_args );
32663270
my $manpage = $self->man1page_name( $file ) . '.' .
32673271
$self->config( 'man1ext' );
32683272
my $outfile = File::Spec->catfile($mandir, $manpage);
@@ -3276,6 +3280,7 @@ sub manify_bin_pods {
32763280

32773281
sub manify_lib_pods {
32783282
my $self = shift;
3283+
my %podman_args = (section => 3, @_); # libraries go in section 3
32793284

32803285
my $files = $self->_find_pods($self->{properties}{libdoc_dirs});
32813286
return unless keys %$files;
@@ -3287,7 +3292,7 @@ sub manify_lib_pods {
32873292
while (my ($file, $relfile) = each %$files) {
32883293
# Pod::Simple based parsers only support one document per instance.
32893294
# This is expected to change in a future version (Pod::Simple > 3.03).
3290-
my $parser = Pod::Man->new( section => 3 ); # libraries go in section 3
3295+
my $parser = Pod::Man->new( %podman_args );
32913296
my $manpage = $self->man3page_name( $relfile ) . '.' .
32923297
$self->config( 'man3ext' );
32933298
my $outfile = File::Spec->catfile( $mandir, $manpage);

t/manifypods_with_utf8.t

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package ManifypodsWithUtf8;
2+
use strict;
3+
use Test::More;
4+
5+
use lib 't/lib';
6+
blib_load('Module::Build');
7+
blib_load('Module::Build::ConfigData');
8+
9+
SKIP: {
10+
unless ( Module::Build::ConfigData->feature('manpage_support') ) {
11+
skip 'manpage_support feature is not enabled';
12+
}
13+
}
14+
15+
use MBTest tests => 1;
16+
use File::Spec::Functions qw( catdir );
17+
18+
use Cwd ();
19+
my $cwd = Cwd::cwd;
20+
my $tmp = MBTest->tmpdir;
21+
22+
use DistGen;
23+
my $dist = DistGen->new( dir => $tmp );
24+
$dist->add_file( 'lib/Simple/PodWithUtf8.pod', <<'---' );
25+
=head1 NAME
26+
27+
Simple::PodWithUtf8 - POD with some (ç á à ô) special chars
28+
29+
=cut
30+
---
31+
$dist->regen;
32+
$dist->chdir_in;
33+
34+
my $destdir = catdir($cwd, 't', 'install_test' . $$);
35+
36+
my $mb = Module::Build->new(
37+
module_name => $dist->name,
38+
install_base => $destdir,
39+
40+
# need default install paths to ensure manpages & HTML get generated
41+
installdirs => 'site',
42+
extra_manify_args => { utf8 => 1 },
43+
);
44+
$mb->add_to_cleanup($destdir);
45+
46+
47+
$mb->dispatch('build');
48+
my $sep = $mb->manpage_separator;
49+
my $ext3 = $mb->config('man3ext');
50+
my $to = File::Spec->catfile('blib', 'libdoc', "Simple${sep}PodWithUtf8.${ext3}");
51+
52+
open my $pod, '<:utf8', $to;
53+
undef $/; my $pod_content = <$pod>;
54+
close $pod;
55+
56+
ok $pod_content =~ qr/ \(ç á à ô\) /, "POD should contain special characters";
57+

0 commit comments

Comments
 (0)