Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POD below __DATA__ not recognized. #15

Open
mkrull opened this issue Dec 27, 2013 · 4 comments
Open

POD below __DATA__ not recognized. #15

mkrull opened this issue Dec 27, 2013 · 4 comments
Labels

Comments

@mkrull
Copy link

mkrull commented Dec 27, 2013

Pod in the __DATA__ section is valid acording to the documentation. Maybe this is on purpose (how good is good enough?) but it will be correctly parsed below __END__ so it maybe is not.

use strict;
use warnings;
use feature 'say';
use PPI::Document;

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.
=cut

my $content = '';
{
    local $/;
    open my $fh, '<', $0;
    $content = <$fh>;
    close $0;
}

my $doc = PPI::Document->new(\$content);
my $pod .= PPI::Token::Pod->merge(@{$doc->find('PPI::Token::Pod')});
say $pod;

__DATA__

=head1 More
This should also be a piece of POD. Should it?
=cut

This little test yields:

=pod

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.

=cut

When it should yield:

=pod

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.

=head1 More
This should also be a piece of POD. Should it?

=cut
@wchristian
Copy link
Member

I do believe this is intentional, since any content after END is generally documentation of some kind, while any content after DATA is a binary blob accessible as a filehandle in the Perl program.

@adamkennedy: Is this correct?

Note so i don't forget: If this is correct, then this issue should be converted into a doc improvement issue.

@mkrull
Copy link
Author

mkrull commented Dec 27, 2013

While it is true __DATA__ could contain anything perlpod explicitly mentions how to handle Pod below __DATA__ and __END__ in Embedding Pods in Perl Modules . I see the problems with parsing that but I guess Pod after __END__ should get handled if that is below __DATA__?

Like this:

use strict;
use warnings;
use feature 'say';
use PPI::Document;

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.
=cut

my $content = '';
{
    local $/;
    open my $fh, '<', $0;
    $content = <$fh>;
    close $0;
}

my $doc = PPI::Document->new(\$content);
my $pod .= PPI::Token::Pod->merge(@{$doc->find('PPI::Token::Pod')});
say $pod;

__DATA__
# some data here
__END__

=head1 More
This should also be a piece of POD. Should it?
=cut

In this case everything between __DATA__ and __END__ is accessable via DATA file handle according to The-DATA-token.

@wchristian
Copy link
Member

You're right. END after DATA should be handled. Can you make a second issue for that, referencing this one?

@mkrull
Copy link
Author

mkrull commented Dec 27, 2013

I opened #16 for the above case. I leave this one open because it is still unsure if Pod in the __DATA__ section should be parsed as perldoc does.. the documentation is not too specific about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants