| 1 | package Decl::Semantics::POD; | ||||||||||
| 2 | |||||||||||
| 3 | 13 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 13 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 13 | ▶ | use base qw(Decl::Node); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =head1 NAME | ||||||||||
| 9 | |||||||||||
| 10 | Decl::Semantics::POD - implements POD documentation in a declarative framework. | ||||||||||
| 11 | |||||||||||
| 12 | =head1 VERSION | ||||||||||
| 13 | |||||||||||
| 14 | Version 0.02 | ||||||||||
| 15 | |||||||||||
| 16 | =cut | ||||||||||
| 17 | |||||||||||
| 18 | 13 | our $VERSION = '0.02'; | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | =head1 SYNOPSIS | ||||||||||
| 22 | |||||||||||
| 23 | Obviously, POD documentation doesn't *do* anything, but we'll be able to scan the tree for POD documentation and get it all out in sequence. | ||||||||||
| 24 | The main benefit from the POD module is to permit convenient indentation for POD code, like this: | ||||||||||
| 25 | |||||||||||
| 26 | pod head2 "Explanatory title" | ||||||||||
| 27 | This function will do all kinds of neat stuff | ||||||||||
| 28 | and here's an example of how to use it: | ||||||||||
| 29 | |||||||||||
| 30 | (code POD will see as indented) | ||||||||||
| 31 | |||||||||||
| 32 | And then we finish our explanation. | ||||||||||
| 33 | |||||||||||
| 34 | do { some code } | ||||||||||
| 35 | |||||||||||
| 36 | The text that POD sees will automatically have =head2 and =cut added to the start and end, and will be de-indented to the lowest indentation level | ||||||||||
| 37 | in the text defined as POD. | ||||||||||
| 38 | |||||||||||
| 39 | =head2 defines(), tags_defined() | ||||||||||
| 40 | |||||||||||
| 41 | Called by Decl::Semantics during import, to find out what xmlapi tags this plugin claims to implement. | ||||||||||
| 42 | The asterisk means indented lines will all be put into the body of this tag even if not surrounded by curly braces. | ||||||||||
| 43 | |||||||||||
| 44 | =cut | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub defines { ('pod'); } | ||||||||
|
Subroutine
defines: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 47 | 0 | ▶ | our %build_handlers = ( pod => { node => sub { Decl::Semantics::POD->new (@_) }, body => 'none' } ); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 48 | 12 | ▶ | sub tags_defined { Decl->new_data(<<EOF); } | ||||||||
|
Subroutine
tags_defined: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 49 | pod (body=text) | ||||||||||
| 50 | EOF | ||||||||||
| 51 | |||||||||||
| 52 | =head2 extract | ||||||||||
| 53 | |||||||||||
| 54 | This is the only POD-specific function provided; it extracts the POD documentation. If we do a C<search_first ('pod')> on the root of the tree, | ||||||||||
| 55 | we can get a sequential list of all POD nodes, so C<join "\n\n", map { $_->extract() } search_first ('pod')> gives us the POD for the whole tree. | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | 1 | ▶ | sub extract { | ||||||||
|
Subroutine
extract: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 60 | 1 | my $self = shift; | |||||||||
| 61 | 1 | my $ret = ''; | |||||||||
| 62 | |||||||||||
| 63 | 1 | ▶ | if ($self->name) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 1 | $ret .= "=" . $self->name . " " . $self->label . "\n\n"; | |||||||||
| 65 | } | ||||||||||
| 66 | 1 | $ret .= $self->body; | |||||||||
| 67 | 1 | $ret .= "\n=cut\n"; | |||||||||
| 68 | 1 | return $ret; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | =head1 AUTHOR | ||||||||||
| 72 | |||||||||||
| 73 | Michael Roberts, C<< <michael at vivtek.com> >> | ||||||||||
| 74 | |||||||||||
| 75 | =head1 BUGS | ||||||||||
| 76 | |||||||||||
| 77 | Please report any bugs or feature requests to C<bug-decl at rt.cpan.org>, or through | ||||||||||
| 78 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Decl>. I will be notified, and then you'll | ||||||||||
| 79 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 80 | |||||||||||
| 81 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 82 | |||||||||||
| 83 | Copyright 2010 Michael Roberts. | ||||||||||
| 84 | |||||||||||
| 85 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 86 | under the terms of either: the GNU General Public License as published | ||||||||||
| 87 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 88 | |||||||||||
| 89 | See http://dev.perl.org/licenses/ for more information. | ||||||||||
| 90 | |||||||||||
| 91 | =cut | ||||||||||
| 92 | |||||||||||
| 93 | 13 | 1; # End of Decl::Semantics::POD | |||||||||