| 1 | package Dist::Zilla::Plugin::PodKnit; | ||
| 2 | 1 | our $AUTHORITY = 'cpan:YANICK'; | |
| 3 | # ABSTRACT: craft from warm and fuzzy documentation for your Perl code | ||
| 4 | 1 | $Dist::Zilla::Plugin::PodKnit::VERSION = '0.0.1'; | |
| 5 | |||
| 6 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | use Log::Any qw/ $log /, prefix => 'DZP::PK: '; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 1 | ▶ | use Log::Any::Adapter 'Stderr'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 1 | ▶ | use Moose::Util qw/ with_traits /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | |||
| 17 | 1 | with( | |
| 18 | 'Dist::Zilla::Role::FileMunger', | ||
| 19 | 'Dist::Zilla::Role::FileFinderUser' => { | ||
| 20 | default_finders => [ ':InstallModules', ':ExecFiles' ], | ||
| 21 | }, | ||
| 22 | ); | ||
| 23 | |||
| 24 | 1 | ▶ | use experimental 'postderef'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | has knit => ( | ||
| 27 | is => 'ro', | ||
| 28 | lazy => 1, | ||
| 29 | 0 | ▶ | default => sub { |
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||
| 30 | 0 | my $self = shift; | |
| 31 | |||
| 32 | 0 | my $knit = with_traits( 'Pod::Knit', 'Pod::Knit::Zilla' )->new( | |
| 33 | zilla => $self->zilla | ||
| 34 | ); | ||
| 35 | |||
| 36 | $knit->stash->{$_} = $self->zilla->$_ | ||
| 37 | 0 | for qw/ version license authors distmeta /; | |
| 38 | |||
| 39 | 0 | return $knit; | |
| 40 | }, | ||
| 41 | 1 | ); | |
| 42 | |||
| 43 | 0 | ▶ | sub munge_files { |
|
Subroutine
munge_files: not called CC=2 SCAR=17.9
Pod
undocumented
| |||
| 44 | 0 | my ($self) = @_; | |
| 45 | |||
| 46 | $self->munge_file($_) | ||
| 47 | 0 | for grep { $_->name =~ /\.p[lm]$/ } $self->found_files->@*; | |
| 48 | } | ||
| 49 | |||
| 50 | 0 | ▶ | sub munge_file { |
|
Subroutine
munge_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 51 | 0 | my ($self, $file) = @_; | |
| 52 | |||
| 53 | 0 | $self->log_debug([ 'knitting pod in %s', $file->name ]); | |
| 54 | |||
| 55 | 0 | $self->munge_pod($file); | |
| 56 | } | ||
| 57 | |||
| 58 | 0 | ▶ | sub munge_pod { |
|
Subroutine
munge_pod: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 59 | 0 | my ($self, $file) = @_; | |
| 60 | |||
| 61 | 0 | $log->debugf( "munging '%s'", $file->name ); | |
| 62 | |||
| 63 | 0 | my $doc = $self->knit->munge_document( | |
| 64 | path => $file->name, | ||
| 65 | content => $file->content, | ||
| 66 | ); | ||
| 67 | |||
| 68 | # my $new_content = $self->munge_perl_string( | ||
| 69 | # $file->content, | ||
| 70 | # { | ||
| 71 | # zilla => $self->zilla, | ||
| 72 | # filename => $file->name, | ||
| 73 | # version => $self->zilla->version, | ||
| 74 | # license => $self->zilla->license, | ||
| 75 | # authors => $self->zilla->authors, | ||
| 76 | # distmeta => $self->zilla->distmeta, | ||
| 77 | # }, | ||
| 78 | # ); | ||
| 79 | |||
| 80 | 0 | $file->content( $doc->as_string ); | |
| 81 | } | ||
| 82 | |||
| 83 | 1 | __PACKAGE__->meta->make_immutable; | |
| 84 | |||
| 85 | 1 | 1; | |
| 86 | |||
| 87 | __END__ | ||