| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution OODoc version 3.05. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.05. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2003-2025 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package OODoc::Format::Pod3;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '3.05'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1851
|
use parent 'OODoc::Format::Pod'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
13
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
103
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
109
|
|
|
20
|
1
|
|
|
1
|
|
7
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
37
|
use Log::Report 'oodoc'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
13
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
459
|
use OODoc::Template (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
25
|
1
|
|
|
1
|
|
9
|
use List::Util qw/first/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
112
|
|
|
26
|
1
|
|
|
1
|
|
8
|
use Encode qw/decode/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
2223
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#-------------------- |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init($) |
|
31
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
|
32
|
0
|
|
0
|
|
|
|
$args->{format} //= 'pod3'; |
|
33
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#-------------------- |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $default_template; |
|
39
|
|
|
|
|
|
|
{ local $/; |
|
40
|
|
|
|
|
|
|
$default_template = ; |
|
41
|
|
|
|
|
|
|
close DATA; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub createManual(@) |
|
45
|
0
|
|
|
0
|
1
|
|
{ my ($self, %args) = @_; |
|
46
|
0
|
|
0
|
|
|
|
$self->{OFP_template} = delete $args{template} || \$default_template; |
|
47
|
0
|
|
|
|
|
|
$self->SUPER::createManual(%args); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _formatManual(@) |
|
51
|
0
|
|
|
0
|
|
|
{ my ($self, %args) = @_; |
|
52
|
0
|
|
|
|
|
|
my $output = delete $args{output}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $template = OODoc::Template->new( |
|
55
|
|
|
|
|
|
|
markers => [ '<{', '}>' ], |
|
56
|
|
|
|
|
|
|
manual_obj => delete $args{manual}, |
|
57
|
0
|
|
|
|
|
|
chapter_order => [ qw/ |
|
58
|
|
|
|
|
|
|
NAME INHERITANCE SYNOPSIS DESCRIPTION OVERLOADED METHODS |
|
59
|
|
|
|
|
|
|
FUNCTIONS CONSTANTS EXPORTS DIAGNOSTICS DETAILS REFERENCES |
|
60
|
|
|
|
|
|
|
COPYRIGHTS |
|
61
|
|
|
|
|
|
|
/ ], |
|
62
|
|
|
|
|
|
|
%args, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$output->print(scalar $template->process( |
|
66
|
|
|
|
|
|
|
$self->{OFP_template}, |
|
67
|
0
|
|
|
0
|
|
|
manual => sub { shift; ( {}, @_ ) }, |
|
|
0
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
|
|
chapters => sub { $self->chapters($template, @_) }, |
|
69
|
0
|
|
|
0
|
|
|
sections => sub { $self->sections($template, @_) }, |
|
70
|
0
|
|
|
0
|
|
|
subsections => sub { $self->subsections($template, @_) }, |
|
71
|
0
|
|
|
0
|
|
|
subsubsections => sub { $self->subsubsections($template, @_) }, |
|
72
|
0
|
|
|
0
|
|
|
subroutines => sub { $self->subroutines($template, @_) }, |
|
73
|
0
|
|
|
0
|
|
|
diagnostics => sub { $self->diagnostics($template, @_) }, |
|
74
|
0
|
|
|
|
|
|
)); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub structure($$$) |
|
78
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $type, $object) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $manual = $template->valueFor('manual_obj'); |
|
81
|
0
|
|
|
|
|
|
my $descr = $self->cleanup($manual, $object->description); |
|
82
|
0
|
|
|
|
|
|
my $name = $object->name; |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
0
|
|
|
|
$descr =~ s/\n*$/\n\n/ |
|
85
|
|
|
|
|
|
|
if defined $descr && length $descr; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @examples; |
|
88
|
0
|
|
|
|
|
|
foreach my $example ($object->examples) |
|
89
|
0
|
|
0
|
|
|
|
{ my $title = $example->name || 'Example'; |
|
90
|
0
|
0
|
|
|
|
|
$title = "Example: $example" if $title !~ /example/i; |
|
91
|
0
|
|
|
|
|
|
$title =~ s/\s+$//; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
push @examples, +{ |
|
94
|
|
|
|
|
|
|
title => $title, |
|
95
|
|
|
|
|
|
|
descr => $self->cleanup($manual, $example->description) |
|
96
|
|
|
|
|
|
|
}; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my @extends; |
|
100
|
0
|
0
|
0
|
|
|
|
@extends = map +{manual => $_->manual, header => $name}, $object->extends |
|
101
|
|
|
|
|
|
|
if $name ne 'NAME' && $name ne 'SYNOPSIS'; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
+{ $type => $name, |
|
104
|
|
|
|
|
|
|
$type.'_obj' => $object, |
|
105
|
|
|
|
|
|
|
description => $descr, |
|
106
|
|
|
|
|
|
|
examples => \@examples, |
|
107
|
|
|
|
|
|
|
extends => \@extends, |
|
108
|
|
|
|
|
|
|
}; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub chapters($$$$$) |
|
112
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
113
|
0
|
|
|
|
|
|
my $manual = $template->valueFor('manual_obj'); |
|
114
|
0
|
|
|
|
|
|
my @chapters = map $self->structure($template, chapter => $_), $manual->chapters; |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
if(my $order = $attrs->{order}) |
|
117
|
0
|
0
|
|
|
|
|
{ my @order = ref $order eq 'ARRAY' ? @$order : split( /\,\s*/, $order); |
|
118
|
0
|
|
|
|
|
|
my %order; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# first the pre-defined names, then the other |
|
121
|
0
|
|
|
|
|
|
my $count = 1; |
|
122
|
0
|
|
|
|
|
|
$order{$_} = $count++ for @order; |
|
123
|
0
|
|
0
|
|
|
|
$order{$_->{chapter}} ||= $count++ for @chapters; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
@chapters = sort { $order{$a->{chapter}} <=> $order{$b->{chapter}} } @chapters; |
|
|
0
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
( \@chapters, $attrs, $then, $else ); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub sections($$$$$) |
|
132
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
133
|
0
|
|
|
|
|
|
my $chapter = $template->valueFor('chapter_obj'); |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
0
|
|
|
first {!$_->isEmpty} $chapter->sections |
|
|
0
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
or return ([], $attrs, $then, $else); |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my @sections = map $self->structure($template, section => $_), $chapter->sections; |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
( \@sections, $attrs, $then, $else ); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub subsections($$$$$) |
|
144
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
145
|
0
|
|
|
|
|
|
my $section = $template->valueFor('section_obj'); |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
0
|
|
0
|
|
|
first {!$_->isEmpty} $section->subsections |
|
|
0
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
or return ([], $attrs, $then, $else); |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my @subsections = map $self->structure($template, subsection => $_), $section->subsections; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
( \@subsections, $attrs, $then, $else ); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub subsubsections($$$$$) |
|
156
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
157
|
0
|
|
|
|
|
|
my $subsection = $template->valueFor('subsection_obj'); |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
0
|
|
0
|
|
|
first {!$_->isEmpty} $subsection->subsubsections |
|
|
0
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
or return ([], $attrs, $then, $else); |
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my @subsubsections = map $self->structure($template, subsubsection => $_), $subsection->subsubsections; |
|
163
|
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
( \@subsubsections, $attrs, $then, $else ); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub subroutines($$$$$$) |
|
168
|
0
|
|
|
0
|
1
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
0
|
|
|
|
my $parent |
|
171
|
|
|
|
|
|
|
= $template->valueFor('subsubsection_obj') |
|
172
|
|
|
|
|
|
|
|| $template->valueFor('subsection_obj') |
|
173
|
|
|
|
|
|
|
|| $template->valueFor('section_obj') |
|
174
|
|
|
|
|
|
|
|| $template->valueFor('chapter_obj'); |
|
175
|
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
defined $parent |
|
177
|
|
|
|
|
|
|
or return (); |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my $out = ''; |
|
180
|
0
|
|
|
|
|
|
open my $fh, '>:encoding(utf8)', \$out; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
my @show = map +($_ => scalar $template->valueFor($_)), qw/ |
|
183
|
|
|
|
|
|
|
show_described_options show_described_subs show_diagnostics |
|
184
|
|
|
|
|
|
|
show_examples show_inherited_options show_inherited_subs |
|
185
|
|
|
|
|
|
|
show_option_table show_subs_index |
|
186
|
|
|
|
|
|
|
/; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# This is quite weak: the whole POD section for a sub description |
|
189
|
|
|
|
|
|
|
# is produced outside the template. In the future, this may get |
|
190
|
|
|
|
|
|
|
# changed: if there is a need for it: of course, we can do everything |
|
191
|
|
|
|
|
|
|
# in the template system. |
|
192
|
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
$self->showSubroutines( |
|
194
|
|
|
|
|
|
|
subroutines => [ $parent->subroutines ], |
|
195
|
|
|
|
|
|
|
manual => $parent->manual, |
|
196
|
|
|
|
|
|
|
output => $fh, |
|
197
|
|
|
|
|
|
|
@show, |
|
198
|
|
|
|
|
|
|
); |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
$fh->close; |
|
201
|
0
|
0
|
|
|
|
|
length $out or return (); |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
|
$out =~ s/\n*$/\n\n/; |
|
204
|
0
|
|
|
|
|
|
decode 'UTF-8', $out; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub diagnostics($$$$$$) |
|
208
|
0
|
|
|
0
|
0
|
|
{ my ($self, $template, $tag, $attrs, $then, $else) = @_; |
|
209
|
0
|
|
|
|
|
|
my $manual = $template->valueFor('manual_obj'); |
|
210
|
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
my $out = ''; |
|
212
|
0
|
|
|
|
|
|
open my $fh, '>:encoding(utf8)', \$out; |
|
213
|
0
|
|
|
|
|
|
$self->chapterDiagnostics(%$attrs, manual => $manual, output => $fh); |
|
214
|
0
|
|
|
|
|
|
$fh->close; |
|
215
|
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
$out =~ s/\n*$/\n\n/; |
|
217
|
0
|
|
|
|
|
|
decode 'UTF-8', $out; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
1; |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
__DATA__ |