Skip Menu |

This queue is for tickets about the Pod-Parser CPAN distribution.

Report information
The Basics
Id: 87891
Status: resolved
Worked: 40 min
Priority: 0/
Queue: Pod-Parser

People
Owner: Marek.Rouchal [...] gmx.net
Requestors: florent.angly [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.61
Fixed in: (no value)



Subject: More sanity checks in podselect()
Hi, I mistakenly passed an arrayref of files to podselect() (v1.6.1) instead of an array of files. This mistake caused podselect to just stall and do nothing. Here is a way to reproduce my mistake: use Pod::Select; my @arr = ( 'script.pl' ); podselect( \@arr ); The same behaviour is obtained with this other piece of code: use Pod::Select; my $file = ( '' ); podselect( $file ); In both cases, what I expected would be an error message since I did not pass valid files to podselect(). Is it possible to add a couple of sanity checks to podselect() ? Cheers, Florent
The documentation describes what podselect() expects as parameters. The intent of podselect to be benign, i.e. not to croak on invalid or empty parameters. If I changed that, central tools like Pod::Usage would cease to work as advertised. If you would like more strictness, implement it in your client script/module. -Marek
Dear Marek, I just re-read the documentation of podselect() at https://metacpan.org/module/Pod::Select. According to this documentation, files to be processed must be a list containing filenames, "-" or "<&STDIN". In my two examples, the input was not valid according to this documentation. The documentation could need an update if the behavior you described is intended. Cheers, Florent PS/ It's a bit unrelated, but Getopt::Euclid spends quite a bit of time running podselect(). Is there any way of making podselect() faster or is it already as fast as you think it can get?
If you cared enough to read the ANNOUNCEMENT in Pod-Parser, you'd probably understand that there is not really a point in spending efforts to update Pod-Parser. Switch to Pod-Simple, this is unanimous agreement of the community that this is the preferred modern parser. If you provide a patch though, I will be happy to consider it. -Marek Am So 22. Sep 2013, 19:18:55, FANGLY schrieb: Show quoted text
> Dear Marek, > > I just re-read the documentation of podselect() at > https://metacpan.org/module/Pod::Select. According to this > documentation, files to be processed must be a list containing > filenames, "-" or "<&STDIN". In my two examples, the input was not > valid according to this documentation. > > The documentation could need an update if the behavior you described > is intended. > > Cheers, > > Florent > > > PS/ It's a bit unrelated, but Getopt::Euclid spends quite a bit of > time running podselect(). Is there any way of making podselect() > faster or is it already as fast as you think it can get?
Dear Marek, People who download the Pod-Parser distribution (and see the ANNOUNCE file) and install it manually are probably a minority compared to people who installed it in an automated fashion. I included a first patch, which affects documents the deprecation in all modules included in Pod-Parser. The second patch addresses the two use-case I filed above. The case where an empty string is passed is a case where the POD was not clear enough. The case where an arrayref is passed is a case where more thorough input checking needed to be done. In the future I will certainly consider Pod-Simple. I need to read its documentation but it does not seem that there is a ready-made module in Pod-Simple that does what Pod::Select does. I suppose I will have to write and contribute such a module. Thank you, Florent
Subject: patch1_deprecation_message.patch
diff -rupN Pod-Parser-1.61/lib/Pod/Find.pm Pod-Parser-1.61-deprec/lib/Pod/Find.pm --- Pod-Parser-1.61/lib/Pod/Find.pm 2013-06-01 23:13:52.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/Find.pm 2013-09-27 11:22:39.000000000 +1000 @@ -45,6 +45,10 @@ Pod::Find - find POD documents in direct =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + B<Pod::Find> provides a set of functions to locate POD files. Note that no function is exported by default to avoid pollution of your namespace, so be sure to specify them in the B<use> statement if you need them: diff -rupN Pod-Parser-1.61/lib/Pod/InputObjects.pm Pod-Parser-1.61-deprec/lib/Pod/InputObjects.pm --- Pod-Parser-1.61/lib/Pod/InputObjects.pm 2013-06-01 23:08:46.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/InputObjects.pm 2013-09-27 11:22:18.000000000 +1000 @@ -35,6 +35,10 @@ Nothing. =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + This module defines some basic input objects used by B<Pod::Parser> when reading and parsing POD text from an input source. The following objects are defined: diff -rupN Pod-Parser-1.61/lib/Pod/Parser.pm Pod-Parser-1.61-deprec/lib/Pod/Parser.pm --- Pod-Parser-1.61/lib/Pod/Parser.pm 2013-06-01 23:12:20.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/Parser.pm 2013-09-27 11:22:06.000000000 +1000 @@ -81,6 +81,10 @@ Nothing. =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + B<Pod::Parser> is a base class for creating POD filters and translators. It handles most of the effort involved with parsing the POD sections from an input stream, leaving subclasses free to be concerned only with @@ -90,10 +94,6 @@ B<Pod::Parser> parses PODs, and makes me components of the POD. Subclasses of B<Pod::Parser> override these methods to translate the POD into whatever output format they desire. -Note: This module is considered as legacy; modern Perl releases (5.18 and -higher) are going to remove Pod::Parser from core and use L<Pod::Simple> -for all things POD. - =head1 QUICK OVERVIEW To create a POD filter for translating POD documentation into some other diff -rupN Pod-Parser-1.61/lib/Pod/ParseUtils.pm Pod-Parser-1.61-deprec/lib/Pod/ParseUtils.pm --- Pod-Parser-1.61/lib/Pod/ParseUtils.pm 2013-06-01 23:09:47.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/ParseUtils.pm 2013-09-27 11:22:24.000000000 +1000 @@ -27,6 +27,10 @@ Pod::ParseUtils - helpers for POD parsin =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + B<Pod::ParseUtils> contains a few object-oriented helper packages for POD parsing and processing (i.e. in POD formatters and translators). diff -rupN Pod-Parser-1.61/lib/Pod/PlainText.pm Pod-Parser-1.61-deprec/lib/Pod/PlainText.pm --- Pod-Parser-1.61/lib/Pod/PlainText.pm 2013-02-01 05:38:29.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/PlainText.pm 2013-09-27 11:22:28.000000000 +1000 @@ -621,6 +621,10 @@ Pod::PlainText - Convert POD data to for =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + Pod::PlainText is a module that can convert documentation in the POD format (the preferred language for documenting Perl) into formatted ASCII. It uses no special formatting controls or codes whatsoever, and its output is therefore diff -rupN Pod-Parser-1.61/lib/Pod/Select.pm Pod-Parser-1.61-deprec/lib/Pod/Select.pm --- Pod-Parser-1.61/lib/Pod/Select.pm 2013-06-01 23:12:57.000000000 +1000 +++ Pod-Parser-1.61-deprec/lib/Pod/Select.pm 2013-09-27 11:22:34.000000000 +1000 @@ -71,6 +71,10 @@ podselect() =head1 DESCRIPTION +B<NOTE: This module is considered legacy; modern Perl releases (5.18 and +higher) are going to remove Pod-Parser from core and use L<Pod-Simple> +for all things POD.> + B<podselect()> is a function which will extract specified sections of pod documentation from an input stream. This ability is provided by the B<Pod::Select> module which is a subclass of B<Pod::Parser>.
Subject: patch2_rt87891.patch
diff -rupN Pod-Parser-1.61/lib/Pod/Parser.pm Pod-Parser-1.61-sanity/lib/Pod/Parser.pm --- Pod-Parser-1.61/lib/Pod/Parser.pm 2013-06-01 23:12:20.000000000 +1000 +++ Pod-Parser-1.61-sanity/lib/Pod/Parser.pm 2013-09-27 13:01:00.000000000 +1000 @@ -1146,7 +1146,7 @@ closes the input and output files. =back -If the special input filename "-" or "<&STDIN" is given then the STDIN +If the special input filename "", "-" or "<&STDIN" is given then the STDIN filehandle is used for input (and no open or close is performed). If no input filename is specified then "-" is implied. Filehandle references, or objects that support the regular IO operations (like C<E<lt>$fhE<gt>> diff -rupN Pod-Parser-1.61/lib/Pod/Select.pm Pod-Parser-1.61-sanity/lib/Pod/Select.pm --- Pod-Parser-1.61/lib/Pod/Select.pm 2013-06-01 23:12:57.000000000 +1000 +++ Pod-Parser-1.61-sanity/lib/Pod/Select.pm 2013-09-27 13:02:07.000000000 +1000 @@ -531,7 +531,7 @@ implicit first argument. B<podselect> will print the raw (untranslated) POD paragraphs of all POD sections in the given input files specified by C<@filelist> -according to the given options. +according to the options given in C<\%options>. If any argument to B<podselect> is a reference to a hash (associative array) then the values with the following keys are @@ -565,10 +565,10 @@ are used. =back -All other arguments should correspond to the names of input files -containing POD sections. A file name of "-" or "<&STDIN" will -be interpreted to mean standard input (which is the default if no -filenames are given). +All other arguments are optional and should correspond to the names +of input files containing POD sections. A file name of "", "-" or +"<&STDIN" will be interpreted to mean standard input (which is the +default if no filenames are given). =cut @@ -581,8 +581,11 @@ sub podselect { my %opts; local $_; for (@argv) { - if (ref($_)) { - next unless (ref($_) eq 'HASH'); + my $ref = ref($_); + if ($ref) { + if (not $ref eq 'HASH') { + croak "Input from $ref reference not supported!\n"; + } %opts = (%defaults, %{$_}); ##------------------------------------------------------------- @@ -617,7 +620,7 @@ sub podselect { ++$num_inputs; } } - $pod_parser->parse_from_file('-') unless ($num_inputs > 0); + $pod_parser->parse_from_file('-') unless ($num_inputs > 0); } ############################################################################# diff -rupN Pod-Parser-1.61/t/pod/testp2pt.pl Pod-Parser-1.61-sanity/t/pod/testp2pt.pl --- Pod-Parser-1.61/t/pod/testp2pt.pl 2011-09-17 00:32:16.000000000 +1000 +++ Pod-Parser-1.61-sanity/t/pod/testp2pt.pl 2013-09-27 12:33:43.000000000 +1000 @@ -141,8 +141,8 @@ sub testpodplaintext( @ ) { my %opts = (ref $_[0] eq 'HASH') ? %{shift()} : (); my @testpods = @_; my ($testname, $testdir) = ("", ""); - my ($podfile, $cmpfile) = ("", ""); - my ($outfile, $errfile) = ("", ""); + my ($podfile , $cmpfile) = ("", ""); + my ($outfile , $errfile) = ("", ""); my $passes = 0; my $failed = 0; local $_;
I am marking this report as open since you said you would consider patches. Cheers, Florent
Here is another patch that documents that podselect() accepts filehandles for input and output.
Subject: patch_doc_update.patch
diff -rupN Pod-Parser-1.61/lib/Pod/Select.pm Pod-Parser-1.61-doc-update/lib/Pod/Select.pm --- Pod-Parser-1.61/lib/Pod/Select.pm 2013-06-01 23:12:57.000000000 +1000 +++ Pod-Parser-1.61-doc-update/lib/Pod/Select.pm 2013-10-03 17:26:29.867529793 +1000 @@ -542,7 +542,8 @@ processed as follows: =item B<-output> A string corresponding to the desired output file (or ">&STDOUT" -or ">&STDERR"). The default is to use standard output. +or ">&STDERR"), or a filehandle to write on. The default is to use +standard output. =item B<-sections> @@ -565,10 +566,10 @@ are used. =back -All other arguments should correspond to the names of input files -containing POD sections. A file name of "-" or "<&STDIN" will -be interpreted to mean standard input (which is the default if no -filenames are given). +All other arguments should correspond to filehandles to read from or +names of input files containing POD sections. A file name of "-" or +"<&STDIN" will be interpreted to mean standard input (which is the +default if no filenames are given). =cut
Fixed in 1.62, coming to CPAN asap.