From 97f5e887b5b6289265d4e22d934df9ad1f528ab7 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Tue, 12 Mar 2013 15:15:53 +0900 Subject: [PATCH] Tizen 2.1 base --- Build.PL | 18 ++ Changes | 150 +++++++++++ MANIFEST | 41 +++ META.yml | 26 ++ Makefile.PL | 19 ++ bin/pod_cover | 49 ++++ examples/check_installed | 27 ++ examples/script-covered | 27 ++ lib/Pod/Coverage.pm | 486 +++++++++++++++++++++++++++++++++++ lib/Pod/Coverage/CountParents.pm | 77 ++++++ lib/Pod/Coverage/ExportOnly.pm | 53 ++++ lib/Pod/Coverage/Overloader.pm | 37 +++ packaging/perl-Pod-Coverage.changes | 53 ++++ packaging/perl-Pod-Coverage.manifest | 5 + packaging/perl-Pod-Coverage.spec | 51 ++++ t/01compile.t | 8 + t/02simple.t | 84 ++++++ t/03import.t | 32 +++ t/04cvgv.t | 19 ++ t/05parentage.t | 19 ++ t/06trustme.t | 30 +++ t/07pod.t | 4 + t/08tie.t | 13 + t/09whitespace.t | 12 + t/lib/Args.pm | 12 + t/lib/Child.pm | 10 + t/lib/Earle.pm | 16 ++ t/lib/Empty.pm | 18 ++ t/lib/Fully/Qualified.pm | 45 ++++ t/lib/GrandParent.pm | 14 + t/lib/Parent.pm | 18 ++ t/lib/Sibling.pm | 9 + t/lib/Simple1.pm | 27 ++ t/lib/Simple2.pm | 31 +++ t/lib/Simple3.pm | 16 ++ t/lib/Simple4.pm | 7 + t/lib/Simple4.pod | 9 + t/lib/Simple5.pm | 15 ++ t/lib/Simple6.pm | 23 ++ t/lib/Simple7.pm | 13 + t/lib/Simple8.pm | 5 + t/lib/Tie.pm | 53 ++++ t/lib/Trustme.pm | 40 +++ t/lib/XS4ALL.pm | 30 +++ 44 files changed, 1751 insertions(+) create mode 100644 Build.PL create mode 100644 Changes create mode 100644 MANIFEST create mode 100644 META.yml create mode 100644 Makefile.PL create mode 100644 bin/pod_cover create mode 100644 examples/check_installed create mode 100644 examples/script-covered create mode 100644 lib/Pod/Coverage.pm create mode 100644 lib/Pod/Coverage/CountParents.pm create mode 100644 lib/Pod/Coverage/ExportOnly.pm create mode 100644 lib/Pod/Coverage/Overloader.pm create mode 100644 packaging/perl-Pod-Coverage.changes create mode 100644 packaging/perl-Pod-Coverage.manifest create mode 100644 packaging/perl-Pod-Coverage.spec create mode 100644 t/01compile.t create mode 100644 t/02simple.t create mode 100644 t/03import.t create mode 100644 t/04cvgv.t create mode 100644 t/05parentage.t create mode 100644 t/06trustme.t create mode 100644 t/07pod.t create mode 100644 t/08tie.t create mode 100644 t/09whitespace.t create mode 100644 t/lib/Args.pm create mode 100644 t/lib/Child.pm create mode 100644 t/lib/Earle.pm create mode 100644 t/lib/Empty.pm create mode 100644 t/lib/Fully/Qualified.pm create mode 100644 t/lib/GrandParent.pm create mode 100644 t/lib/Parent.pm create mode 100644 t/lib/Sibling.pm create mode 100644 t/lib/Simple1.pm create mode 100644 t/lib/Simple2.pm create mode 100644 t/lib/Simple3.pm create mode 100644 t/lib/Simple4.pm create mode 100644 t/lib/Simple4.pod create mode 100644 t/lib/Simple5.pm create mode 100644 t/lib/Simple6.pm create mode 100644 t/lib/Simple7.pm create mode 100644 t/lib/Simple8.pm create mode 100644 t/lib/Tie.pm create mode 100644 t/lib/Trustme.pm create mode 100644 t/lib/XS4ALL.pm diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..1f2abc6 --- /dev/null +++ b/Build.PL @@ -0,0 +1,18 @@ +use strict; +use Module::Build; + +Module::Build + ->new( module_name => "Pod::Coverage", + license => 'perl', + script_files => [ 'bin/pod_cover' ], + build_requires => { + 'Test::More' => 0, + }, + requires => { + 'Devel::Symdump' => 2.01, + 'Pod::Parser' => 1.13, + 'Pod::Find' => 0.21, + }, + create_makefile_pl => 'traditional', + ) + ->create_build_script; diff --git a/Changes b/Changes new file mode 100644 index 0000000..817e557 --- /dev/null +++ b/Changes @@ -0,0 +1,150 @@ +0.20 Thursday 19th February, 2009 + Fix t/lib/Fully/Qualified.pm to have a 1; (Zefram) + Ship t/09whitespace.t - had missed it before + +0.19 Thursday 13th September, 2007 + Don't use _CvGV to determine if a sub was imported, there's a handy + flag - GVf_IMPORTED_CV. Fixes 5.9.5 and future perls + (solution by Nicholas Clark) + + +0.18 Friday 4th August, 2006 + Rewrite _CvGV in terms of B::CV - no xs dependency anymore + (suggested by Tim Bunce) + + Add the (FETCH|MODIFY)_$foo_ATTRIBUTES methods to the private + stoplists. (rt #12451) + + Support documentation where the method name is documented in a + ::qualified style (rt #14635) + + Ignores new (5.8) magic CLONE and CLONE_SKIP methods. (rt #17489) + + Added a nonwhitespace option (Alex - rt #14950) + + +0.17 Tuesday 23rd November, 2004 + Fixed a further case reported by Jos Boumans where + =head2 $self->foo(); was intepreted as documentation for a + C method. (more XS4ALL house style) + +0.16 Wednesday 20th October, 2004 + Fixed a MANIFEST bug. + Fixed a case reported by Jos Boumans where + =head2 $self->foo; was intepreted as documentation for a + C method. (XS4ALL house style) + +0.15 Tuesday 19th October, 2004 + Correctly ignores tie subroutines (David Cantrell) + +0.14 Sunday 9th May, 2004 + Small fix from Andy Lester for when people entity escape + the greater than in the method call arrow. + +0.13 Monday 29th December, 2003 + Fixed a case reported by Earle Martin, where + =head2 C wasn't working correctly + + Pod and Test fixes by Andy Lester + + Now we install the pod_cover command line utility. + +0.12 Tuesday 30th September, 2003 + Added 'trustme' so that you don't have to lie about subs being private + when the module fails to find their docs. Work by David Cantrell. + + Pulled HISTORY out into a Changes file. + + Deprecated and gutted Pod::Coverage::Overloader. The ignored + patterns in the base class now include qr/^\(/ which is all it + really did only in a stupidly complex manner. + +0.11 2002-02-27 + Sort the uncovered subs reported from the import form. From a + bug report from Tels. + +0.10 2002-02-18 + Added Pod::Coverage::CountParents which counts the Pod + sections from higher in the inheritance tree (it walks @ISA). + + Refactored C<_get_pods> into its own method to allow this. + +0.09 2001-12-17 + Fixed a typo in mstevens' name (oopsie) + + Added C based on an email exchange. + + Modified the import form so that if given one argument it's + assumed to be the package. From a suggestion by Mark Fowler. + + Changed tracing to use optimisable constants. + + Added why_unrated. + +0.08 2001-11-14 + Paul Johnson beat me to making Pod::Coverage a Devel::Cover + plugin, so that's one less thing in the TODO section. + + Ran the code through perltidy, made some of the changes it + suggested. + + Worked over the parsing of the also_private flag to give it more + consistent semantics + + Assimilated C from Tels + +0.07 + Implemented _CvGV based upon code from Robin Houston. This + removes the dependency on Devel::Peek (the CPAN version of + Devel::Peek doesn't supply CvGV). This also happily makes the + module work with perl 5.005_03. + + Fixed a bug in the import routine which was preventing the use + form of derived classes. Reports a module is unrated if + coverage returns undef. + + Added Pod::Checker::Overloader. + +0.06 + First cut at making inheritance easy. + Pod::Checker::ExportOnly isa Pod::Checker which only checks + what Exporter is allowed to hand out. + + Fixed up bad docs from the 0.05 release. + +0.05 + Used Pod::Find to deal with alternative locations for pod + files. + + Introduced pod_from. + + Merged some patches from Schwern. + Added in covered. + + Assimilated C as contributed by + Kirrily "Skud" Robert . + + Copes with multple functions documented by one section. + + Added uncovered as a synonym for naked. + +0.04 + Just 0.03 with a correctly generated README file + +0.03 + Applied a patch from Dave Rolsky (barely 6 hours after release + of 0.02) to improve scanning of pod markers. + +0.02 + Fixed up the import form. + + Removed dependency on List::Util. + + Added naked method. + + Exposed private configuration. + +0.01 + As #london.pm invaded Brighton, people taked about + documentation standards. mstevens scribbled something down, + richardc coded it, the rest is ponies. diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..0c1d855 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,41 @@ +MANIFEST +Changes +Makefile.PL +Build.PL +META.yml +bin/pod_cover +lib/Pod/Coverage.pm +lib/Pod/Coverage/ExportOnly.pm +lib/Pod/Coverage/Overloader.pm +lib/Pod/Coverage/CountParents.pm +t/01compile.t +t/02simple.t +t/03import.t +t/04cvgv.t +t/05parentage.t +t/06trustme.t +t/07pod.t +t/08tie.t +t/09whitespace.t +t/lib/Args.pm +t/lib/Earle.pm +t/lib/Empty.pm +t/lib/Simple1.pm +t/lib/Simple2.pm +t/lib/Simple3.pm +t/lib/Simple4.pm +t/lib/Simple4.pod +t/lib/Simple5.pm +t/lib/Simple6.pm +t/lib/Simple7.pm +t/lib/Simple8.pm +t/lib/Child.pm +t/lib/GrandParent.pm +t/lib/Parent.pm +t/lib/Sibling.pm +t/lib/Trustme.pm +t/lib/Tie.pm +t/lib/XS4ALL.pm +t/lib/Fully/Qualified.pm +examples/check_installed +examples/script-covered diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..080dd06 --- /dev/null +++ b/META.yml @@ -0,0 +1,26 @@ +--- +name: Pod-Coverage +version: 0.20 +author: ~ +abstract: Checks if the documentation of a module is comprehensive +license: perl +requires: + Devel::Symdump: 2.01 + Pod::Find: 0.21 + Pod::Parser: 1.13 +build_requires: + Test::More: 0 +provides: + Pod::Coverage: + file: lib/Pod/Coverage.pm + version: 0.20 + Pod::Coverage::CountParents: + file: lib/Pod/Coverage/CountParents.pm + Pod::Coverage::ExportOnly: + file: lib/Pod/Coverage/ExportOnly.pm + Pod::Coverage::Extractor: + file: lib/Pod/Coverage.pm + version: 0.20 + Pod::Coverage::Overloader: + file: lib/Pod/Coverage/Overloader.pm +generated_by: Module::Build version 0.2611 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..736d611 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,19 @@ +# Note: this file was auto-generated by Module::Build::Compat version 0.03 +use ExtUtils::MakeMaker; +WriteMakefile +( + 'PL_FILES' => {}, + 'INSTALLDIRS' => 'site', + 'NAME' => 'Pod::Coverage', + 'EXE_FILES' => [ + 'bin/pod_cover' + ], + 'VERSION_FROM' => 'lib/Pod/Coverage.pm', + 'PREREQ_PM' => { + 'Test::More' => 0, + 'Pod::Parser' => '1.13', + 'Devel::Symdump' => '2.01', + 'Pod::Find' => '0.21' + } + ) +; diff --git a/bin/pod_cover b/bin/pod_cover new file mode 100644 index 0000000..c11b2ff --- /dev/null +++ b/bin/pod_cover @@ -0,0 +1,49 @@ +#!/usr/bin/perl -w + +# Run this to get a coverage analysis of the embedded documentation + +use Pod::Coverage; +use lib 'lib'; # to test distribution inside './lib' +use strict; + +print "Pod coverage analysis v1.00 (C) by Tels 2001.\n"; +print "Using Pod::Coverage v$Pod::Coverage::VERSION\n\n"; + +print scalar localtime()," Starting analysis:\n\n"; + +my $covered = 0; my $uncovered; my $count = 0; my $c; +open FILE, 'MANIFEST' or die "Can't read MANIFEST: $!"; +while () + { + chomp; + my ($file) = split /[\s\t]/,$_; + next unless $file =~ /^lib.*\.pm$/; + $file =~ s/^lib\///; # remove lib and .pm + $file =~ s/\.pm$//; + $file =~ s/\//::/g; # / => :: + my $rc = Pod::Coverage->new( package => $file ); + $covered += $rc->covered(); + $uncovered += $rc->uncovered(); + $count ++; + $c = $rc->coverage() || 0; + $c = int($c * 10000)/100; + print "$file has a doc coverage of $c%.\n"; + my @naked = $rc->naked(); + if (@naked > 0) + { + print "Uncovered routines are:\n"; + print " ",join("\n ",sort @naked),"\n"; # sort by name + # could sort by line_num + } + print "\n"; + } + +my $total = $covered+$uncovered; +my $average = 'unknown'; +$average = int(10000*$covered/$total)/100 if $total > 0; + +print "Summary:\n"; +print " sub routines total : $total\n"; +print " sub routines covered : $covered\n"; +print " sub routines uncovered: $uncovered\n"; +print " total coverage : $average%\n\n"; diff --git a/examples/check_installed b/examples/check_installed new file mode 100644 index 0000000..dfa5c4b --- /dev/null +++ b/examples/check_installed @@ -0,0 +1,27 @@ +#!/usr/bin/perl -w + +# code contributed by Kirrily "Skud" Robert + +use strict; +use Pod::Coverage; +use ExtUtils::Installed; + +my $m = ExtUtils::Installed->new; +my @modules = $m->modules(); + +print "Checking POD coverage...\n"; + +my %coverage; +foreach my $mod (@modules) { + my $pc = new Pod::Coverage package => $mod; + $coverage{$mod} = $pc->coverage() || 0; +} + +foreach my $out (sort by_coverage keys %coverage) { + my $bar = "*" x ($coverage{$out} * 40); + printf("%30s %3d%% %s\n", $out, $coverage{$out}*100, $bar); +} + +sub by_coverage { + $coverage{$b} <=> $coverage{$a}; +} diff --git a/examples/script-covered b/examples/script-covered new file mode 100644 index 0000000..8dd8a3a --- /dev/null +++ b/examples/script-covered @@ -0,0 +1,27 @@ +#!/usr/bin/perl -w +use strict; + +my $file = shift || die "need something to test"; +my $code; + +open F, $file; +{ + local $/; + $code = ; +} +close F; + +eval qq{ +package testme; + +$code; + +1; +}; +$INC{'testme.pm'} = 1; + +print testme::foo(); + +require Pod::Coverage; +Pod::Coverage->import(pod_from => $file, + package => 'testme'); diff --git a/lib/Pod/Coverage.pm b/lib/Pod/Coverage.pm new file mode 100644 index 0000000..52598f0 --- /dev/null +++ b/lib/Pod/Coverage.pm @@ -0,0 +1,486 @@ +use strict; + +package Pod::Coverage; +use Devel::Symdump; +use B; +use Pod::Find qw(pod_where); + +BEGIN { defined &TRACE_ALL or eval 'sub TRACE_ALL () { 0 }' } + +use vars qw/ $VERSION /; +$VERSION = '0.20'; + +=head1 NAME + +Pod::Coverage - Checks if the documentation of a module is comprehensive + +=head1 SYNOPSIS + + # in the beginnning... + perl -MPod::Coverage=Pod::Coverage -e666 + + # all in one invocation + use Pod::Coverage package => 'Fishy'; + + # straight OO + use Pod::Coverage; + my $pc = Pod::Coverage->new(package => 'Pod::Coverage'); + print "We rock!" if $pc->coverage == 1; + + +=head1 DESCRIPTION + +Developers hate writing documentation. They'd hate it even more if +their computer tattled on them, but maybe they'll be even more +thankful in the long run. Even if not, F tells you to, so +you must obey. + +This module provides a mechanism for determining if the pod for a +given module is comprehensive. + +It expects to find either a C<< =head(n>1) >> or an C<=item> block documenting a +subroutine. + +Consider: + # an imaginary Foo.pm + package Foo; + + =item foo + + The foo sub + + = cut + + sub foo {} + sub bar {} + + 1; + __END__ + +In this example C is covered, but C is not, so the C +package is only 50% (0.5) covered + +=head2 Methods + +=over + +=item Pod::Coverage->new(package => $package) + +Creates a new Pod::Coverage object. + +C the name of the package to analyse + +C an array of regexen which define what symbols are regarded +as private (and so need not be documented) defaults to [ qr/^_/, +qr/^import$/, qr/^DESTROY$/, qr/^AUTOLOAD$/, qr/^bootstrap$/, + qr/^(TIE( SCALAR | ARRAY | HASH | HANDLE ) | + FETCH | STORE | UNTIE | FETCHSIZE | STORESIZE | + POP | PUSH | SHIFT | UNSHIFT | SPLICE | DELETE | + EXISTS | EXTEND | CLEAR | FIRSTKEY | NEXTKEY | PRINT | PRINTF | + WRITE | READLINE | GETC | READ | CLOSE | BINMODE | OPEN | + EOF | FILENO | SEEK | TELL)$/x, + qr/^( MODIFY | FETCH )_( REF | SCALAR | ARRAY | HASH | CODE | + GLOB | FORMAT | IO)_ATTRIBUTES$/x, + qr/^CLONE(_SKIP)?$/, +] + +This should cover all the usual magical methods for tie()d objects, +attributes, generally all the methods that are typically not called by +a user, but instead being used internally by perl. + +C items are appended to the private list + +C an array of regexen which define what symbols you just want +us to assume are properly documented even if we can't find any docs +for them + +If C is supplied, that file is parsed for the documentation, +rather than using Pod::Find + +If C is supplied, then only POD sections which have +non-whitespace characters will count towards being documented. + +=cut + +sub new { + my $referent = shift; + my %args = @_; + my $class = ref $referent || $referent; + + my $private = $args{private} || [ + qr/^_/, + qr/^import$/, + qr/^DESTROY$/, + qr/^AUTOLOAD$/, + qr/^bootstrap$/, + qr/^\(/, + qr/^(TIE( SCALAR | ARRAY | HASH | HANDLE ) | + FETCH | STORE | UNTIE | FETCHSIZE | STORESIZE | + POP | PUSH | SHIFT | UNSHIFT | SPLICE | DELETE | + EXISTS | EXTEND | CLEAR | FIRSTKEY | NEXTKEY | PRINT | PRINTF | + WRITE | READLINE | GETC | READ | CLOSE | BINMODE | OPEN | + EOF | FILENO | SEEK | TELL)$/x, + qr/^( MODIFY | FETCH )_( REF | SCALAR | ARRAY | HASH | CODE | + GLOB | FORMAT | IO)_ATTRIBUTES $/x, + qr/^CLONE(_SKIP)?$/, + ]; + push @$private, @{ $args{also_private} || [] }; + my $trustme = $args{trustme} || []; + my $nonwhitespace = $args{nonwhitespace} || undef; + + my $self = bless { + @_, + private => $private, + trustme => $trustme, + nonwhitespace => $nonwhitespace + }, $class; +} + +=item $object->coverage + +Gives the coverage as a value in the range 0 to 1 + +=cut + +sub coverage { + my $self = shift; + + my $package = $self->{package}; + my $pods = $self->_get_pods; + return unless $pods; + + my %symbols = map { $_ => 0 } $self->_get_syms($package); + + print "tying shoelaces\n" if TRACE_ALL; + for my $pod (@$pods) { + $symbols{$pod} = 1 if exists $symbols{$pod}; + } + + foreach my $sym ( keys %symbols ) { + $symbols{$sym} = 1 if $self->_trustme_check($sym); + } + + # stash the results for later + $self->{symbols} = \%symbols; + + if (TRACE_ALL) { + require Data::Dumper; + print Data::Dumper::Dumper($self); + } + + my $symbols = scalar keys %symbols; + my $documented = scalar grep {$_} values %symbols; + unless ($symbols) { + $self->{why_unrated} = "no public symbols defined"; + return; + } + return $documented / $symbols; +} + +=item $object->why_unrated + +C<< $object->coverage >> may return C, to indicate that it was +unable to deduce coverage for a package. If this happens you should +be able to check C to get a useful excuse. + +=cut + +sub why_unrated { + my $self = shift; + $self->{why_unrated}; +} + +=item $object->naked/$object->uncovered + +Returns a list of uncovered routines, will implicitly call coverage if +it's not already been called. + +Note, private and 'trustme' identifiers will be skipped. + +=cut + +sub naked { + my $self = shift; + $self->{symbols} or $self->coverage; + return unless $self->{symbols}; + return grep { !$self->{symbols}{$_} } keys %{ $self->{symbols} }; +} + +*uncovered = \&naked; + +=item $object->covered + +Returns a list of covered routines, will implicitly call coverage if +it's not previously been called. + +As with C, private and 'trustme' identifiers will be skipped. + +=cut + +sub covered { + my $self = shift; + $self->{symbols} or $self->coverage; + return unless $self->{symbols}; + return grep { $self->{symbols}{$_} } keys %{ $self->{symbols} }; +} + +sub import { + my $self = shift; + return unless @_; + + # one argument - just a package + scalar @_ == 1 and unshift @_, 'package'; + + # we were called with arguments + my $pc = $self->new(@_); + my $rating = $pc->coverage; + $rating = 'unrated (' . $pc->why_unrated . ')' + unless defined $rating; + print $pc->{package}, " has a $self rating of $rating\n"; + my @looky_here = $pc->naked; + if ( @looky_here > 1 ) { + print "The following are uncovered: ", join( ", ", sort @looky_here ), + "\n"; + } elsif (@looky_here) { + print "'$looky_here[0]' is uncovered\n"; + } +} + +=back + +=head2 Debugging support + +In order to allow internals debugging, while allowing the optimiser to +do its thang, C uses constant subs to define how it traces. + +Use them like so + + sub Pod::Coverage::TRACE_ALL () { 1 } + use Pod::Coverage; + +Supported constants are: + +=over + +=item TRACE_ALL + +Trace everything. + +Well that's all there is so far, are you glad you came? + +=back + +=head2 Inheritance interface + +These abstract methods while functional in C may make +your life easier if you want to extend C to fit your +house style more closely. + +B Please consider this interface as in a state of flux until +this comment goes away. + +=over + +=item $object->_CvGV($symbol) + +Return the GV for the coderef supplied. Used by C<_get_syms> to identify +locally defined code. + +You probably won't need to override this one. + +=item $object->_get_syms($package) + +return a list of symbols to check for from the specified packahe + +=cut + +# this one walks the symbol tree +sub _get_syms { + my $self = shift; + my $package = shift; + + print "requiring '$package'\n" if TRACE_ALL; + eval qq{ require $package }; + print "require failed with $@\n" if TRACE_ALL and $@; + return if $@; + + print "walking symbols\n" if TRACE_ALL; + my $syms = Devel::Symdump->new($package); + + my @symbols; + for my $sym ( $syms->functions ) { + + # see if said method wasn't just imported from elsewhere + my $glob = do { no strict 'refs'; \*{$sym} }; + my $o = B::svref_2object($glob); + + # in 5.005 this flag is not exposed via B, though it exists + my $imported_cv = eval { B::GVf_IMPORTED_CV() } || 0x80; + next if $o->GvFLAGS & $imported_cv; + + # check if it's on the whitelist + $sym =~ s/$self->{package}:://; + next if $self->_private_check($sym); + + push @symbols, $sym; + } + return @symbols; +} + +=item _get_pods + +Extract pod markers from the currently active package. + +Return an arrayref or undef on fail. + +=cut + +sub _get_pods { + my $self = shift; + + my $package = $self->{package}; + + print "getting pod location for '$package'\n" if TRACE_ALL; + $self->{pod_from} ||= pod_where( { -inc => 1 }, $package ); + + my $pod_from = $self->{pod_from}; + unless ($pod_from) { + $self->{why_unrated} = "couldn't find pod"; + return; + } + + print "parsing '$pod_from'\n" if TRACE_ALL; + my $pod = Pod::Coverage::Extractor->new; + $pod->{nonwhitespace} = $self->{nonwhitespace}; + $pod->parse_from_file( $pod_from, '/dev/null' ); + + return $pod->{identifiers} || []; +} + +=item _private_check($symbol) + +return true if the symbol should be considered private + +=cut + +sub _private_check { + my $self = shift; + my $sym = shift; + return grep { $sym =~ /$_/ } @{ $self->{private} }; +} + +=item _trustme_check($symbol) + +return true if the symbol is a 'trustme' symbol + +=cut + +sub _trustme_check { + my ( $self, $sym ) = @_; + return grep { $sym =~ /$_/ } @{ $self->{trustme} }; +} + +sub _CvGV { + my $self = shift; + my $cv = shift; + my $b_cv = B::svref_2object($cv); + + # perl 5.6.2's B doesn't have an object_2svref. in 5.8 you can + # just do this: + # return *{ $b_cv->GV->object_2svref }; + # but for backcompat we're forced into this uglyness: + no strict 'refs'; + return *{ $b_cv->GV->STASH->NAME . "::" . $b_cv->GV->NAME }; +} + +package Pod::Coverage::Extractor; +use Pod::Parser; +use base 'Pod::Parser'; + +use constant debug => 0; + +# extract subnames from a pod stream +sub command { + my $self = shift; + my ( $command, $text, $line_num ) = @_; + if ( $command eq 'item' || $command =~ /^head(?:2|3|4)/ ) { + + # take a closer look + my @pods = ( $text =~ /\s*([^\s\|,\/]+)/g ); + $self->{recent} = []; + + foreach my $pod (@pods) { + print "Considering: '$pod'\n" if debug; + + # it's dressed up like a method cal + $pod =~ /-E<\s*gt\s*>(.*)/ and $pod = $1; + $pod =~ /->(.*)/ and $pod = $1; + + # it's used as a (bare) fully qualified name + $pod =~ /\w+(?:::\w+)*::(\w+)/ and $pod = $1; + + # it's wrapped in a pod style B<> + $pod =~ s/[A-Z]//g; + + # has arguments, or a semicolon + $pod =~ /(\w+)\s*[;\(]/ and $pod = $1; + + print "Adding: '$pod'\n" if debug; + push @{ $self->{ $self->{nonwhitespace} + ? "recent" + : "identifiers" } }, $pod; + } + } +} + +sub textblock { + my $self = shift; + my ( $text, $line_num ) = shift; + if ( $self->{nonwhitespace} and $text =~ /\S/ and $self->{recent} ) { + push @{ $self->{identifiers} }, @{ $self->{recent} }; + $self->{recent} = []; + } +} + +1; + +__END__ + +=back + +=head1 BUGS + +Due to the method used to identify documented subroutines +C may completely miss your house style and declare your +code undocumented. Patches and/or failing tests welcome. + +=head1 TODO + +=over + +=item Widen the rules for identifying documentation + +=item Improve the code coverage of the test suite. C rocks so hard. + +=back + +=head1 SEE ALSO + +L, L + +=head1 AUTHORS + +Richard Clamp + +Michael Stevens + +some contributions from David Cantrell + +=head1 COPYRIGHT + +Copyright (c) 2001, 2003, 2004, 2006, 2007, 2009 Richard Clamp, Michael +Stevens. All rights reserved. This program is free software; you can +redistribute it and/or modify it under the same terms as Perl itself. + +=cut diff --git a/lib/Pod/Coverage/CountParents.pm b/lib/Pod/Coverage/CountParents.pm new file mode 100644 index 0000000..08931e7 --- /dev/null +++ b/lib/Pod/Coverage/CountParents.pm @@ -0,0 +1,77 @@ +package Pod::Coverage::CountParents; +use strict; +use Pod::Coverage (); +use base 'Pod::Coverage'; + +# this code considered lightly fugly :) + +sub _get_pods { + my $self = shift; + my $package = $self->{package}; + + eval qq{ require $package }; + if ($@) { + $self->{why_unrated} = "Couldn't compile '$package' to inspect: $@"; + return; + } + + my %pods; + $pods{$package} = $self->SUPER::_get_pods; + + __walk_up($package, \%pods); + my %flat = map { $_ => 1 } map { @{ $_ || [] } } values %pods; + return [ keys %flat ]; +} + +sub __walk_up { + my $package = shift; + my $pods = shift; + + $pods->{$package} = Pod::Coverage->new(package => $package)->_get_pods(); + + my @parents; + { + no strict 'refs'; + @parents = @{"$package\::ISA"}; + } + + do { $pods->{$_} || __walk_up($_, $pods) } for @parents; +} + +1; +__END__ + + +=head1 NAME + +Pod::Coverage::CountParents - subclass of Pod::Coverage that examines the inheritance tree + +=head1 SYNOPSIS + + # all in one invocation + use Pod::Coverage::CountParents package => 'Fishy'; + + # straight OO + use Pod::Coverage::CountParents; + my $pc = new Pod::Coverage::CountParents package => 'Pod::Coverage'; + print "We rock!" if $pc->coverage == 1; + +=head1 DESCRIPTION + +This module extends Pod::Coverage to include the documentation from +parent classes when identifying the coverage of the code. + +If you want full documentation we suggest you check the +L documentation. + +=head1 SEE ALSO + +L, L + +=head1 AUTHOR + +Copyright (c) 2002 Richard Clamp. All rights reserved. This program +is free software; you can redistribute it and/or modify it under the +same terms as Perl itself. + +=cut diff --git a/lib/Pod/Coverage/ExportOnly.pm b/lib/Pod/Coverage/ExportOnly.pm new file mode 100644 index 0000000..df979b1 --- /dev/null +++ b/lib/Pod/Coverage/ExportOnly.pm @@ -0,0 +1,53 @@ +package Pod::Coverage::ExportOnly; +use strict; +use Pod::Coverage (); +use base qw(Pod::Coverage); + +sub _get_syms { + my $self = shift; + my $package = shift; + + # lifted from UNIVERSAL::exports + no strict 'refs'; + my %exports = map { $_ => 1 } @{$package.'::EXPORT'}, + @{$package.'::EXPORT_OK'}; + + return keys %exports; +} + +1; +__END__ + +=head1 NAME + +Pod::Coverage::ExportOnly - subclass of Pod::Coverage than only examines exported functions + +=head1 SYNOPSIS + + # all in one invocation + use Pod::Coverage::ExportOnly package => 'Fishy'; + + # straight OO + use Pod::Coverage::ExportOnly; + my $pc = new Pod::Coverage::ExportOnly package => 'Pod::Coverage'; + print "We rock!" if $pc->coverage == 1; + +=head1 DESCRIPTION + +This module extends Pod::Coverage to only check things explicitly set +up for export by the Exporter or UNIVERSAL::exports modules. If you +want full documentation we suggest you check the L +documentation + +=head1 SEE ALSO + +L, L, L + +=head1 AUTHORS + +Copyright (c) 2001 Richard Clamp, Micheal Stevens. All rights +reserved. This program is free software; you can redistribute it +and/or modify it under the same terms as Perl itself. + +=cut + diff --git a/lib/Pod/Coverage/Overloader.pm b/lib/Pod/Coverage/Overloader.pm new file mode 100644 index 0000000..fb09af8 --- /dev/null +++ b/lib/Pod/Coverage/Overloader.pm @@ -0,0 +1,37 @@ +package Pod::Coverage::Overloader; +use strict; +use Pod::Coverage (); +use base qw(Pod::Coverage); + +sub new { + my $class = shift; + + warn "Pod::Coverage::Overloader is deprecated. Please use Pod::Coverage instead"; + $class->SUPER::new( @_ ); +} + +1; +__END__ + +=head1 NAME + +Pod::Coverage::Overloader - deprecated subclass of Pod::Coverage + +=head1 SYNOPSIS + + # Please do not use this module, it was an experiment that went + # awry. Use Pod::Coverage instead + +=head1 DESCRIPTION + +=head1 SEE ALSO + +L, L + +=head1 AUTHORS + +Copyright (c) 2001 Richard Clamp, Micheal Stevens. All rights +reserved. This program is free software; you can redistribute it +and/or modify it under the same terms as Perl itself. + +=cut diff --git a/packaging/perl-Pod-Coverage.changes b/packaging/perl-Pod-Coverage.changes new file mode 100644 index 0000000..d0c2ab9 --- /dev/null +++ b/packaging/perl-Pod-Coverage.changes @@ -0,0 +1,53 @@ +* Tue Jun 5 2012 Junfeng Dong - 0.20-1 +- Clean up spec file for packaging. + +* Wed June 30 2010 Quanxian Wang - 0.20-1 +- Add %doc before man file entry + +* Fri Feb 27 2009 Zhu Yanhai - 0.20-1 +- Update to 0.20. + +* Wed Feb 27 2008 Tom "spot" Callaway - 0.19-3 +- Rebuild for perl 5.10 (again), second pass with tests enabled + +* Wed Feb 27 2008 Tom "spot" Callaway - 0.19-2 +- Rebuild for perl 5.10 (again), first pass without Test::Pod, tests + +* Sat Jan 12 2008 Steven Pritchard 0.19-1 +- Update to 0.19. +- Use fixperms macro instead of our own chmod incantation. +- Reformat to match cpanspec output. + +* Thu Jan 10 2007 Tom "spot" Callaway - 0.18-3 +- rebuild 2, enable Test::Pod, tests + +* Thu Jan 10 2007 Tom "spot" Callaway - 0.18-2.1 +- rebuild (first pass, no tests, no Test::Pod) + +* Wed Aug 9 2006 Jose Pedro Oliveira - 0.18-2 +- Version 0.18 is now a noarch package. + +* Wed Aug 9 2006 Jose Pedro Oliveira - 0.18-1 +- Update to 0.18. + +* Fri Feb 17 2006 Jose Pedro Oliveira - 0.17-5 +- Rebuild for FC5 (perl 5.8.8). + +* Thu May 12 2005 Jose Pedro Oliveira - 0.17-4 +- Add dist tag. + +* Wed Apr 20 2005 Jose Pedro Oliveira - 0.17-3 +- Avoid .packlist creation with Module::Build >= 0.2609. +- Trust that %%{perl_vendorlib} is defined. + +* Fri Apr 7 2005 Michael Schwendt +- rebuilt + +* Sat Nov 27 2004 Jose Pedro Oliveira - 0:0.17-1 +- Update to 0.17. + +* Wed Oct 20 2004 Jose Pedro Oliveira - 0:0.16-0.fdr.1 +- Update to 0.16. + +* Thu May 20 2004 Jose Pedro Oliveira - 0:0.14-0.fdr.1 +- First build. diff --git a/packaging/perl-Pod-Coverage.manifest b/packaging/perl-Pod-Coverage.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/perl-Pod-Coverage.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/perl-Pod-Coverage.spec b/packaging/perl-Pod-Coverage.spec new file mode 100644 index 0000000..18ca83a --- /dev/null +++ b/packaging/perl-Pod-Coverage.spec @@ -0,0 +1,51 @@ +#specfile originally created for Fedora, modified for Moblin Linux +Name: perl-Pod-Coverage +Version: 0.20 +Release: 1 +Summary: Checks if the documentation of a module is comprehensive +License: GPL+ or Artistic +Group: Development/Libraries +URL: http://search.cpan.org/dist/Pod-Coverage/ +Source0: %{name}-%{version}.tar.gz +Source1001: packaging/perl-Pod-Coverage.manifest +BuildArch: noarch +BuildRequires: perl(Devel::Symdump) >= 2.01 +BuildRequires: perl(Module::Build) +BuildRequires: perl(Test::Pod) +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) + +%description +Developers hate writing documentation. They'd hate it even more if their +computer tattled on them, but maybe they'll be even more thankful in the +long run. Even if not, perlmodstyle tells you to, so you must obey. + +This module provides a mechanism for determining if the pod for a given +module is comprehensive. + +%prep +%setup -q + +%build +cp %{SOURCE1001} . +%{__perl} Build.PL installdirs=vendor +./Build + +%install +rm -rf $RPM_BUILD_ROOT + +./Build install destdir=$RPM_BUILD_ROOT create_packlist=0 +find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \; + +%check +./Build test + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%manifest perl-Pod-Coverage.manifest +%defattr(-,root,root,-) +%doc Changes examples/ +%{_bindir}/* +%{perl_vendorlib}/* +%doc %{_mandir}/man3/* diff --git a/t/01compile.t b/t/01compile.t new file mode 100644 index 0000000..ac633ad --- /dev/null +++ b/t/01compile.t @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w +use Test::More tests => 4; + +use_ok('Pod::Coverage'); +use_ok('Pod::Coverage::ExportOnly'); +use_ok('Pod::Coverage::Overloader'); +use_ok('Pod::Coverage::CountParents'); + diff --git a/t/02simple.t b/t/02simple.t new file mode 100644 index 0000000..4cf6670 --- /dev/null +++ b/t/02simple.t @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 33; +use lib 't/lib'; + +BEGIN { + use_ok( 'Pod::Coverage' ); + use_ok( 'Pod::Coverage::ExportOnly' ); +} + +my $obj = new Pod::Coverage package => 'Simple1'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 2/3, "Simple1 has 2/3rds coverage"); + +$obj = new Pod::Coverage package => 'Simple2'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 0.75, "Simple2 has 75% coverage"); + +ok( eq_array([ $obj->naked ], [ 'naked' ]), "naked isn't covered"); + +ok( eq_array([ $obj->naked ], [ $obj->uncovered ]), "naked is uncovered"); + +$obj = new Pod::Coverage package => 'Simple2', private => [ 'naked' ]; +isa_ok( $obj, 'Pod::Coverage' ); + +is ( $obj->coverage, 1, "nakedness is a private thing" ); + +$obj = new Pod::Coverage package => 'Simple1', also_private => [ 'bar' ]; +isa_ok( $obj, 'Pod::Coverage' ); + +is ( $obj->coverage, 1, "it's also a private bar" ); + +ok( eq_array([ sort $obj->covered ], [ 'baz', 'foo' ]), "those guys are covered" ); + +$obj = new Pod::Coverage package => 'Pod::Coverage'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1, "Pod::Coverage is covered" ); + +$obj = new Pod::Coverage package => 'Simple3'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1, 'Simple3 is covered' ); + +$obj = new Pod::Coverage package => 'Simple4'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1, "External .pod grokked" ); + +$obj = new Pod::Coverage package => 'Simple5'; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1, "Multiple docs per item works" ); + +$obj = new Pod::Coverage package => "Simple6"; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1/3, "Simple6 is 2/3rds with no extra effort" ); + +$obj = new Pod::Coverage::ExportOnly package => "Simple6"; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, 1/2, "Simple6 is 50% if you only check exports" ); + +$obj = new Pod::Coverage package => "Simple8"; +isa_ok( $obj, 'Pod::Coverage' ); + +is( $obj->coverage, undef, "can't deduce for Simple8" ); +is( $obj->why_unrated, 'no public symbols defined', 'why is correct' ); + +$obj = Pod::Coverage->new( package => 'Earle' ); +is( $obj->coverage, 1, "earle is covered" ); +is( scalar $obj->covered, 2 ); + +$obj = Pod::Coverage->new( package => 'Args' ); +is( $obj->coverage, 1, "Args is covered" ); + +$obj = Pod::Coverage->new( package => 'XS4ALL' ); +is( $obj->coverage, 1, "XS4ALL is covered" ); + +$obj = Pod::Coverage->new( package => 'Fully::Qualified' ); +is( $obj->coverage, 1, "Fully::Qualified is covered" ); diff --git a/t/03import.t b/t/03import.t new file mode 100644 index 0000000..fd86c2f --- /dev/null +++ b/t/03import.t @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w +use strict; +use lib 't/lib'; +use Test::More tests => 3; + + +is( capture(q{ use Pod::Coverage package => 'Simple2'; }), "Simple2 has a Pod::Coverage rating of 0.75\n'naked' is uncovered", "Simple2 works correctly in import form"); + +is( capture(q{ use Pod::Coverage package => 'Simple7' }), "Simple7 has a Pod::Coverage rating of 0\nThe following are uncovered: bar, foo", 'Simple7 import form'); + +is( capture(q{ use Pod::Coverage 'Simple7' }), "Simple7 has a Pod::Coverage rating of 0\nThe following are uncovered: bar, foo", 'Simple7 import form, implicit package'); + +sub capture { + my $code = shift; + open(FH, ">test.out") or die "Couldn't open test.out for writing: $!"; + open(OLDOUT, ">&STDOUT"); + select(select(OLDOUT)); + open(STDOUT, ">&FH"); + + eval $code; + + close STDOUT; + close FH; + open(STDOUT, ">&OLDOUT"); + open(FH, "; } + chomp $result; + close FH; + unlink('test.out'); + return $result; +} diff --git a/t/04cvgv.t b/t/04cvgv.t new file mode 100644 index 0000000..1d6f6d8 --- /dev/null +++ b/t/04cvgv.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 4; +use Pod::Coverage (); + +my $pc = Pod::Coverage->new(); +isa_ok( $pc, 'Pod::Coverage' ); + +package wibble; +sub bar {}; +package main; +sub foo {} +sub baz::baz {}; +*bar = \&wibble::bar; +*baz = \&baz::baz; + +is ( $pc->_CvGV(\&foo), '*main::foo', 'foo checks out' ); +is ( $pc->_CvGV(\&bar), '*wibble::bar', 'bar looks right' ); +is ( $pc->_CvGV(\&baz), '*baz::baz', 'baz too' ); diff --git a/t/05parentage.t b/t/05parentage.t new file mode 100644 index 0000000..24e744f --- /dev/null +++ b/t/05parentage.t @@ -0,0 +1,19 @@ +#!perl -w +use strict; +use lib 't/lib'; + +use Test::More tests => 5; + +BEGIN { + use_ok( 'Pod::Coverage::CountParents' ); +} + +my $pc = Pod::Coverage::CountParents->new(package => 'Child'); +isa_ok( $pc, 'Pod::Coverage::CountParents' ); + +is( $pc->coverage, 1, 'picked up parent docs' ); + +$pc = Pod::Coverage::CountParents->new(package => 'Sibling'); +isa_ok( $pc, 'Pod::Coverage::CountParents' ); + +is( $pc->coverage, 1, 'picked up grandparent docs' ); diff --git a/t/06trustme.t b/t/06trustme.t new file mode 100644 index 0000000..4ca0b49 --- /dev/null +++ b/t/06trustme.t @@ -0,0 +1,30 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 10; +use lib 't/lib'; + +BEGIN { + use_ok( 'Pod::Coverage' ); + use_ok( 'Pod::Coverage::ExportOnly' ); +} + +my $obj = new Pod::Coverage package => 'Trustme'; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 3/7, "without private or trustme it gets it right"); + +$obj = new Pod::Coverage package => 'Trustme', private => [qr/^private$/]; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 3/6, "with just private it gets it right"); + +$obj = new Pod::Coverage + package => 'Trustme', + private => [qr/^private$/], + trustme => [qr/u/]; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 5/6, "with private and trustme it gets it right"); + +$obj = new Pod::Coverage + package => 'Trustme', + trustme => [qr/u/]; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 5/7, "with just trustme it gets it right"); diff --git a/t/07pod.t b/t/07pod.t new file mode 100644 index 0000000..437887a --- /dev/null +++ b/t/07pod.t @@ -0,0 +1,4 @@ +use Test::More; +eval "use Test::Pod 1.00"; +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; +all_pod_files_ok(); diff --git a/t/08tie.t b/t/08tie.t new file mode 100644 index 0000000..12fc7b6 --- /dev/null +++ b/t/08tie.t @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 4; +use lib 't/lib'; + +BEGIN { + use_ok( 'Pod::Coverage' ); + use_ok( 'Pod::Coverage::ExportOnly' ); +} + +my $obj = new Pod::Coverage package => 'Tie'; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 1, "yay, skipped TIE* and friends"); diff --git a/t/09whitespace.t b/t/09whitespace.t new file mode 100644 index 0000000..56421c0 --- /dev/null +++ b/t/09whitespace.t @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w +use strict; +use Test::More tests => 3; +use lib 't/lib'; + +BEGIN { + use_ok( 'Pod::Coverage' ); +} + +my $obj = new Pod::Coverage package => 'Empty', nonwhitespace => 1; +isa_ok( $obj, 'Pod::Coverage' ); +is($obj->coverage, 0.5, "Noticed empty pod section"); diff --git a/t/lib/Args.pm b/t/lib/Args.pm new file mode 100644 index 0000000..8da2164 --- /dev/null +++ b/t/lib/Args.pm @@ -0,0 +1,12 @@ +package Args; + +sub foo {} + +1; +__END__ + +# test module - one sub, documented with a head2 with sample arguments + +=head2 foo($bar, @baz) + +foo takes a bar and the rest of the stuff is an array of bazen diff --git a/t/lib/Child.pm b/t/lib/Child.pm new file mode 100644 index 0000000..eba6a1a --- /dev/null +++ b/t/lib/Child.pm @@ -0,0 +1,10 @@ +package Child; +use Parent (); +use base 'Parent'; + +sub foo { +} + +1; +__END__ + diff --git a/t/lib/Earle.pm b/t/lib/Earle.pm new file mode 100644 index 0000000..c1f90cc --- /dev/null +++ b/t/lib/Earle.pm @@ -0,0 +1,16 @@ +package Earle; + +=head1 NAME + +Earle - ape Earle's odd layout stuff. + +=head2 C + +These subs are useful if you need example subs + +=cut + +sub foo {} +sub bar {} + +1; diff --git a/t/lib/Empty.pm b/t/lib/Empty.pm new file mode 100644 index 0000000..e7faf95 --- /dev/null +++ b/t/lib/Empty.pm @@ -0,0 +1,18 @@ +package Empty; + +sub foo {} +sub bar {} + +1; +__END__ + +# test module - two subs, one with docs, one with empty pod section + +=head2 foo + +=head2 bar + +bar does things! + +=cut + diff --git a/t/lib/Fully/Qualified.pm b/t/lib/Fully/Qualified.pm new file mode 100644 index 0000000..4c6e4ad --- /dev/null +++ b/t/lib/Fully/Qualified.pm @@ -0,0 +1,45 @@ +package Fully::Qualified; +use strict; +use warnings; + +use vars qw( $VERSION @EXPORT_OK ); +$VERSION=0.001; + +use base 'Exporter'; +@EXPORT_OK = qw( &ex_sub2 ); + +=head1 NAME + +Fully::Qualified - Test for Pod::Coverage + +=head1 SYNOPSIS + +none + +=head1 DESCRIPTION + +This package is to see that L sees fully qualified subnames as documented. (Not all the world is OO) + +=over 4 + +=item C + +Okay, it is API; but not exported + +=cut + +sub api_sub1 { "in api_sub1" } + +=item Fully::Qualified::ex_sub2 + +This sub can be exported. + +=cut + +sub ex_sub2 { "in ex_sub2" } + +=back + +=cut + +1; diff --git a/t/lib/GrandParent.pm b/t/lib/GrandParent.pm new file mode 100644 index 0000000..05b5783 --- /dev/null +++ b/t/lib/GrandParent.pm @@ -0,0 +1,14 @@ +package GrandParent; + +sub dummy {}; + +1; +__END__ + +=head1 NAME + +GrandParent + +=head2 grandparent_method + +=cut diff --git a/t/lib/Parent.pm b/t/lib/Parent.pm new file mode 100644 index 0000000..7183adb --- /dev/null +++ b/t/lib/Parent.pm @@ -0,0 +1,18 @@ +package Parent; +use GrandParent (); +use base 'GrandParent'; +sub dummy {}; + +1; +__END__ + +=head1 NAME + +Parent demo class + +=head2 foo + +you must implement this in a derived class + +=cut + diff --git a/t/lib/Sibling.pm b/t/lib/Sibling.pm new file mode 100644 index 0000000..ae8fe59 --- /dev/null +++ b/t/lib/Sibling.pm @@ -0,0 +1,9 @@ +package Sibling; +use Parent (); +use base 'Parent'; + +sub grandparent_method { +} + +1; +__END__ diff --git a/t/lib/Simple1.pm b/t/lib/Simple1.pm new file mode 100644 index 0000000..6364a90 --- /dev/null +++ b/t/lib/Simple1.pm @@ -0,0 +1,27 @@ +package Simple1; + +sub foo {} +sub bar {} +sub baz {} + +1; +__END__ + +# test module - three subs, one without, one with an item, one with a head2 + +=head2 Methods + +=over + +=item foo + +this is foo + +=back + +=head2 baz + +baz is very important + +=cut + diff --git a/t/lib/Simple2.pm b/t/lib/Simple2.pm new file mode 100644 index 0000000..b6b844d --- /dev/null +++ b/t/lib/Simple2.pm @@ -0,0 +1,31 @@ +package Simple2; + +# test module - four subs, one with embedded pod item, one with a head2, one +# with a method call, one with nowt + +sub foo {} +sub baz {} +sub qux {} +sub naked {} + + + +1; +__END__ + +=head2 Methods + +=over + +=item foo + +this is foo + +=item $object->baz() + +=item B + +=back + +=cut + diff --git a/t/lib/Simple3.pm b/t/lib/Simple3.pm new file mode 100644 index 0000000..9974f6f --- /dev/null +++ b/t/lib/Simple3.pm @@ -0,0 +1,16 @@ +package Simple3; + +sub h3 {} +sub has_parens {} + +1; + +__END__ + +# test module - all covered, just make sure that we catch them properly + +=head3 h3 + +=head2 has_parens (stuff, here) + +=cut diff --git a/t/lib/Simple4.pm b/t/lib/Simple4.pm new file mode 100644 index 0000000..3028108 --- /dev/null +++ b/t/lib/Simple4.pm @@ -0,0 +1,7 @@ +# a package with external .pod +package Simple4; + +sub foo {} + +1; +__END__ diff --git a/t/lib/Simple4.pod b/t/lib/Simple4.pod new file mode 100644 index 0000000..b5cfb25 --- /dev/null +++ b/t/lib/Simple4.pod @@ -0,0 +1,9 @@ +=head1 NAME + +Simple4 - ya test + +=over + +=item foo () + +=back diff --git a/t/lib/Simple5.pm b/t/lib/Simple5.pm new file mode 100644 index 0000000..338b0fa --- /dev/null +++ b/t/lib/Simple5.pm @@ -0,0 +1,15 @@ +package Simple5; + +=head1 NAME + +=item get_foo set_foo + +frob foo + +=cut + +sub get_foo {} +sub set_foo {} + +1; +__END__ diff --git a/t/lib/Simple6.pm b/t/lib/Simple6.pm new file mode 100644 index 0000000..67db69f --- /dev/null +++ b/t/lib/Simple6.pm @@ -0,0 +1,23 @@ +# an exporter - 3 subs, 1 documented, 2 exportable +package Simple6; +use strict; + +require Exporter; +use base 'Exporter'; +use vars qw/@EXPORT @EXPORT_OK/; + +@EXPORT = qw(foo); +@EXPORT_OK = qw(foo bar); + +sub foo {} +sub bar {} +sub baz {}; + +1; +__END__ + +=item bar + +this is bar + +=cut diff --git a/t/lib/Simple7.pm b/t/lib/Simple7.pm new file mode 100644 index 0000000..6d78638 --- /dev/null +++ b/t/lib/Simple7.pm @@ -0,0 +1,13 @@ +package Simple7; + +=head1 NAME + +Simple7 - two, both uncovered + +=cut + +sub foo {} +sub bar {} + +1; +__END__ diff --git a/t/lib/Simple8.pm b/t/lib/Simple8.pm new file mode 100644 index 0000000..d836bbd --- /dev/null +++ b/t/lib/Simple8.pm @@ -0,0 +1,5 @@ +package Simple8; + +=item docs + +=cut diff --git a/t/lib/Tie.pm b/t/lib/Tie.pm new file mode 100644 index 0000000..60d07f0 --- /dev/null +++ b/t/lib/Tie.pm @@ -0,0 +1,53 @@ +package Tie; + +=head1 NAME + +Tie - stubs to make sure that TIE* and friends are skipped + +=head1 METHODS + +=item foo + +blah blah + +=cut + +sub foo { + print "I like pie\n"; +} + +sub TIESCALAR { print "foo"; } +sub TIEARRAY { print "foo"; } +sub TIEHASH { print "foo"; } +sub TIEHANDLE { print "foo"; } +sub FETCH { print "foo"; } +sub STORE { print "foo"; } +sub UNTIE { print "foo"; } +sub FETCHSIZE { print "foo"; } +sub STORESIZE { print "foo"; } +sub POP { print "foo"; } +sub PUSH { print "foo"; } +sub SHIFT { print "foo"; } +sub UNSHIFT { print "foo"; } +sub SPLICE { print "foo"; } +sub DELETE { print "foo"; } +sub EXISTS { print "foo"; } +sub EXTEND { print "foo"; } +sub CLEAR { print "foo"; } +sub FIRSTKEY { print "foo"; } +sub NEXTKEY { print "foo"; } +sub PRINT { print "foo"; } +sub PRINTF { print "foo"; } +sub WRITE { print "foo"; } +sub READLINE { print "foo"; } +sub GETC { print "foo"; } +sub READ { print "foo"; } +sub CLOSE { print "foo"; } +sub BINMODE { print "foo"; } +sub OPEN { print "foo"; } +sub EOF { print "foo"; } +sub FILENO { print "foo"; } +sub SEEK { print "foo"; } +sub TELL { print "foo"; } + +1; diff --git a/t/lib/Trustme.pm b/t/lib/Trustme.pm new file mode 100644 index 0000000..ada796b --- /dev/null +++ b/t/lib/Trustme.pm @@ -0,0 +1,40 @@ +package Trustme; + +# test module - four subs, one with embedded pod item, one with a head2, one +# with a method call, one with nowt + +sub foo {} +sub bar {} +sub baz {} +sub naked {} +sub private {} +sub trustme {} +sub trust_me {} + + +1; +__END__ + + +=head2 METHODS + +=over 4 + +=item foo + +foo does foo to things + +=item bar + +bar does bar to things + +=item baz + +baz does baz to things + +=back + +This paragraph should be considered to be the docs for any +method containing the letter u in its name. + +=cut diff --git a/t/lib/XS4ALL.pm b/t/lib/XS4ALL.pm new file mode 100644 index 0000000..f979b31 --- /dev/null +++ b/t/lib/XS4ALL.pm @@ -0,0 +1,30 @@ +package XS4ALL; +# some failing elements of XS4ALL's house style + +=head2 $self->classes; + +something somthing + +=cut + +sub classes {} + +=head2 $level = $mmdb->transaction_level; + +rhubarb rhubarb + +=cut + +sub transaction_level {} + +=head2 $self->frobnicate(); + +mushrooms mushrooms + +=cut + +sub frobnicate {} + + +1; + -- 2.7.4