[Rt-commit] rt branch 5.0/convert-to-pod-simple created. rt-5.0.3-126-ge7a9a1d1d4

BPS Git Server git at git.bestpractical.com
Wed Oct 5 02:43:56 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/convert-to-pod-simple has been created
        at  e7a9a1d1d47fd2112e9f2faf565ef1ad1ee471ac (commit)

- Log -----------------------------------------------------------------
commit e7a9a1d1d47fd2112e9f2faf565ef1ad1ee471ac
Author: Brian Conry <bconry at bestpractical.com>
Date:   Tue Oct 4 21:40:07 2022 -0500

    Replace Pod::Select and Pod::PlainText
    
    Prior to this change, RT::Shredder::POD used Pod::Select and
    Pod::PlainText to generate plain-text help information for the
    command-line utility rt-shredder.
    
    Since Pod::Select id deprecated and going to be removed from Perl CORE,
    it has been replaced with Pod::Simple::Text.

diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index 9d80edad53..4b4d78a4d9 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -50,8 +50,8 @@ package RT::Shredder::POD;
 
 use strict;
 use warnings;
+use Pod::Simple::Text;
 use Pod::Select;
-use Pod::PlainText;
 
 sub plugin_html
 {
@@ -65,21 +65,20 @@ sub plugin_html
 sub plugin_cli
 {
     my ($file, $out_fh, $no_name) = @_;
-    local @Pod::PlainText::ISA = ('Pod::Select', @Pod::PlainText::ISA);
-    my $parser = Pod::PlainText->new();
-    $parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE');
-    $parser->add_selection('NAME') unless $no_name;
-    $parser->parse_from_file( $file, $out_fh );
+    my $parser = RT::Shredder::POD::Text->new;
+    $parser->output_fh($out_fh);
+    $parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE', ($no_name ? () : 'Name') );
+    $parser->parse_file( $file );
     return;
 }
 
 sub shredder_cli
 {
     my ($file, $out_fh) = @_;
-    local @Pod::PlainText::ISA = ('Pod::Select', @Pod::PlainText::ISA);
-    my $parser = Pod::PlainText->new();
+    my $parser = RT::Shredder::POD::Text->new;
+    $parser->output_fh($out_fh);
     $parser->select('NAME', 'SYNOPSIS', 'USAGE', 'OPTIONS');
-    $parser->parse_from_file( $file, $out_fh );
+    $parser->parse_file( $file );
     return;
 }
 
@@ -123,6 +122,75 @@ sub arguments_help {
 
 1;
 
+package RT::Shredder::POD::Text;
+use base qw(Pod::Simple::Text);
+
+sub new {
+    my $self = shift;
+    my $new = $self->SUPER::new(@_);
+    $new->{'Suppress'} = 1;
+    $new->{'InHead1'} = 0;
+    $new->{'Selected'} = {};
+    return $new;
+}
+
+sub select {
+    my $self = shift;
+    $self->{'Selected'}{$_} = 1 for @_;
+    return;
+}
+
+sub handle_text {
+    my $self = shift;
+
+    if ($self->{'InHead1'} and exists $self->{'Selected'}{ $_[0] }) {
+        $self->{'Suppress'} = 0;
+    }
+
+    return $self->SUPER::handle_text( @_ );
+}
+
+sub start_head1 {
+    my $self = shift;
+
+    $self->{'InHead1'} = 1;
+    $self->{'Suppress'} = 1;
+
+    return $self->SUPER::start_head1( @_ );
+}
+
+sub end_head1 {
+    my $self = shift;
+
+    $self->{'InHead1'} = 0;
+
+    return $self->SUPER::end_head1( @_ );
+}
+
+sub emit_par {
+    my $self = shift;
+
+    if ($self->{'Suppress'}) {
+        $self->{'Thispara'} = '';
+        return;
+    }
+
+    return $self->SUPER::emit_par( @_ );
+}
+
+sub end_Verbatim {
+    my $self = shift;
+
+    if ($self->{'Suppress'}) {
+        $self->{'Thispara'} = '';
+        return;
+    }
+
+    return $self->SUPER::end_Verbatim( @_ );
+}
+
+1;
+
 package RT::Shredder::POD::HTML;
 use base qw(Pod::Select);
 

commit 8437f72ac87fd2f4647b8b510909f958a927b248
Author: Brian Conry <bconry at bestpractical.com>
Date:   Tue Oct 4 21:39:41 2022 -0500

    Foer -> for
    
    Fix typo in comment

diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index ade9d12c5a..9d80edad53 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -83,7 +83,7 @@ sub shredder_cli
     return;
 }
 
-# Extract the help foer each argument from the plugin POD
+# Extract the help for each argument from the plugin POD
 # they must be on a =head2 line in the ARGUMENTS section of the POD
 # the return value is a hashref:
 #   keys are the argument names,

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list