line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perinci::To::PackageBase; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
668
|
use 5.010; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
445
|
use Data::Dump::OneLine qw(dump1); |
|
1
|
|
|
|
|
2789
|
|
|
1
|
|
|
|
|
55
|
|
5
|
1
|
|
|
1
|
|
7
|
use Log::ger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
219
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
395
|
use Perinci::Object; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
968
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Perinci::To::Doc::Role::Section'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has name => (is=>'rw'); |
12
|
|
|
|
|
|
|
has meta => (is=>'rw'); |
13
|
|
|
|
|
|
|
has url => (is=>'rw'); |
14
|
|
|
|
|
|
|
has child_metas => (is=>'rw'); |
15
|
|
|
|
|
|
|
has _pa => (is=>'rw'); |
16
|
|
|
|
|
|
|
has exports => (is=>'rw'); # hash, key=function name, val=0|1|2 (see Perinci::Sub::To::FuncBase's export) |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
19
|
|
|
|
|
|
|
our $DATE = '2022-10-15'; # DATE |
20
|
|
|
|
|
|
|
our $DIST = 'Perinci-To-Doc'; # DIST |
21
|
|
|
|
|
|
|
our $VERSION = '0.880'; # VERSION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub BUILD { |
24
|
1
|
|
|
1
|
0
|
24
|
my ($self, $args) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
5
|
$args->{meta} or die "Please specify meta"; |
27
|
1
|
50
|
|
|
|
4
|
$args->{child_metas} or die "Please specify child_metas"; |
28
|
|
|
|
|
|
|
$self->{doc_sections} //= [ |
29
|
1
|
|
50
|
|
|
12
|
'summary', |
30
|
|
|
|
|
|
|
'version', |
31
|
|
|
|
|
|
|
'description', |
32
|
|
|
|
|
|
|
'functions', |
33
|
|
|
|
|
|
|
'methods', |
34
|
|
|
|
|
|
|
'links', |
35
|
|
|
|
|
|
|
]; |
36
|
1
|
|
33
|
|
|
7
|
$self->{_pa} //= do { |
37
|
1
|
|
|
|
|
1022
|
require Perinci::Access; |
38
|
1
|
|
|
|
|
1260
|
Perinci::Access->new; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub before_gen_doc { |
43
|
0
|
|
|
0
|
0
|
|
my ($self, %opts) = @_; |
44
|
0
|
|
|
|
|
|
log_trace("=> PackageBase's before_gen_doc(opts=%s)", \%opts); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# initialize hash to store [intermediate] result |
47
|
0
|
|
|
|
|
|
$self->{_doc_res} = {}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# provide simple default implementation without any text wrapping. subclass such |
51
|
|
|
|
|
|
|
# as Perinci::To::Text will use another implementation, one that supports text |
52
|
|
|
|
|
|
|
# wrapping for example (provided by |
53
|
|
|
|
|
|
|
# Perinci::To::Doc::Role::Section::AddTextLines). |
54
|
|
|
|
|
|
|
sub add_doc_lines { |
55
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
56
|
0
|
|
|
|
|
|
my $opts; |
57
|
0
|
0
|
|
|
|
|
if (ref($_[0]) eq 'HASH') { $opts = shift } |
|
0
|
|
|
|
|
|
|
58
|
0
|
|
0
|
|
|
|
$opts //= {}; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
my @lines = map { $_ . (/\n\z/s ? "" : "\n") } |
61
|
0
|
0
|
|
|
|
|
map {/\n/ ? split /\n/ : $_} @_; |
|
0
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $indent = $self->doc_indent_str x $self->doc_indent_level; |
64
|
0
|
|
|
|
|
|
push @{$self->doc_lines}, |
65
|
0
|
|
|
|
|
|
map {"$indent$_"} @lines; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub gen_doc_section_summary { |
69
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $rimeta = rimeta($self->meta); |
72
|
0
|
|
|
|
|
|
my $dres = $self->{_doc_res}; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
0
|
|
|
|
my $name = $self->name // $rimeta->langprop("name") // "UnnamedModule"; |
|
|
|
0
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $summary = $rimeta->langprop("summary"); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$dres->{name} = $name; |
78
|
0
|
|
|
|
|
|
$dres->{summary} = $summary; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
0
|
0
|
|
sub gen_doc_section_version { |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub gen_doc_section_description { |
85
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $rimeta = rimeta($self->meta); |
88
|
0
|
|
|
|
|
|
my $dres = $self->{_doc_res}; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$dres->{description} = $rimeta->langprop("description"); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub gen_doc_section_functions { |
94
|
0
|
|
|
0
|
0
|
|
require Perinci::Sub::To::FuncBase; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
my $cmetas = $self->child_metas; |
99
|
0
|
|
|
|
|
|
my $dres = $self->{_doc_res}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# list all functions |
102
|
0
|
|
|
|
|
|
my @func_uris = grep {m!(\A|/)\w+\z!} sort keys %$cmetas; |
|
0
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# generate doc for all functions |
105
|
0
|
|
|
|
|
|
$dres->{functions} = {}; |
106
|
0
|
|
|
|
|
|
$dres->{function_names_by_meta_addr} = {}; |
107
|
0
|
|
|
|
|
|
for my $furi (@func_uris) { |
108
|
0
|
|
|
|
|
|
my $fname = $furi; $fname =~ s!.+/!!; |
|
0
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
my $meta = $cmetas->{$furi}; |
110
|
0
|
0
|
0
|
|
|
|
next if $meta->{'x.no_index'} || grep { $_ eq 'hidden' } @{ $meta->{tags} // [] }; |
|
0
|
|
0
|
|
|
|
|
|
0
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
push @{ $dres->{function_names_by_meta_addr}{"$meta"} }, $fname; |
|
0
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$dres->{functions}{$furi} = |
113
|
|
|
|
|
|
|
$self->_gen_func_doc( |
114
|
|
|
|
|
|
|
parent=>$self, |
115
|
|
|
|
|
|
|
name=>$fname, |
116
|
|
|
|
|
|
|
meta=>$meta, |
117
|
0
|
|
0
|
|
|
|
url=> ($self->{url}//'') . $furi, |
118
|
|
|
|
|
|
|
); |
119
|
0
|
|
|
|
|
|
$dres->{function_metas}{$furi} = $meta; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
0
|
0
|
|
sub gen_doc_section_methods { |
124
|
|
|
|
|
|
|
# already done by gen_doc_section_functions |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
0
|
0
|
|
sub gen_doc_section_links { |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
# ABSTRACT: Base class for Perinci::To::* package documentation generators |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=pod |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=encoding UTF-8 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 NAME |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Perinci::To::PackageBase - Base class for Perinci::To::* package documentation generators |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 VERSION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This document describes version 0.880 of Perinci::To::PackageBase (from Perl distribution Perinci-To-Doc), released on 2022-10-15. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=for Pod::Coverage .+ |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 HOMEPAGE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Perinci-To-Doc>. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SOURCE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Perinci-To-Doc>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
165
|
|
|
|
|
|
|
GitHub. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
168
|
|
|
|
|
|
|
simply modify the code, then test via: |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
% prove -l |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
173
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
174
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
175
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
176
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
177
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This software is copyright (c) 2022, 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013 by perlancar <perlancar@cpan.org>. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
184
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 BUGS |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-To-Doc> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
191
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
192
|
|
|
|
|
|
|
feature. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |