From: Peter Rabbitson Date: Mon, 17 Dec 2012 07:52:13 +0000 (+0100) Subject: Use plain old file concat for the dbicadmin pod-injection X-Git-Tag: v0.08205~42 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2633789f6faa803867476366674aa531597af81;p=dbsrgits%2FDBIx-Class.git Use plain old file concat for the dbicadmin pod-injection Lose the oneliner for more sanity and better cross-platform support --- diff --git a/maint/Makefile.PL.inc/11_authortests.pl b/maint/Makefile.PL.inc/11_authortests.pl index dc3eb4c..c9ff881 100644 --- a/maint/Makefile.PL.inc/11_authortests.pl +++ b/maint/Makefile.PL.inc/11_authortests.pl @@ -14,10 +14,11 @@ my @xt_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dirs; # this will add the xt tests to the `make test` target among other things Meta->tests(join (' ', map { $_ || () } Meta->tests, @xt_tests ) ); -# inject an explicit xt test run for the create_distdir target +# inject an explicit xt test run, mainly to check the contents of +# lib and the generated POD's *before* anything is copied around postamble <<"EOP"; -create_distdir : test_xt +dbic_clonedir_copy_generated_pod : test_xt test_xt : pm_to_blib @{[ diff --git a/maint/Makefile.PL.inc/53_autogen_pod.pl b/maint/Makefile.PL.inc/53_autogen_pod.pl index 5d68f65..54f1d58 100644 --- a/maint/Makefile.PL.inc/53_autogen_pod.pl +++ b/maint/Makefile.PL.inc/53_autogen_pod.pl @@ -37,11 +37,38 @@ EOP } +# generate the script/dbicadmin pod +{ + print "Regenerating script/dbicadmin.pod\n"; + + # generating it in the root of $pod_dir + # it will *not* be copied over due to not being listed at the top + # of MANIFEST.SKIP - this is a *good* thing + # we only want to ship a script/dbicadmin, with the POD appended + # (see inject_dbicadmin_pod.pl), but still want to spellcheck and + # whatnot the intermediate step + my $pod_fn = "$pod_dir/dbicadmin.pod"; + + # if the author doesn't have the prereqs, don't fail the initial "perl Makefile.pl" step + # therefore no error checking + system($^X, qw( -Ilib -- script/dbicadmin --documentation-as-pod ), $pod_fn); + + postamble <<"EOP"; + +clonedir_generate_files : dbic_clonedir_gen_dbicadmin_pod + +dbic_clonedir_gen_dbicadmin_pod : +\t\$(ABSPERLRUN) -Ilib -- script/dbicadmin --documentation-as-pod @{[ $mm_proto->quote_literal($pod_fn) ]} + +EOP +} + + # generate the inherit pods both in the clone-dir and during the makefile distdir { print "Regenerating project documentation to include inherited methods\n"; - # if the author doesn't have them, don't fail the initial "perl Makefile.pl" step + # if the author doesn't have the prereqs, don't fail the initial "perl Makefile.pl" step do "maint/gen_pod_inherit" or print "\n!!! FAILED: $@\n"; postamble <<"EOP"; diff --git a/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl b/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl index 090fda3..97db5d6 100644 --- a/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl +++ b/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl @@ -1,15 +1,19 @@ -# Makefile syntax allows adding extra dep-specs for already-existing targets, -# and simply appends them on *LAST*-come *FIRST*-serve basis. -# This allows us to inject extra depenencies for standard EUMM targets +# without having the pod in the file itself, perldoc may very +# well show a *different* document, because perl and perldoc +# search @INC differently (crazy right?) +# +# make sure we delete and re-create the file - just an append +# will not do what one expects, because on unixy systems the +# target is symlinked to the original postamble <<"EOP"; create_distdir : dbic_distdir_dbicadmin_pod_inject -# The pod self-injection code is in fact a hidden option in -# dbicadmin itself, we execute the one in the distdir dbic_distdir_dbicadmin_pod_inject : -\t\$(ABSPERLRUN) -I\$(DISTVNAME)/lib \$(DISTVNAME)/script/dbicadmin --selfinject-pod + +\t\$(RM_F) \$(DISTVNAME)/script/dbicadmin +\t@{[ $mm_proto->oneliner('cat', ['-MExtUtils::Command']) ]} script/dbicadmin maint/.Generated_Pod/dbicadmin.pod > \$(DISTVNAME)/script/dbicadmin EOP diff --git a/script/dbicadmin b/script/dbicadmin index 60124e4..13c724d 100755 --- a/script/dbicadmin +++ b/script/dbicadmin @@ -43,7 +43,7 @@ my ($opts, $usage) = describe_options( ['delete' => 'Delete data from the schema'], ['op:s' => 'compatiblity option all of the above can be suppied as --op='], ['help' => 'display this help', { implies => { schema_class => '__dummy__' } } ], - ['selfinject-pod' => 'hidden', { implies => { schema_class => '__dummy__' } } ], + ['documentation-as-pod:s' => 'hidden', { implies => { schema_class => '__dummy__' } } ], ], required => 1 }], ['Arguments'], ["configuration" => hidden => { one_of => [ @@ -68,23 +68,26 @@ my ($opts, $usage) = describe_options( ) ); -if($opts->{selfinject_pod}) { - - die "This is an internal method, do not call!!!\n" - unless $ENV{MAKELEVEL}; - - $usage->synopsis($synopsis_text); - $usage->short_description($short_description); - exec ( - $^X, - qw/-p -0777 -i -e/, - ( - 's/^# auto_pod_begin.*^# auto_pod_end/' - . quotemeta($usage->pod) - . '/ms' - ), - __FILE__ - ); +if(defined (my $fn = $opts->{documentation_as_pod}) ) { + $usage->synopsis($synopsis_text); + $usage->short_description($short_description); + + if ($fn) { + require File::Spec; + require File::Path; + my $dir = File::Spec->catpath( (File::Spec->splitpath($fn))[0,1] ); + File::Path::mkpath([$dir]); + } + + local *STDOUT if $fn; + open (STDOUT, '>', $fn) or die "Unable to open $fn: $!\n" if $fn; + + print STDOUT "\n"; + print STDOUT $usage->pod; + print STDOUT "\n"; + + close STDOUT if $fn; + exit 0; } # FIXME - lowercasing will eventually go away when Getopt::Long::Descriptive is fixed @@ -129,13 +132,6 @@ if ($action eq 'select') { } } +1; __END__ - -# auto_pod_begin -# -# This will be replaced by the actual pod when selfinject-pod is invoked -# -# auto_pod_end - -# vim: et ft=perl