Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: POD from code?

by Corion (Patriarch)
on Nov 03, 2010 at 07:38 UTC ( [id://869156]=note: print w/replies, xml ) Need Help??


in reply to POD from code?

If I really want to do something like this, I do it the other way around, and create my data (not code) from POD:

my %stuff = map { /^=item * (\w+) => (.*)/ ? $1 => $2 : die "Malformed + line: $_" } grep /^=item */, split /\r?\n/, <<'=cut'; =over 4 =item * foo => ... =item * bar => ... =item * baz => ... =back =cut

Usually I find that approach to be a bit too much magic, but at least for the definition of configuration file entries, I found it helpfull as it forces me to write the documentation for every possible option together with its introduction into the program.

Replies are listed 'Best First'.
Re^2: POD from code?
by JavaFan (Canon) on Nov 03, 2010 at 10:32 UTC
Re^2: POD from code?
by LanX (Saint) on Nov 03, 2010 at 11:58 UTC
    As a side note:

    An alternative to parsing here-docs is putting the POD after __DATA__.

    This clean separation between data and code could also facilitate automatic generation of this "Pod-Data"-hybrid.

    Or even isolating it into a dedicated module, since 'Text after __DATA__ may be read via the filehandle "PACKNAME::DATA"'

    Cheers Rolf

Re^2: POD from code?
by dgaramond2 (Monk) on Nov 03, 2010 at 22:15 UTC

    Yup, that's a tiny bit on the syntax abuse side for me too.

    I don't mind doing this "manual sync" for test code (and in this case I believe this manual sync is necessary due to its very purpose). But for documentation, I'd like it to be automatic if possible. Because otherwise I'll have to test whether my documentation is up to date/complete.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://869156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-26 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found