[Module-build-general] Patch to manpage creation code
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-09-25 14:18:13
|
Hi,
I had a quick look at the man3page code surrounding the current
discussion of separator strings, and I just applied the following
patch. It does two things:
* Fixes a problem with File::Spec usage in man3page_name, which wasn't
dealing with the volume or file portions correctly for certain platforms
* No longer assumes that pods are under 'blib/lib' or 'blib/arch'
It doesn't have much bearing on your current discussion of separators,
but since it's the same area of code I thought I'd let you know.
-Ken
Index: lib/Module/Build/Base.pm
===================================================================
RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -r1.197 -r1.198
--- lib/Module/Build/Base.pm 21 Sep 2003 03:30:49 -0000 1.197
+++ lib/Module/Build/Base.pm 25 Sep 2003 14:10:33 -0000 1.198
@@ -1302,8 +1302,8 @@
my $mandir = File::Spec->catdir( $self->blib, 'libdoc' );
File::Path::mkpath( $mandir, 0, 0777 );
- foreach my $file (keys %$files) {
- my $manpage = $self->man3page_name( $file ) . '.' .
$self->{config}{man3ext};
+ while (my ($file, $relfile) = each %$files) {
+ my $manpage = $self->man3page_name( $relfile ) . '.' .
$self->{config}{man3ext};
my $outfile = File::Spec->catfile( $mandir, $manpage);
next if $self->up_to_date( $file, $outfile );
print "Manifying $file -> $outfile\n";
@@ -1318,7 +1318,7 @@
foreach my $spec (@$dirs) {
my $dir = $self->localize_file_path($spec);
next unless -e $dir;
- do { $files{$_} = $_ if $self->contains_pod( $_ ) }
+ do { $files{$_} = File::Spec->abs2rel($_, $dir) if
$self->contains_pod( $_ ) }
for @{ $self->rscan_dir( $dir ) };
}
return \%files;
@@ -1348,17 +1348,13 @@
# -spurkis
sub man3page_name {
my $self = shift;
- my $file = File::Spec->canonpath( shift ); # clean up file path
- my @dirs = File::Spec->splitdir( $file );
-
- # more clean up - assume all man3 pods are under 'blib/lib' or
'blib/arch'
- # to avoid the complexity found in Pod::Man::begin_pod()
- shift @dirs while ($dirs[0] =~ /^(?:blib|lib|arch)$/i);
-
- # remove known exts from the base name
- $dirs[-1] =~ s/\.p(?:od|m|l)\z//i;
-
- return join( $self->manpage_separator, @dirs );
+ my ($vol, $dirs, $file) = File::Spec->splitpath( shift );
+ my @dirs = File::Spec->splitdir( File::Spec->canonpath($dirs) );
+
+ # Remove known exts from the base name
+ $file =~ s/\.p(?:od|m|l)\z//i;
+
+ return join( $self->manpage_separator, @dirs, $file );
}
sub manpage_separator {
|