line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package MooseX::App::Meta::Role::Class::Documentation; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
|
|
|
|
|
|
|
5
|
15
|
|
|
15
|
|
10716
|
use utf8; |
|
15
|
|
|
|
|
150
|
|
|
15
|
|
|
|
|
122
|
|
6
|
15
|
|
|
15
|
|
756
|
use 5.010; |
|
15
|
|
|
|
|
56
|
|
7
|
|
|
|
|
|
|
|
8
|
15
|
|
|
15
|
|
92
|
use namespace::autoclean; |
|
15
|
|
|
|
|
45
|
|
|
15
|
|
|
|
|
109
|
|
9
|
15
|
|
|
15
|
|
1252
|
use Moose::Role; |
|
15
|
|
|
|
|
96
|
|
|
15
|
|
|
|
|
116
|
|
10
|
|
|
|
|
|
|
|
11
|
15
|
|
|
15
|
|
95695
|
use Pod::Elemental; |
|
15
|
|
|
|
|
9945202
|
|
|
15
|
|
|
|
|
156
|
|
12
|
15
|
|
|
15
|
|
6747
|
use Pod::Elemental::Selectors qw(); |
|
15
|
|
|
|
|
42
|
|
|
15
|
|
|
|
|
379
|
|
13
|
15
|
|
|
15
|
|
99
|
use Pod::Elemental::Transformer::Pod5; |
|
15
|
|
|
|
|
103
|
|
|
15
|
|
|
|
|
413
|
|
14
|
15
|
|
|
15
|
|
9974
|
use Pod::Elemental::Transformer::Nester; |
|
15
|
|
|
|
|
1727303
|
|
|
15
|
|
|
|
|
10577
|
|
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
|
75
|
my ($self) = @_; |
45
|
23
|
|
|
|
|
90
|
return $self->_command_pod_predicate('command_short_description'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _build_command_short_description { |
49
|
9
|
|
|
9
|
|
22
|
my ($self) = @_; |
50
|
9
|
|
|
|
|
43
|
my %pod = $self->_build_command_pod(); |
51
|
|
|
|
|
|
|
return $pod{'command_short_description'} |
52
|
9
|
100
|
|
|
|
160
|
if defined $pod{'command_short_description'}; |
53
|
6
|
|
|
|
|
245
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub command_long_description_predicate { |
57
|
36
|
|
|
36
|
1
|
115
|
my ($self) = @_; |
58
|
36
|
|
|
|
|
142
|
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
|
192
|
my ($self) = @_; |
71
|
35
|
|
|
|
|
243
|
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
|
|
270
|
my ($self,$field) = @_; |
84
|
|
|
|
|
|
|
|
85
|
94
|
|
|
|
|
415
|
my $attribute = $self->meta->find_attribute_by_name($field); |
86
|
|
|
|
|
|
|
|
87
|
94
|
100
|
|
|
|
8138
|
unless ($attribute->has_value($self)) { |
88
|
14
|
|
|
|
|
767
|
$self->_build_command_pod($field); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
94
|
|
|
|
|
2989
|
my $value = $attribute->get_value($self); |
92
|
|
|
|
|
|
|
|
93
|
94
|
100
|
66
|
|
|
16535
|
return (defined $value && $value ? 1:0); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_command_pod { |
98
|
23
|
|
|
23
|
|
79
|
my ($self) = @_; |
99
|
|
|
|
|
|
|
|
100
|
23
|
|
|
|
|
186
|
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
|
|
|
3886
|
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
|
|
|
|
|
109
|
foreach my $key (keys %pod) { |
110
|
69
|
|
|
|
|
1503
|
my $meta_attribute = $self->meta->find_attribute_by_name($key); |
111
|
|
|
|
|
|
|
next |
112
|
69
|
50
|
|
|
|
4350
|
unless defined $meta_attribute; |
113
|
|
|
|
|
|
|
next |
114
|
69
|
100
|
|
|
|
218
|
if $meta_attribute->has_value($self); |
115
|
61
|
|
|
|
|
1940
|
$meta_attribute->set_raw_value($self,$pod{$key}); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
23
|
|
|
|
|
670
|
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 |