| 1 | ## | ||||||||||||||||||||
| 2 | # name: Stardoc::Document::Pod | ||||||||||||||||||||
| 3 | # abstract: Stardoc Pod Generator | ||||||||||||||||||||
| 4 | # author: Ingy döt Net <ingy@cpan.org> | ||||||||||||||||||||
| 5 | # copyright: 2011 | ||||||||||||||||||||
| 6 | # license: perl | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | package Stardoc::Document::Pod; | ||||||||||||||||||||
| 9 | 1 | ▶ | use Mouse; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | ▶ | use Template::Toolkit::Simple; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use IO::All; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | has module => ( | |||||||||||||||||||
| 15 | is => 'ro', | ||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 1 | my $layout = [ | |||||||||||||||||||
| 19 | {name => 'encoding', requires => ['encoding']}, | ||||||||||||||||||||
| 20 | {name => 'name', requires => ['name', 'abstract']}, | ||||||||||||||||||||
| 21 | 'synopsis', | ||||||||||||||||||||
| 22 | 'description', | ||||||||||||||||||||
| 23 | 'other', | ||||||||||||||||||||
| 24 | {name => 'see', requires => ['see']}, | ||||||||||||||||||||
| 25 | {name => 'author', requires => ['author']}, | ||||||||||||||||||||
| 26 | {name => 'license', requires => ['copyright']}, | ||||||||||||||||||||
| 27 | {name => 'cut'}, | ||||||||||||||||||||
| 28 | ]; | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | ▶ | sub format { | ||||||||||||||||||
|
Subroutine
format: called CC=14 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||
| 31 | 2 | my ($self) = @_; | |||||||||||||||||||
| 32 | 2 | my $module = $self->module; | |||||||||||||||||||
| 33 | 2 | my $data = $module->meta; | |||||||||||||||||||
| 34 | 2 | my $pod = ''; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | OUTER: | ||||||||||||||||||||
| 37 | 2 | for my $entry (@$layout) { | |||||||||||||||||||
| 38 | 18 | ▶ | my $name = ref($entry) ? $entry->{name} : $entry; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 18 | ▶ | if ($name eq 'other') { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 40 | 2 | for my $section (@{$module->other}) { | |||||||||||||||||||
| 41 | 2 | ▶ | $pod .= "\n" if $pod; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 2 | $pod .= $section->{text}; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | ▶ | elsif ($module->can($name) and $module->$name) { | |||||||||||||||||||
|
Condition100%3/3
$module->can($name) and $module->$name
MC/DC100%2/2
$module->can($name) and $module->$name
$module->can($name)
$module->$name
Truth table100%3/3
A and B
A= $module->can($name)B= $module->$name
| |||||||||||||||||||||
| 46 | 4 | ▶ | $pod .= "\n" if $pod; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 4 | $pod .= $module->$name->{text}; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | elsif (ref $entry) { | ||||||||||||||||||||
| 50 | 12 | ▶ | my $requires = $entry->{requires} || []; | ||||||||||||||||||
|
Condition100%2/2
$entry->{'requires'} || []
MC/DC100%1/1
$entry->{'requires'} || []
$entry->{'requires'}
Truth table100%2/2
A
A= $entry->{'requires'}
| |||||||||||||||||||||
| 51 | 12 | ▶ | $data->{$_} or next OUTER for @$requires; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 11 | ▶ | $pod .= "\n" if $pod; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 11 | $pod .= $self->format_template($name, $data); | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 2 | return $pod; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 11 | ▶ | sub format_template { | ||||||||||||||||||
|
Subroutine
format_template: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||
| 60 | 11 | my ($self, $name, $data) = @_; | |||||||||||||||||||
| 61 | 11 | ▶ | my $template = eval { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 11 | Stardoc::Pod::Templates->$name; | |||||||||||||||||||
| 63 | } or next; | ||||||||||||||||||||
| 64 | 11 | tt->render(\$template, $data); | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | ▶ | sub format_section { | ||||||||||||||||||
|
Subroutine
format_section: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | package Stardoc::Pod::Templates; | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 1 | ▶ | use constant name => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | =head1 NAME | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | [% name %] - [% abstract %] | ||||||||||||||||||||
| 76 | ... | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 1 | ▶ | use constant status => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 79 | =head1 STATUS | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | [% status %] | ||||||||||||||||||||
| 82 | ... | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 1 | ▶ | use constant encoding => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 85 | =encoding [% encoding %] | ||||||||||||||||||||
| 86 | ... | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 1 | ▶ | use constant see => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 89 | =head1 SEE ALSO | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =over | ||||||||||||||||||||
| 92 | [% FOR also = see %] | ||||||||||||||||||||
| 93 | =item * | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | L<[% also %]> | ||||||||||||||||||||
| 96 | [% END %] | ||||||||||||||||||||
| 97 | =back | ||||||||||||||||||||
| 98 | ... | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 1 | ▶ | use constant author => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 101 | =head1 AUTHOR | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | [% author.0.name %][% IF author.0.email %] <[% author.0.email %]>[% END %] | ||||||||||||||||||||
| 104 | ... | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 1 | ▶ | use constant license => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 107 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | Copyright (c) [% copyright %]. [% author.0.name %]. | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 112 | under the same terms as Perl itself. | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | See http://www.perl.com/perl/misc/Artistic.html | ||||||||||||||||||||
| 115 | ... | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 1 | ▶ | use constant cut => <<'...'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||
| 119 | ... | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 1 | 1; | |||||||||||||||||||