[libcode-tidyall-perl] 202/374: add PodChecker
Jonas Smedegaard
js at alioth.debian.org
Sun Sep 29 22:26:20 UTC 2013
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libcode-tidyall-perl.
commit b8850837dd7ebd15ea56000a8e8217e2aa098dc0
Author: Jonathan Swartz <swartz at pobox.com>
Date: Sun Sep 9 04:57:31 2012 -0700
add PodChecker
---
lib/Code/TidyAll/Plugin/PodChecker.pm | 66 +++++++++++++++++++++++++++++++
lib/Code/TidyAll/t/Plugin/PodChecker.pm | 42 ++++++++++++++++++++
xt/author/Plugin-PodChecker.t | 3 ++
3 files changed, 111 insertions(+)
diff --git a/lib/Code/TidyAll/Plugin/PodChecker.pm b/lib/Code/TidyAll/Plugin/PodChecker.pm
new file mode 100644
index 0000000..f947fe1
--- /dev/null
+++ b/lib/Code/TidyAll/Plugin/PodChecker.pm
@@ -0,0 +1,66 @@
+package Code::TidyAll::Plugin::PodChecker;
+use Capture::Tiny qw(capture_merged);
+use Pod::Checker;
+use Moo;
+extends 'Code::TidyAll::Plugin';
+
+has 'warnings' => ( is => 'ro' );
+
+sub validate_file {
+ my ( $self, $file ) = @_;
+
+ my $result;
+ my %options = ( defined( $self->warnings ) ? ( '-warnings' => $self->warnings ) : () );
+ my $checker = new Pod::Checker(%options);
+ my $output = capture_merged { $checker->parse_from_file( $file, \*STDERR ) };
+ die $output
+ if $checker->num_errors
+ or ( $self->warnings && $checker->num_warnings );
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Code::TidyAll::Plugin::PodChecker - use podchecker with tidyall
+
+=head1 SYNOPSIS
+
+ In tidyall.ini:
+
+ ; Check for errors, but ignore warnings
+ ;
+ [PodChecker]
+ select = lib/**/*.{pm,pod}
+
+ ; Die on level 1 warnings (can also be set to 2)
+ ;
+ [PodChecker]
+ select = lib/**/*.{pm,pod}
+ warnings = 1
+
+=head1 DESCRIPTION
+
+Runs L<podchecker|podchecker>, a POD validator, and dies if any problems were
+found.
+
+=head1 INSTALLATION
+
+Install podchecker from CPAN.
+
+ cpanm podchecker
+
+=head1 CONFIGURATION
+
+=over
+
+=item warnings
+
+Level of warnings to consider as errors - 1 or 2. By default, warnings will be
+ignored.
+
+=back
diff --git a/lib/Code/TidyAll/t/Plugin/PodChecker.pm b/lib/Code/TidyAll/t/Plugin/PodChecker.pm
new file mode 100644
index 0000000..c2f2625
--- /dev/null
+++ b/lib/Code/TidyAll/t/Plugin/PodChecker.pm
@@ -0,0 +1,42 @@
+package Code::TidyAll::t::Plugin::PodChecker;
+use Test::Class::Most parent => 'Code::TidyAll::t::Plugin';
+
+sub test_main : Tests {
+ my $self = shift;
+
+ $self->tidyall(
+ source => '=head1 DESCRIPTION\n\nHello',
+ expect_ok => 1,
+ desc => 'ok',
+ );
+ $self->tidyall(
+ source => '=head1 METHODS\n\n=over',
+ expect_error => qr/without closing =back/,
+ desc => 'error',
+ );
+ $self->tidyall(
+ source => '=head1 DESCRIPTION\n\n=head1 METHODS\n\n',
+ expect_ok => 1,
+ desc => 'ok - empty section, no warnings',
+ );
+ $self->tidyall(
+ source => '=head1 DESCRIPTION\n\n=head1 METHODS\n\n',
+ conf => { warnings => 1 },
+ expect_error => qr/empty section in previous paragraph/,
+ desc => 'error - empty section, warnings=1',
+ );
+ $self->tidyall(
+ source => '=head1 DESCRIPTION\n\nblah blah\n\n=head1 DESCRIPTION\n\nblah blah',
+ conf => { warnings => 1 },
+ expect_ok => 1,
+ desc => 'ok - duplicate section, warnings=1',
+ );
+ $self->tidyall(
+ source => '=head1 DESCRIPTION\n\nblah blah\n\n=head1 DESCRIPTION\n\nblah blah',
+ conf => { warnings => 2 },
+ expect_error => qr/multiple occurrence/,
+ desc => 'error - duplicate section, warnings=2',
+ );
+}
+
+1;
diff --git a/xt/author/Plugin-PodChecker.t b/xt/author/Plugin-PodChecker.t
new file mode 100644
index 0000000..6565d43
--- /dev/null
+++ b/xt/author/Plugin-PodChecker.t
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+use Code::TidyAll::t::Plugin::PodChecker;
+Code::TidyAll::t::Plugin::PodChecker->runtests;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcode-tidyall-perl.git
More information about the Pkg-perl-cvs-commits
mailing list