view release on metacpan or search on metacpan
requires 'ExtUtils::Manifest';
requires 'Exporter';
requires 'File::Basename';
requires 'File::Spec';
requires 'Markdown::Pod::Embed', '1.010';
requires 'perl', '5.010';
requires 'strict';
requires 'vars';
requires 'warnings';
on configure => sub {
requires 'perl', '5.010';
requires 'ExtUtils::MakeMaker';
requires 'version';
};
on test => sub {
requires 'File::Path';
requires 'File::Temp';
requires 'Test::More';
};
lib/ASPEER/MakeMaker/Markdown/Pod/Constant.pm view on Meta::CPAN
# Get module file name and path, derive name of file to store local constants
#
use Cwd qw(abs_path);
my $local_fn=abs_path(__FILE__) . '.local';
# Find file in path
#
sub bin_find {
# Find a binary file
#
my @bin_fn=@_;
my $bin_fn;
# Find the bin file/files if given array ref. If not supplied as array ref
# convert.
lib/ASPEER/MakeMaker/Markdown/Pod/Constant.pm view on Meta::CPAN
#
%Constant=(
OPTION_HR => {
dialect => 'GitHub',
},
PANDOC_EXE => &bin_find(qw(pandoc pandoc.exe)),
PANDOC_CMD_MD2TEXT_CR => sub {
return [
shift(), # PANDOC_EXE
'-fmarkdown_github', # from markdown (github dialect)
'-tplain', # to plaintext
shift(), # File name
]
},
# Local constants override anything above
#
lib/ASPEER/MakeMaker/Markdown/Pod/MM.pm view on Meta::CPAN
#
package ASPEER::MakeMaker::Markdown::Pod::MM;
# Compiler Pragma
#
use strict qw(vars);
use vars qw($VERSION @ISA $IMPORTED);
use warnings;
no warnings qw(uninitialized);
sub BEGIN {local $^W=0}
# Base packages and shared utility functions
#
use ASPEER::MakeMaker::MM ();
use ASPEER::MakeMaker::MM::Util;
use ASPEER::MakeMaker::Markdown::Pod::MM::Constant ();
@ISA=qw(ASPEER::MakeMaker::MM);
lib/ASPEER/MakeMaker/Markdown/Pod/MM.pm view on Meta::CPAN
# All done, init finished
#
1;
#======================================================================================================================
# Makefile targets from here down
#
sub doc {
# Convert DocBook articles under doc to sibling Markdown files
#
my ($self, $param_hr)=(shift(), arg(@_));
msg($self);
if (-d 'doc') {
require Docbook::Convert::Pandoc;
my $docbook_or=Docbook::Convert::Pandoc->new();
my $changed_fn_ar=$docbook_or->convert_articles('doc');
lib/ASPEER/MakeMaker/Markdown/Pod/MM.pm view on Meta::CPAN
}
# Done
#
return undef;
}
sub readme {
# Build README files from README.md or VERSION_FROM markdown
#
my ($self, $param_hr)=(shift(), arg(@_));
require Markdown::Pod::Embed;
# Get manifest for any file additions we make
#
lib/ASPEER/MakeMaker/Markdown/Pod/MM.pm view on Meta::CPAN
else {
msg('markpod: %s -> %s: finished, no changes', $source_fn, $readme_fn);
}
push @manifest_add, $readme_fn unless exists $manifest_hr->{$readme_fn};
manifest_add(\@manifest_add) if @manifest_add;
}
sub manifest_add {
my ($file_ar)=@_;
return undef unless @{$file_ar};
require ExtUtils::Manifest;
my %add=map { $_ => '' } @{$file_ar};
ExtUtils::Manifest::maniadd(\%add);
return 1;
}
t/01-embed-process.t view on Meta::CPAN
use strict;
use warnings;
use lib 'lib';
use File::Temp qw(tempdir);
use Test::More;
use ASPEER::MakeMaker::Markdown::Pod;
sub slurp {
my ($fn)=@_;
open my $fh, '<', $fn or die "open $fn: $!";
local $/=undef;
return scalar <$fh>;
}
sub spew {
my ($fn, $content)=@_;
open my $fh, '>', $fn or die "open $fn: $!";
print {$fh} $content;
close $fh or die "close $fn: $!";
}
{
my $dir=tempdir(CLEANUP => 1);
my $fn="${dir}/plain.pm";
my $orig=<<'PLAIN';
t/02-markdown-source.t view on Meta::CPAN
use strict;
use warnings;
use lib 'lib';
use File::Temp qw(tempdir);
use Test::More;
use ASPEER::MakeMaker::Markdown::Pod;
sub spew {
my ($fn, $content)=@_;
open my $fh, '>', $fn or die "open $fn: $!";
print {$fh} $content;
close $fh or die "close $fn: $!";
}
{
my $dir=tempdir(CLEANUP => 1);
my $fn="${dir}/sidecar-wins.pm";
spew($fn, <<'PM');
t/03-update-behavior.t view on Meta::CPAN
use strict;
use warnings;
use lib 'lib';
use File::Temp qw(tempdir);
use Test::More;
use ASPEER::MakeMaker::Markdown::Pod;
sub slurp {
my ($fn)=@_;
open my $fh, '<', $fn or die "open $fn: $!";
local $/=undef;
return scalar <$fh>;
}
sub spew {
my ($fn, $content)=@_;
open my $fh, '>', $fn or die "open $fn: $!";
print {$fh} $content;
close $fh or die "close $fn: $!";
}
{
my $dir=tempdir(CLEANUP => 1);
my $fn="${dir}/backup.pm";
my $orig=<<'PM';
t/04-mm-readme.t view on Meta::CPAN
use File::Temp qw(tempdir);
use Test::More;
use ASPEER::MakeMaker::Markdown::Pod::Constant;
use ASPEER::MakeMaker::Markdown::Pod::MM;
plan skip_all => 'pandoc is required for README generation tests'
unless $PANDOC_EXE;
sub slurp {
my ($fn)=@_;
open(my $fh, '<', $fn) || die "unable to open $fn, $!";
local $/=undef;
my $text=<$fh>;
close($fh) || die "unable to close $fn, $!";
return $text;
}
sub spew {
my ($fn, $content)=@_;
open(my $fh, '>', $fn) || die "unable to open $fn, $!";
print $fh $content;
close($fh) || die "unable to close $fn, $!";
}
sub run_readme {
my ($version_from)=@_;
return ASPEER::MakeMaker::Markdown::Pod::MM::readme(
undef,
'',
'',
'',
'',
'',
'',
t/04-mm-readme.t view on Meta::CPAN
'',
'',
'',
'',
'',
);
}
sub start_fixture {
my ($cwd)=@_;
chdir($cwd) || die "unable to chdir $cwd, $!";
my $temporary_dn=tempdir(CLEANUP => 1);
chdir($temporary_dn) || die "unable to chdir $temporary_dn, $!";
make_path('lib/Sample');
return 'lib/Sample/Readme.pm';
}
t/05-mm-integration.t view on Meta::CPAN
use File::Path qw(make_path);
use File::Temp qw(tempdir);
use Test::More;
use Markdown::Pod::Embed;
use ASPEER::MakeMaker::Markdown::Pod::MM;
# Read and write test fixture files
#
sub slurp {
my ($fn)=@_;
open(my $input_fh, '<', $fn) || die "unable to open $fn, $!";
local $/=undef;
my $text=<$input_fh>;
close($input_fh) || die "unable to close $fn, $!";
return $text;
}
sub blurp {
my ($fn, $text)=@_;
open(my $output_fh, '>', $fn) || die "unable to open $fn, $!";
print $output_fh $text;
close($output_fh) || die "unable to close $fn, $!";
return 1;
}
t/05-mm-integration.t view on Meta::CPAN
AUTHOR => 'Andrew Speer',
depend => {'generated.out' => 'generated.in'},
);
MAKEFILE_PL
blurp('lib/Sample.pm', "package Sample;\nour \$VERSION='0.001';\n1;\n");
blurp('lib/Sample.pm.md', "# NAME\n\nSample - generated documentation\n");
blurp('bin/sample.pl', "#!perl\nour \$VERSION='0.001';\nprint qq(sample\\n);\n");
blurp('doc/guide.xml', "<?xml version=\"1.0\"?>\n<article><title>Guide</title></article>\n");
blurp('local lib/Docbook/Convert/Pandoc.pm', <<'PANDOC_STUB');
package Docbook::Convert::Pandoc;
sub new {return bless({}, shift())}
sub convert_articles {
my ($self, $root_dn)=@_;
die "unexpected document root\n" unless $root_dn eq 'doc';
open(my $output_fh, '>', 'doc/guide.md') || die "unable to open output: $!";
print {$output_fh} "# Guide\n" || die "unable to write output: $!";
close($output_fh) || die "unable to close output: $!";
return ['doc/guide.md'];
}
1;
PANDOC_STUB
blurp('LICENSE', "Sample license\n");
t/05-mm-integration.t view on Meta::CPAN
like($makefile, qr/^doc :: readme$/m,
'minimal Makefile.PL retains documentation targets');
chdir($cwd) || die "unable to chdir $cwd, $!";
# File writes must report both data and close failures
#
{
no warnings qw(redefine);
local *IO::File::new=sub {bless({}, 'Local::FailingWrite')};
my $write_ok=eval {
ASPEER::MakeMaker::MM::Util::blurp('ignored', 'text');
1;
};
ok(!$write_ok, 'file write failure is fatal');
}
{
no warnings qw(redefine);
local *IO::File::new=sub {bless({}, 'Local::FailingClose')};
my $close_ok=eval {
ASPEER::MakeMaker::MM::Util::blurp('ignored', 'text');
1;
};
ok(!$close_ok, 'file close failure is fatal');
}
done_testing();
package Local::FailingWrite;
sub print {return 0}
sub close {return 1}
package Local::FailingClose;
sub print {return 1}
sub close {return 0}