| 1 | package Code::TidyAll::Plugin::PodTidy; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Capture::Tiny qw(capture_merged); | ||
| 7 | use Pod::Tidy; | ||
| 8 | use Specio::Library::Numeric; | ||
| 9 | |||
| 10 | use Moo; | ||
| 11 | |||
| 12 | extends 'Code::TidyAll::Plugin'; | ||
| 13 | |||
| 14 | our $VERSION = '0.83'; | ||
| 15 | |||
| 16 | has columns => ( | ||
| 17 | is => 'ro', | ||
| 18 | isa => t('PositiveInt'), | ||
| 19 | ); | ||
| 20 | |||
| 21 | sub transform_file { | ||
| 22 | my ( $self, $file ) = @_; | ||
| 23 | |||
| 24 | my $output = capture_merged { | ||
| 25 | Pod::Tidy::tidy_files( | ||
| 26 | files => [ $file->stringify ], | ||
| 27 | inplace => 1, | ||
| 28 | nobackup => 1, | ||
| 29 | verbose => 1, | ||
| 30 | ( $self->columns ? ( columns => $self->columns ) : () ), | ||
| 31 | ); | ||
| 32 | }; | ||
| 33 | die $output if $output =~ /\S/ && $output !~ /does not contain Pod/; | ||
| 34 | } | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | # ABSTRACT: Use podtidy with tidyall | ||
| 39 | |||
| 40 | __END__ | ||
| 41 | |||
| 42 | =pod | ||
| 43 | |||
| 44 | =encoding UTF-8 | ||
| 45 | |||
| 46 | =head1 NAME | ||
| 47 | |||
| 48 | Code::TidyAll::Plugin::PodTidy - Use podtidy with tidyall | ||
| 49 | |||
| 50 | =head1 VERSION | ||
| 51 | |||
| 52 | version 0.83 | ||
| 53 | |||
| 54 | =head1 SYNOPSIS | ||
| 55 | |||
| 56 | In configuration: | ||
| 57 | |||
| 58 | [PodTidy] | ||
| 59 | select = lib/**/*.{pm,pod} | ||
| 60 | columns = 90 | ||
| 61 | |||
| 62 | =head1 DESCRIPTION | ||
| 63 | |||
| 64 | Runs L<podtidy>, which will tidy the POD in your Perl or POD-only file. | ||
| 65 | |||
| 66 | =head1 INSTALLATION | ||
| 67 | |||
| 68 | Install podtidy from CPAN. | ||
| 69 | |||
| 70 | cpanm podtidy | ||
| 71 | |||
| 72 | =head1 CONFIGURATION | ||
| 73 | |||
| 74 | This plugin accepts the following configuration options: | ||
| 75 | |||
| 76 | =head2 columns | ||
| 77 | |||
| 78 | Number of columns per line. | ||
| 79 | |||
| 80 | =head1 SUPPORT | ||
| 81 | |||
| 82 | Bugs may be submitted at L<https://github.com/houseabsolute/perl-code-tidyall/issues>. | ||
| 83 | |||
| 84 | =head1 SOURCE | ||
| 85 | |||
| 86 | The source code repository for Code-TidyAll can be found at L<https://github.com/houseabsolute/perl-code-tidyall>. | ||
| 87 | |||
| 88 | =head1 AUTHORS | ||
| 89 | |||
| 90 | =over 4 | ||
| 91 | |||
| 92 | =item * | ||
| 93 | |||
| 94 | Jonathan Swartz <swartz@pobox.com> | ||
| 95 | |||
| 96 | =item * | ||
| 97 | |||
| 98 | Dave Rolsky <autarch@urth.org> | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | =head1 COPYRIGHT AND LICENSE | ||
| 103 | |||
| 104 | This software is copyright (c) 2011 - 2022 by Jonathan Swartz. | ||
| 105 | |||
| 106 | This is free software; you can redistribute it and/or modify it under | ||
| 107 | the same terms as the Perl 5 programming language system itself. | ||
| 108 | |||
| 109 | The full text of the license can be found in the | ||
| 110 | F<LICENSE> file included with this distribution. | ||
| 111 | |||
| 112 | =cut |