Another blocked mail that deserves a better treatment.
Mt
----- Forwarded message from Russ Allbery <rra(a)cpan.org> -----
Date: Mon, 25 May 2020 09:48:19 -0700
From: Russ Allbery <rra(a)cpan.org>
To: Martin Quinson <martin.quinson(a)ens-rennes.fr>
Cc: pod-people(a)perl.org, devel(a)lists.po4a.org
Subject: Re: Example of dumper (along with references) using Pod::Simple?
Organization: The Eyrie
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Martin Quinson <martin.quinson(a)ens-rennes.fr> writes:
I had a look at Pod::Simple to see how to convert po4a to the
modernity, but I would appreciate to have some guidance, please. For
reference, our code is here:
https://github.com/mquinson/po4a/blob/master/lib/Locale/Po4a/Pod.pm
For now, we override initialize(), command(), verbatim() and
textblock() and then call parse_from_file() on the provided file.
Pod::Simple has a very different organizational structure than Pod::Parser
and it will probably require some reworking or a compatibility layer to
adapt Pod::Parser code to it. To understand how Pod::Simple natively
thinks about passing information to you, you'll want to look at:
Pod::Simple::Subclassing
and then the three major layers over Pod::Simple:
Pod::Simple::Methody
Pod::Simple::PullParser
Pod::Simple::SimpleTree
which gives you method callbacks, a token stream, and a tree respectively.
I have to admit that when converting Pod::Man and Pod::Text, I ended up
writing my own layer to call into the structure that I was already using
with Pod::Parser. A similar approach may work for you since you're coming
from a Pod::Parser world. Take a look at the code that starts here:
https://github.com/rra/podlators/blob/master/lib/Pod/Text.pm#L149
It's fairly short.
Second question: How do you retrieve the line number in the original
text in your parsers? Will I have the same issue with the reported
line numbers ignoring the cut parts of the file?
It depends on the interface that you use, but in general you'll get a
reference to an attrs hash passed into your code, and the start_line
element of that hash is the line number. I suspect the line numbers will
be more accurate, although I haven't tested this myself.
Third question: Is it possible to get some information from the
external
blocks? (the parts that are not POD in the file) I would like to "see"
the comments added to these parts, searching for specific comments that
are intended for the translators. This is to implement something similar
to --add-command of xgettext.
Yes, call the code_handler() method and pass it a callback. That callback
will be called for each non-POD block in the source file, and can then do
what it wants with them.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{
> 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.),
01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
----- End forwarded message -----
--
Reject: The reference on the SimGrid toolkit is outdated.
-- Bastard Reviewer From Hell