perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [Patch] replace glue_pods with an ExtUtils::MakeMaker solution
Date Thu, 12 Aug 2004 22:34:51 GMT
Philippe M. Chiasson wrote:
> As stas pointed out in todo/release, since glue_pods is kinda broken 
> right now,
> why not simply use ExtUtils::MakeMaker to manify and install all pods in 
> docs/api ?

There are several reasons:

1) perldoc won't find the docs. I think that's the case even if you 
install .pod files next to .pm files. But I didn't check recently.

2) manpages will get installed over the mp1 manpages and vice versa.

in any case, if we drop glue_pod, the simplest approach is probably to 
just have docs/api/Makefile.PL and let it do the job of finding .pod 
files. There was a provision for that already (that's how I did it in 
first place), before replacing it with glue_pods.

> ------------------------------------------------------------------------
> 
> Index: Makefile.PL
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
> retrieving revision 1.153
> diff -u -I$Id -r1.153 Makefile.PL
> --- Makefile.PL	6 Aug 2004 19:35:34 -0000	1.153
> +++ Makefile.PL	10 Aug 2004 19:44:37 -0000
> @@ -28,6 +28,7 @@
>  use File::Spec::Functions;
>  use DirHandle ();
>  use File::Copy 'cp';
> +use File::Find ();
>  use File::Basename 'basename';
>  
>  use Apache::Build ();
> @@ -70,6 +71,7 @@
>      NO_META       => 1,
>      ABSTRACT_FROM => 'lib/mod_perl.pm',
>      EXE_FILES     => \@exe_files,
> +    MAN1PODS      => find_pods(),
>      DEFINE        => get_DEFINE(),
>      macro         => {
>          MODPERL_SRC        => $code->path,
> @@ -109,6 +111,24 @@
>          map { (/^DEFINE=(.*)/ && ($opt_define .= " $1")) ? undef : $_ } @ARGV;
>  
>      return $opt_define;
> +}
> +
> +my $pods;
> +#Find pods to manify under docs/api
> +sub find_pods {
> +    File::Find::find ( \&wanted_pods, catdir 'docs','api');
> +    return $pods;
> +
> +    sub wanted_pods {
> +        my $ext = qr/\.pod$/;
> +        if (/$ext/) {
> +            my ($filename, $path) = File::Basename::fileparse($File::Find::name, $ext);
> +            my (undef, undef, @dirs) = File::Spec->splitdir($path); pop @dirs;
> +            my $name = join '::', (@dirs, $filename);
> +            my $man = catdir('blib','man3', $name.'.pm3');
> +            $pods->{$File::Find::name} = $man;
> +        }
> +    }
>  }
>  
>  sub configure {
> Index: lib/ModPerl/BuildMM.pm
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/lib/ModPerl/BuildMM.pm,v
> retrieving revision 1.18
> diff -u -I$Id -r1.18 BuildMM.pm
> --- lib/ModPerl/BuildMM.pm	1 Aug 2004 19:44:00 -0000	1.18
> +++ lib/ModPerl/BuildMM.pm	10 Aug 2004 19:44:37 -0000
> @@ -121,7 +121,7 @@
>  
>      my $clean_files = (exists $args{clean} && exists $args{clean}{FILES}) ?
>          $args{clean}{FILES} : '';
> -    $clean_files .= " glue_pods"; # cleanup the dependency target
> +
>      $args{clean}{FILES} = $clean_files;
>  
>      ExtUtils::MakeMaker::WriteMakefile(@opts, %args);
> @@ -170,73 +170,15 @@
>      my $self = shift;
>      my $string = $self->MM::top_targets;
>  
> -    ModPerl::MM::add_dep_after(\$string, "pure_all", pm_to_blib => 'glue_pods');
> -
>      return $string;
>  }
>  
>  sub ModPerl::BuildMM::MY::postamble {
>      my $self = shift;
> +    my $string = $self->MM::postamble;
>  
> -    my $doc_root = catdir Cwd::getcwd(), "docs", "api";
> -
> -    my @targets = ();
> -
> -    # add the code to glue the existing pods to the .pm files in blib
> -    my @target = ('glue_pods:');
> -
> -    if (-d $doc_root) {
> -        while (my ($pm, $blib) = each %{$self->{PM}}) {
> -            my $pod = catdir(
> -                (splitdir($blib))[-2 .. -1]);
> -            $pod =~ s/\.pm/\.pod/;
> -            my $podpath = catfile $doc_root, $pod;
> -            next unless -r $podpath;
> -
> -            push @target, 
> -                '$(FULLPERL) -I$(INST_LIB) ' .
> -                "-I$apache_test_dir -MModPerl::BuildMM " .
> -                "-e ModPerl::BuildMM::glue_pod $pm $podpath $blib";
> -        }
> -
> -        push @target, $self->{NOECHO} . '$(TOUCH) $@';
> -    }
> -    else {
> -        # we don't have the docs sub-cvs repository extracted, skip
> -        # the docs gluing
> -        push @target, $self->{NOECHO} . '$(NOOP)';
> -    }
> -    push @targets, join "\n\t", @target;
> -
> -#    # next target: cleanup the dependency file
> -#    @target = ('glue_pods_clean:');
> -#    push @target, '$(RM_F) glue_pods';
> -#    push @targets, join "\n\t", @target;
> -
> -    return join "\n\n", @targets, '';
> -}
> -
> -sub glue_pod {
> -
> -    die "expecting 3 arguments: pm, pod, dst" unless @ARGV == 3;
> -    my($pm, $pod, $dst) = @ARGV;
> -
> -    # have we already glued the doc?
> -    exit 0 unless -s $pm == -s $dst;
> +    return $string;
>  
> -    # ExtUtils::Install::pm_to_blib removes the 'w' perms, so we can't
> -    # just append the doc there
> -    my $orig_mode = (stat $dst)[2];
> -    my $rw_mode   = 0666;
> -
> -    chmod $rw_mode, $dst      or die "Can't chmod $rw_mode $dst: $!";
> -    open my $pod_fh, "<$pod"  or die "Can't open $pod: $!";
> -    open my $dst_fh, ">>$dst" or die "Can't open $dst: $!";
> -    print $dst_fh (<$pod_fh>);
> -    close $pod_fh;
> -    close $dst_fh;
> -    # restore the perms
> -    chmod $orig_mode, $dst    or die "Can't chmod $orig_mode $dst: $!";
>  }
>  
>  sub ModPerl::BuildMM::MY::post_initialize {


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message