[Rt-commit] rt branch 5.0/convert-to-pod-simple created. rt-5.0.3-128-g88991e1847
BPS Git Server
git at git.bestpractical.com
Thu Oct 6 20:09:24 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 88991e184710d65a2d31e0937a651a9425d8ffaf (commit)
- Log -----------------------------------------------------------------
commit 88991e184710d65a2d31e0937a651a9425d8ffaf
Author: Brian Conry <bconry at bestpractical.com>
Date: Wed Oct 5 14:39:12 2022 -0500
Remove dependency on Pod::Select
This change removes the explicit dependency on Pod::Select.
diff --git a/docs/UPGRADING-5.0 b/docs/UPGRADING-5.0
index 9991928fcd..58d59aefcf 100644
--- a/docs/UPGRADING-5.0
+++ b/docs/UPGRADING-5.0
@@ -487,6 +487,11 @@ additional defense against CSRF attacks in some browsers. See
L<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite>
for more details on valid values, their meaning, and browser support.
+=item * Removed dependency on Pod::Select
+
+We no longer depend on the Pod::Select Perl module since it has been deprecated
+following its removal from the Perl core.
+
=back
=cut
diff --git a/etc/cpanfile b/etc/cpanfile
index aaa8cb969f..1f308e7742 100644
--- a/etc/cpanfile
+++ b/etc/cpanfile
@@ -69,7 +69,6 @@ requires 'Net::IP';
requires 'Parallel::ForkManager';
requires 'Plack', '>= 1.0002';
requires 'Plack::Handler::Starlet';
-requires 'Pod::Select';
requires 'Regexp::Common';
requires 'Regexp::Common::net::CIDR';
requires 'Regexp::IPv6';
commit cb29990d761ea70af505b7320a18a4a35693c7f3
Author: Brian Conry <bconry at bestpractical.com>
Date: Wed Oct 5 14:30:03 2022 -0500
Replace Pod::Select HTML generation
Prior to this change, RT::Shredder::POD used Pod::Select to generate
HTML versions of help information for the Admin shredder pages in the RT
UI.
Since Pod::Select is deprecated and going to be removed from Perl CORE,
it has been replaced with Pod::Simple::HTML.
diff --git a/lib/RT/Shredder/POD.pm b/lib/RT/Shredder/POD.pm
index 4b4d78a4d9..fe10ae16bb 100644
--- a/lib/RT/Shredder/POD.pm
+++ b/lib/RT/Shredder/POD.pm
@@ -51,14 +51,14 @@ package RT::Shredder::POD;
use strict;
use warnings;
use Pod::Simple::Text;
-use Pod::Select;
sub plugin_html
{
my ($file, $out_fh) = @_;
my $parser = RT::Shredder::POD::HTML->new;
+ $parser->output_fh($out_fh);
$parser->select('SYNOPSIS', 'ARGUMENTS', 'USAGE');
- $parser->parse_from_file( $file, $out_fh );
+ $parser->parse_file( $file );
return;
}
@@ -94,18 +94,19 @@ sub arguments_help {
my ($file) = @_;
my $text;
- open( my $io_handle, ">:scalar", \$text )
- or die "Can't open scalar for write: $!";
my $parser = RT::Shredder::POD::HTML->new;
+ $parser->output_string(\$text);
$parser->select('ARGUMENTS');
- $parser->parse_from_file( $file, $io_handle );
+ $parser->parse_file( $file );
my $arguments_help = {};
- while( $text=~ m{<h4[^>]*> # argument description starts with an h4 title
- \s*(\S*) # argument name ($1)
+ while( $text=~ m{<h4[^>]*> # argument description starts with an h4 title
+ \s*<a\s*[^>]*> # is enclosed in an <a> tag
+ \s*(\S*) # argument name ($1)
\s*-\s*
- ([^<]*) # argument type ($2)
+ ([^<]*) # argument type ($2)
+ \s*</a>\s* # closing the <a>
</h4>\s*
(?:<p[^>]*>\s*
(.*?) # help: the first paragraph of the POD ($3)
@@ -192,61 +193,81 @@ sub end_Verbatim {
1;
package RT::Shredder::POD::HTML;
-use base qw(Pod::Select);
+use base qw(Pod::Simple::HTML);
-sub command
-{
- my( $self, $command, $paragraph, $line_num ) = @_;
+(our $VERSION = $RT::VERSION) =~ s/^(\d+\.\d+).*/$1/;
- my $tag;
- # =head1 => h3, =head2 => h4
- if ($command =~ /^head(\d+)$/) {
- my $h_level = $1 + 2;
- $tag = "h$h_level";
- }
- my $out_fh = $self->output_handle();
- my $expansion = $self->interpolate($paragraph, $line_num);
- $expansion =~ s/^\s+|\s+$//;
- $expansion = lc( $expansion );
- $expansion = ucfirst( $expansion );
-
- print $out_fh "<$tag class=\"rt-general-header1\">" if $tag eq 'h3';
- print $out_fh "<$tag class=\"rt-general-header2\">" if $tag eq 'h4';
- print $out_fh $expansion;
- print $out_fh "</$tag>" if $tag;
- print $out_fh "\n";
- return;
+sub new {
+ my $self = shift;
+ my $new = $self->SUPER::new(@_);
+
+ $new->{'Selected'} = {};
+
+ $new->html_h_level(3);
+ $new->__adjust_html_h_levels;
+ $new->{'Adjusted_html_h_levels'} = 3;
+
+ $new->_add_classes_to_types(
+ head1 => 'rt-general-header1',
+ head2 => 'rt-general-header2',
+ Para => 'rt-general-paragraph',
+ );
+
+ return $new;
}
-sub verbatim
-{
- my ($self, $paragraph, $line_num) = @_;
- my $out_fh = $self->output_handle();
- print $out_fh "<pre class=\"rt-general-paragraph\">";
- print $out_fh $paragraph;
- print $out_fh "</pre>";
- print $out_fh "\n";
- return;
+sub _add_classes_to_types {
+ my $self = shift;
+ my $Tagmap = $self->{'Tagmap'};
+
+ my %mods = @_;
+
+ foreach my $tagname ( keys %mods ) {
+ my $classname = $mods{$tagname};
+
+ next unless exists $Tagmap->{$tagname};
+
+ my $tagvalue = $Tagmap->{$tagname};
+
+ $tagvalue =~ s{(<\w+ class='[^']+)('>)$}{$1 $classname$2};
+ $tagvalue =~ s{(<\w+)(>)$}{$1 class='$classname'$2};
+
+ $Tagmap->{$tagname} = $tagvalue;
+ }
}
-sub textblock {
- my ($self, $paragraph, $line_num) = @_;
- my $out_fh = $self->output_handle();
- my $expansion = $self->interpolate($paragraph, $line_num);
- $expansion =~ s/^\s+|\s+$//;
- print $out_fh "<p class=\"rt-general-paragraph\">";
- print $out_fh $expansion;
- print $out_fh "</p>";
- print $out_fh "\n";
+sub select {
+ my $self = shift;
+ $self->{'Selected'}{$_} = 1 for @_;
return;
}
-sub interior_sequence {
- my ($self, $seq_command, $seq_argument) = @_;
- ## Expand an interior sequence; sample actions might be:
- return "<b>$seq_argument</b>" if $seq_command eq 'B';
- return "<i>$seq_argument</i>" if $seq_command eq 'I';
- return "<tt>$seq_argument</tt>" if $seq_command eq 'C';
- return "<span class=\"pod-sequence-$seq_command\">$seq_argument</span>";
+sub get_token {
+ my $self = shift;
+
+ my $token = $self->SUPER::get_token();
+
+ return $token unless $token;
+
+ if (scalar keys %{ $self->{'Selected'} }) {
+ while ($token and $token->type eq 'start' and $token->tagname eq 'head1') {
+ my $next_token = $self->SUPER::get_token();
+
+ if ($next_token->type eq 'text' and not exists $self->{'Selected'}{ $next_token->text }) {
+ # discard everything up to, but not including, the start of the next head1
+ while ($next_token and ($next_token->type ne 'start' or $next_token->tagname ne 'head1')) {
+ $next_token = $self->SUPER::get_token();
+ }
+ $token = $next_token;
+ }
+ else {
+ $self->unget_token($next_token);
+ last;
+ }
+ }
+ }
+
+ return $token;
}
+
1;
commit 8059837b09b034e1fac48a06a07c3878c3923c4a
Author: Brian Conry <bconry at bestpractical.com>
Date: Tue Oct 4 21:40:07 2022 -0500
Replace Pod::Select and Pod::PlainText for plain text
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 is 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