line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Meta::Role::Class::Documentation; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
8891
|
use utf8; |
|
15
|
|
|
|
|
130
|
|
|
15
|
|
|
|
|
110
|
|
6
|
15
|
|
|
15
|
|
701
|
use 5.010; |
|
15
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
96
|
use namespace::autoclean; |
|
15
|
|
|
|
|
41
|
|
|
15
|
|
|
|
|
92
|
|
9
|
15
|
|
|
15
|
|
1149
|
use Moose::Role; |
|
15
|
|
|
|
|
73
|
|
|
15
|
|
|
|
|
109
|
|
10
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
|
87342
|
use Pod::Elemental; |
|
15
|
|
|
|
|
9349462
|
|
|
15
|
|
|
|
|
144
|
|
12
|
15
|
|
|
15
|
|
6629
|
use Pod::Elemental::Selectors qw(); |
|
15
|
|
|
|
|
41
|
|
|
15
|
|
|
|
|
333
|
|
13
|
15
|
|
|
15
|
|
90
|
use Pod::Elemental::Transformer::Pod5; |
|
15
|
|
|
|
|
105
|
|
|
15
|
|
|
|
|
392
|
|
14
|
15
|
|
|
15
|
|
9216
|
use Pod::Elemental::Transformer::Nester; |
|
15
|
|
|
|
|
1647262
|
|
|
15
|
|
|
|
|
9825
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'command_short_description' => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
19
|
|
|
|
|
|
|
lazy => 1, |
20
|
|
|
|
|
|
|
builder => '_build_command_short_description', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'command_long_description' => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
builder => '_build_command_long_description', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'command_usage' => ( |
31
|
|
|
|
|
|
|
is => 'rw', |
32
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
builder => '_build_command_usage', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'command_strict' => ( |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => 'Bool', |
40
|
|
|
|
|
|
|
default => sub {0}, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub command_short_description_predicate { |
44
|
23
|
|
|
23
|
1
|
77
|
my ($self) = @_; |
45
|
23
|
|
|
|
|
63
|
return $self->_command_pod_predicate('command_short_description'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_command_short_description { |
49
|
9
|
|
|
9
|
|
26
|
my ($self) = @_; |
50
|
9
|
|
|
|
|
45
|
my %pod = $self->_build_command_pod(); |
51
|
|
|
|
|
|
|
return $pod{'command_short_description'} |
52
|
9
|
100
|
|
|
|
152
|
if defined $pod{'command_short_description'}; |
53
|
6
|
|
|
|
|
246
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub command_long_description_predicate { |
57
|
36
|
|
|
36
|
1
|
126
|
my ($self) = @_; |
58
|
36
|
|
|
|
|
136
|
return $self->_command_pod_predicate('command_long_description'); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _build_command_long_description { |
62
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
63
|
0
|
|
|
|
|
0
|
my %pod = $self->_build_command_pod(); |
64
|
|
|
|
|
|
|
return $pod{'command_long_description'} |
65
|
0
|
0
|
|
|
|
0
|
if defined $pod{'command_long_description'}; |
66
|
0
|
|
|
|
|
0
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub command_usage_predicate { |
70
|
35
|
|
|
35
|
1
|
130
|
my ($self) = @_; |
71
|
35
|
|
|
|
|
246
|
return $self->_command_pod_predicate('command_usage'); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _build_command_usage { |
75
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
76
|
0
|
|
|
|
|
0
|
my %pod = $self->_build_command_pod(); |
77
|
|
|
|
|
|
|
return $pod{'command_usage'} |
78
|
0
|
0
|
|
|
|
0
|
if defined $pod{'command_usage'}; |
79
|
0
|
|
|
|
|
0
|
return; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _command_pod_predicate { |
83
|
94
|
|
|
94
|
|
255
|
my ($self,$field) = @_; |
84
|
|
|
|
|
|
|
|
85
|
94
|
|
|
|
|
381
|
my $attribute = $self->meta->find_attribute_by_name($field); |
86
|
|
|
|
|
|
|
|
87
|
94
|
100
|
|
|
|
7298
|
unless ($attribute->has_value($self)) { |
88
|
14
|
|
|
|
|
732
|
$self->_build_command_pod($field); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
94
|
|
|
|
|
2757
|
my $value = $attribute->get_value($self); |
92
|
|
|
|
|
|
|
|
93
|
94
|
100
|
66
|
|
|
15046
|
return (defined $value && $value ? 1:0); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_command_pod { |
98
|
23
|
|
|
23
|
|
80
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
|
100
|
23
|
|
|
|
|
202
|
my %pod_raw = MooseX::App::Utils::parse_pod($self->name); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my %pod = ( |
103
|
|
|
|
|
|
|
command_usage => ($pod_raw{SYNOPSIS} || $pod_raw{USAGE}), |
104
|
|
|
|
|
|
|
command_long_description => ($pod_raw{DESCRIPTION} || $pod_raw{OVERVIEW}), |
105
|
23
|
|
66
|
|
|
3689
|
command_short_description => ($pod_raw{NAME} || $pod_raw{ABSTRACT}), |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Loop sections that need to be extracted from POD |
109
|
23
|
|
|
|
|
110
|
foreach my $key (keys %pod) { |
110
|
69
|
|
|
|
|
1442
|
my $meta_attribute = $self->meta->find_attribute_by_name($key); |
111
|
|
|
|
|
|
|
next |
112
|
69
|
50
|
|
|
|
4216
|
unless defined $meta_attribute; |
113
|
|
|
|
|
|
|
next |
114
|
69
|
100
|
|
|
|
212
|
if $meta_attribute->has_value($self); |
115
|
61
|
|
|
|
|
1805
|
$meta_attribute->set_raw_value($self,$pod{$key}); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
23
|
|
|
|
|
630
|
return %pod; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#{ |
122
|
|
|
|
|
|
|
# package Moose::Meta::Class::Custom::Trait::AppCommand; |
123
|
|
|
|
|
|
|
# sub register_implementation { return 'MooseX::App::Meta::Role::Class::Documentation' } |
124
|
|
|
|
|
|
|
#} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
__END__ |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=pod |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=encoding utf8 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NAME |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
MooseX::App::Meta::Role::Class::Documentation - Meta class role for command classes |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 DESCRIPTION |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This meta class role will automatically be applied to all command classes. |
141
|
|
|
|
|
|
|
This documentation is only of interest if you intend to write plugins for |
142
|
|
|
|
|
|
|
MooseX::App. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ACCESSORS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 command_short_description |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Read/set the short command description. Will be extracted from the Pod NAME |
149
|
|
|
|
|
|
|
or ABSTRACT section if not set. Alternative this will be taken from the |
150
|
|
|
|
|
|
|
DistZilla ABSTRACT tag. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 command_long_description |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Read/set the long command description. Will be extracted from the Pod |
155
|
|
|
|
|
|
|
DESCRIPTION or OVERVIEW section if not set. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 command_usage |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Read/set the long command usage. Will be extracted from the Pod |
160
|
|
|
|
|
|
|
SYNOPSIS or USAGE section if not set. If these Pod sections are not defined |
161
|
|
|
|
|
|
|
the usage will be autogenerated. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 command_short_description_predicate |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Checks if command_short_description is available |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 command_long_description_predicate |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Checks if command_long_description is available |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 command_usage_predicate |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Checks if command_usage is available |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 command_strict |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Read/set the strict command flag. If strict is enabled the command will |
178
|
|
|
|
|
|
|
terminate with an error message if superfluous/unknown positional parameters |
179
|
|
|
|
|
|
|
are supplied. If disabled all extra parameters will be copied to the |
180
|
|
|
|
|
|
|
L<extra_argv> attribute. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
The app_strict function in the app classes allows one to set this option |
183
|
|
|
|
|
|
|
globally. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 METHODS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 _build_command_pod |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Parses the Pod from the command class. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |