line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# AUTHOR: Don Owens |
2
|
|
|
|
|
|
|
# AUTHOR: Jeff Fearn |
3
|
|
|
|
|
|
|
# AUTHOR: Alex Muntada |
4
|
|
|
|
|
|
|
# OWNER: 2010 Don Owens |
5
|
|
|
|
|
|
|
# OWNER: 2016 Jeff Fearn |
6
|
|
|
|
|
|
|
# OWNER: 2016-2018 Alex Muntada |
7
|
|
|
|
|
|
|
# LICENSE: Perl_5 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
126395
|
use strict; |
|
2
|
|
|
|
|
13
|
|
|
2
|
|
|
|
|
52
|
|
11
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
45
|
|
12
|
2
|
|
|
2
|
|
1079
|
use Data::Dumper (); |
|
2
|
|
|
|
|
11513
|
|
|
2
|
|
|
|
|
52
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1064
|
use Pod::POM; |
|
2
|
|
|
|
|
41584
|
|
|
2
|
|
|
|
|
137
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Pod::POM::View::Restructured; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.000001'; # VERSION |
19
|
|
|
|
|
|
|
|
20
|
2
|
|
|
2
|
|
17
|
use base 'Pod::POM::View::Text'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
954
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
2
|
|
|
2
|
1
|
88
|
my ($class, $params) = @_; |
25
|
2
|
50
|
33
|
|
|
13
|
$params = { } unless $params and UNIVERSAL::isa($params, 'HASH'); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
33
|
|
|
13
|
my $self = bless { seen_something => 0, title_set => 0, params => { } }, ref($class) || $class; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
|
|
5
|
my $callbacks = $params->{callbacks}; |
30
|
2
|
100
|
|
|
|
6
|
$callbacks = { } unless $callbacks; |
31
|
2
|
|
|
|
|
12
|
$self->{callbacks} = $callbacks; |
32
|
2
|
|
|
|
|
5
|
$self->{namespace} = delete($params->{namespace}); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
5
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub convert_file { |
38
|
1
|
|
|
1
|
1
|
559
|
my ($self, $source_file, $title, $dest_file, $callbacks) = @_; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
my $cb; |
41
|
1
|
50
|
|
|
|
4
|
if ($callbacks) { |
42
|
0
|
|
|
|
|
0
|
$cb = { %{ $self->{callbacks} }, %$callbacks }; |
|
0
|
|
|
|
|
0
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
1
|
|
|
|
|
2
|
$cb = $self->{callbacks}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
5
|
my $view = Pod::POM::View::Restructured->new({ callbacks => $cb, namespace => $self->{namespace} }); |
49
|
1
|
|
|
|
|
12
|
my $parser = Pod::POM->new; |
50
|
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
47
|
unless (-r $source_file) { |
52
|
0
|
|
|
|
|
0
|
warn "can't read source file $source_file"; |
53
|
0
|
|
|
|
|
0
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
7
|
my $pom = $parser->parse_file($source_file); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
18666
|
$view->{title_set} = 1 if defined($title); |
59
|
1
|
|
|
|
|
30
|
my $out = $pom->present($view); |
60
|
|
|
|
|
|
|
|
61
|
1
|
50
|
|
|
|
49
|
if (defined($title)) { |
62
|
0
|
|
|
|
|
0
|
$out = $self->_build_header($title, '#', 1) . "\n" . $out; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
1
|
|
|
|
|
3
|
$title = $view->{title}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
1
|
50
|
33
|
|
|
8
|
if (defined($dest_file) and $dest_file ne '') { |
69
|
0
|
|
|
|
|
0
|
my $out_fh; |
70
|
0
|
0
|
|
|
|
0
|
if (UNIVERSAL::isa($dest_file, 'GLOB')) { |
71
|
0
|
|
|
|
|
0
|
$out_fh = $dest_file; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
0
|
|
|
|
0
|
unless (open($out_fh, '>', $dest_file)) { |
75
|
0
|
|
|
|
|
0
|
warn "couldn't open output file $dest_file"; |
76
|
0
|
|
|
|
|
0
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
print $out_fh $out; |
81
|
0
|
|
|
|
|
0
|
close $out_fh; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
5
|
my $rv = { content => $out, title => $title }; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
7
|
return $rv; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub convert_files { |
90
|
0
|
|
|
0
|
1
|
0
|
my ($self, $file_spec, $index_file, $index_title, $out_dir) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
my $index_fh = $self->_get_file_handle($index_file, '>'); |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
0
|
|
|
0
|
if ($index_fh and defined($index_title) and $index_title ne '') { |
|
|
|
0
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
my $header = $self->_build_header($index_title, '#', 1); |
96
|
|
|
|
|
|
|
# my $line = '#' x length($index_title); |
97
|
|
|
|
|
|
|
# my $header = $line . "\n" . $index_title . "\n" . $line . "\n\n"; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
0
|
print $index_fh $header; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
print $index_fh "\nContents:\n\n"; |
102
|
0
|
|
|
|
|
0
|
print $index_fh ".. toctree::\n"; |
103
|
0
|
|
|
|
|
0
|
print $index_fh " :maxdepth: 1\n\n"; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
0
|
my $count = 0; |
107
|
0
|
|
|
|
|
0
|
my $toc = ''; |
108
|
0
|
|
|
|
|
0
|
foreach my $spec (@$file_spec) { |
109
|
0
|
|
|
|
|
0
|
$count++; |
110
|
|
|
|
|
|
|
my $data = $self->convert_file($spec->{source_file}, $spec->{title}, |
111
|
0
|
|
|
|
|
0
|
$spec->{dest_file}, $spec->{callbacks}); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
my $this_title = $data->{title}; |
114
|
|
|
|
|
|
|
# print STDERR Data::Dumper->Dump([ $this_title ], [ 'this_title' ]) . "\n\n"; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
0
|
|
|
0
|
unless (defined($this_title) and $this_title !~ /\A\s*\Z/) { |
117
|
0
|
|
|
|
|
0
|
$this_title = 'section_' . $count; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
my $name = $spec->{dest_file}; |
121
|
0
|
0
|
|
|
|
0
|
if (defined($name)) { |
122
|
0
|
|
|
|
|
0
|
$name =~ s/\.rst\Z//; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
else { |
125
|
0
|
|
|
|
|
0
|
($name = $this_title) =~ s/\W/_/g; |
126
|
0
|
|
|
|
|
0
|
my $dest_file = $out_dir . '/' . $name . '.rst'; |
127
|
0
|
|
|
|
|
0
|
my $out_fh; |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
0
|
unless (open($out_fh, '>', $dest_file)) { |
130
|
0
|
|
|
|
|
0
|
warn "couldn't open output file $dest_file"; |
131
|
0
|
|
|
|
|
0
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
0
|
print $out_fh $data->{content}; |
135
|
0
|
|
|
|
|
0
|
close $out_fh; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
0
|
unless ($spec->{no_toc}) { |
139
|
0
|
|
|
|
|
0
|
$toc .= ' ' . $name . "\n"; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
0
|
|
|
0
|
if ($index_fh and not $spec->{no_toc}) { |
143
|
0
|
|
|
|
|
0
|
print $index_fh " " . $name . "\n"; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
0
|
0
|
|
|
|
0
|
if ($index_fh) { |
148
|
0
|
|
|
|
|
0
|
print $index_fh "\n"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
0
|
return { toc => $toc }; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub _get_file_handle { |
155
|
0
|
|
|
0
|
|
0
|
my ($self, $file, $mode) = @_; |
156
|
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
0
|
return unless defined $file; |
158
|
|
|
|
|
|
|
|
159
|
0
|
0
|
0
|
|
|
0
|
if (ref($file) and UNIVERSAL::isa($file, 'GLOB')) { |
160
|
0
|
|
|
|
|
0
|
return $file; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
0
|
$mode = '<' unless $mode; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
my $fh; |
166
|
0
|
0
|
|
|
|
0
|
if ($file ne '') { |
167
|
0
|
0
|
|
|
|
0
|
unless (open($fh, $mode, $file)) { |
168
|
0
|
|
|
|
|
0
|
warn "couldn't open input file $file: $!"; |
169
|
0
|
|
|
|
|
0
|
return; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
return $fh; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub view_pod { |
177
|
1
|
|
|
1
|
1
|
26
|
my ($self, $node) = @_; |
178
|
|
|
|
|
|
|
|
179
|
1
|
|
|
|
|
15
|
return $node->content()->present($self); |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub _generic_head { |
183
|
4
|
|
|
4
|
|
8
|
my ($self, $node, $marker, $do_overline) = @_; |
184
|
|
|
|
|
|
|
|
185
|
4
|
|
|
|
|
10
|
return scalar($self->_generic_head_multi($node, $marker, $do_overline)); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _generic_head_multi { |
189
|
16
|
|
|
16
|
|
26
|
my ($self, $node, $marker, $do_overline) = @_; |
190
|
|
|
|
|
|
|
|
191
|
16
|
|
|
|
|
59
|
my $title = $node->title()->present($self); |
192
|
16
|
|
|
|
|
116
|
my $content = $node->content()->present($self); |
193
|
|
|
|
|
|
|
|
194
|
16
|
50
|
|
|
|
68
|
$title = ' ' if $title eq ''; |
195
|
|
|
|
|
|
|
# my $section_line = $marker x length($title); |
196
|
|
|
|
|
|
|
|
197
|
16
|
|
|
|
|
34
|
my $section = $self->_build_header($title, $marker, $do_overline) . "\n" . $content; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# my $section = $title . "\n" . $section_line . "\n\n" . $content; |
200
|
|
|
|
|
|
|
# if ($do_overline) { |
201
|
|
|
|
|
|
|
# $section = $section_line . "\n" . $section; |
202
|
|
|
|
|
|
|
# } |
203
|
|
|
|
|
|
|
|
204
|
16
|
|
|
|
|
29
|
$section .= "\n"; |
205
|
|
|
|
|
|
|
|
206
|
16
|
100
|
|
|
|
55
|
return wantarray ? ($section, $content, $title) : $section; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub _build_header { |
210
|
17
|
|
|
17
|
|
28
|
my ($self, $text, $marker, $do_overline) = @_; |
211
|
|
|
|
|
|
|
|
212
|
17
|
|
|
|
|
36
|
my $line = $marker x length($text); |
213
|
17
|
|
|
|
|
29
|
my $header = $text . "\n" . $line . "\n"; |
214
|
|
|
|
|
|
|
|
215
|
17
|
100
|
|
|
|
32
|
if ($do_overline) { |
216
|
13
|
|
|
|
|
22
|
$header = $line . "\n" . $header; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
17
|
|
|
|
|
24
|
my $namespace = $self->{namespace}; |
220
|
17
|
50
|
|
|
|
28
|
if($namespace) { |
221
|
17
|
|
|
|
|
35
|
my $a = $text; |
222
|
|
|
|
|
|
|
# prepend the namesspace to gaurantee document wide unique names |
223
|
17
|
100
|
|
|
|
80
|
$a = "$namespace\:\:$a" unless($text =~ /^$namespace/); |
224
|
17
|
|
|
|
|
54
|
$a =~ s/(?:\s)/-/g; |
225
|
|
|
|
|
|
|
|
226
|
17
|
|
|
|
|
36
|
$header = qq{.. _$a:\n\n} . $header; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
17
|
|
|
|
|
71
|
return "\n" . $header; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub _do_indent { |
233
|
14
|
|
|
14
|
|
26
|
my ($self, $text, $indent_amount, $dbg) = @_; |
234
|
|
|
|
|
|
|
|
235
|
14
|
|
|
|
|
21
|
my $indent = ' ' x $indent_amount; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# $indent = "'$dbg" . $indent . "'"; |
238
|
|
|
|
|
|
|
|
239
|
14
|
|
|
|
|
41
|
my @lines = split /\n/, $text, -1; |
240
|
14
|
|
|
|
|
23
|
foreach my $line (@lines) { |
241
|
68
|
|
|
|
|
117
|
$line = $indent . $line; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
14
|
|
|
|
|
56
|
return join("\n", @lines); |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub view_head1 { |
248
|
12
|
|
|
12
|
1
|
258
|
my ($self, $node) = @_; |
249
|
|
|
|
|
|
|
|
250
|
12
|
|
|
|
|
23
|
my ($section, $content, $title) = $self->_generic_head_multi($node, '*', 1); |
251
|
|
|
|
|
|
|
|
252
|
12
|
50
|
66
|
|
|
35
|
unless ($self->{seen_something} or $self->{title_set}) { |
253
|
1
|
50
|
|
|
|
4
|
if ($title eq 'NAME') { |
254
|
1
|
|
|
|
|
2
|
$self->{seen_something} = 1; |
255
|
|
|
|
|
|
|
|
256
|
1
|
50
|
|
|
|
9
|
if ($content =~ /\A\s*(\w+(?:::\w+)+)\s+-\s+/s) { |
257
|
1
|
|
|
|
|
3
|
my $mod_name = $1; |
258
|
1
|
|
|
|
|
2
|
$self->{module_name} = $mod_name; |
259
|
1
|
|
|
|
|
2
|
$self->{title} = $mod_name; |
260
|
1
|
|
|
|
|
3
|
$self->{title_set} = 1; |
261
|
|
|
|
|
|
|
|
262
|
1
|
|
|
|
|
3
|
$section = $self->_build_header($mod_name, '#', 1) . $section; |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# my $line = '#' x length($mod_name); |
265
|
|
|
|
|
|
|
# $section = $line . "\n" . $mod_name . "\n" . $line . "\n\n" . $section; |
266
|
|
|
|
|
|
|
} |
267
|
|
|
|
|
|
|
|
268
|
1
|
|
|
|
|
5
|
return $section; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
11
|
|
|
|
|
14
|
$self->{seen_something} = 1; |
273
|
11
|
|
|
|
|
25
|
return $section; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub view_head2 { |
277
|
4
|
|
|
4
|
1
|
77
|
my ($self, $node) = @_; |
278
|
|
|
|
|
|
|
|
279
|
4
|
|
|
|
|
8
|
$self->{seen_something} = 1; |
280
|
4
|
|
|
|
|
9
|
return $self->_generic_head($node, '='); |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub view_head3 { |
284
|
0
|
|
|
0
|
1
|
0
|
my ($self, $node) = @_; |
285
|
|
|
|
|
|
|
|
286
|
0
|
|
|
|
|
0
|
$self->{seen_something} = 1; |
287
|
0
|
|
|
|
|
0
|
return $self->_generic_head($node, '-'); |
288
|
|
|
|
|
|
|
} |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub view_head4 { |
291
|
0
|
|
|
0
|
1
|
0
|
my ($self, $node) = @_; |
292
|
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
0
|
$self->{seen_something} = 1; |
294
|
0
|
|
|
|
|
0
|
return $self->_generic_head($node, '^'); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub view_item { |
298
|
11
|
|
|
11
|
1
|
240
|
my ($self, $node) = @_; |
299
|
|
|
|
|
|
|
|
300
|
11
|
|
|
|
|
15
|
$self->{seen_something} = 1; |
301
|
|
|
|
|
|
|
|
302
|
11
|
|
|
|
|
35
|
my $title = $node->title()->present($self); |
303
|
11
|
|
|
|
|
68
|
my $content = $node->content()->present($self); |
304
|
|
|
|
|
|
|
|
305
|
11
|
|
|
|
|
41
|
$title =~ s/\A\s+//; |
306
|
11
|
|
|
|
|
17
|
$title =~ s/\n/ /; |
307
|
|
|
|
|
|
|
# $content =~ s/\n/\n /g; |
308
|
|
|
|
|
|
|
# $content = ' ' . $content; |
309
|
|
|
|
|
|
|
|
310
|
11
|
|
|
|
|
19
|
$self->{view_item_count}++; |
311
|
11
|
|
|
|
|
28
|
$content = $self->_do_indent($content, 1, "[[view_item_$self->{view_item_count}]]"); |
312
|
|
|
|
|
|
|
|
313
|
11
|
|
|
|
|
42
|
return "\n" . $title . "\n" . $content . "\n\n"; |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
sub view_over { |
317
|
5
|
|
|
5
|
1
|
93
|
my ($self, $node) = @_; |
318
|
|
|
|
|
|
|
|
319
|
5
|
|
|
|
|
29
|
my $content = $node->content()->present($self); |
320
|
|
|
|
|
|
|
# my $indent = $node->indent(); |
321
|
|
|
|
|
|
|
|
322
|
5
|
|
|
|
|
43
|
return "\n" . $content; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub view_text { |
326
|
0
|
|
|
0
|
0
|
0
|
my ($self, $node) = @_; |
327
|
|
|
|
|
|
|
|
328
|
0
|
|
|
|
|
0
|
my @lines = split /\n/, $node; |
329
|
0
|
|
|
|
|
0
|
foreach my $line (@lines) { |
330
|
0
|
|
|
|
|
0
|
$line =~ s/\A\s+//; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
0
|
return join("\n", @lines); |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
sub view_textblock { |
337
|
38
|
|
|
38
|
1
|
230
|
my ($self, $text) = @_; |
338
|
|
|
|
|
|
|
|
339
|
38
|
|
|
|
|
133
|
return "\n" . $text . "\n"; |
340
|
|
|
|
|
|
|
} |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
sub view_verbatim { |
344
|
3
|
|
|
3
|
1
|
49
|
my ($self, $node) = @_; |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
# (my $node_part = ' ' . $node) =~ s/\n/\n /g; |
347
|
3
|
|
|
|
|
10
|
my $node_part = $self->_do_indent($node . '', 1, '[[view_verbatim]]'); |
348
|
|
|
|
|
|
|
|
349
|
3
|
|
|
|
|
6
|
my $block_part = ".. code-block:: perl\n\n"; |
350
|
3
|
100
|
|
|
|
7
|
if (defined($self->{next_code_block})) { |
351
|
1
|
|
|
|
|
2
|
my $lang = $self->{next_code_block}; |
352
|
1
|
|
|
|
|
3
|
delete $self->{next_code_block}; |
353
|
|
|
|
|
|
|
|
354
|
1
|
50
|
|
|
|
4
|
if ($lang eq 'none') { |
355
|
|
|
|
|
|
|
# FIXME: need to output a preformatted paragraph here, but no highlighting |
356
|
0
|
|
|
|
|
0
|
$block_part = ''; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
else { |
359
|
1
|
|
|
|
|
3
|
$block_part = ".. code-block:: $lang\n\n"; |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
3
|
|
|
|
|
9
|
my $content = $block_part . $node_part; |
364
|
|
|
|
|
|
|
|
365
|
3
|
|
|
|
|
36
|
return "\n\n" . $content . "\n\n"; |
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
sub view_for { |
369
|
1
|
|
|
1
|
1
|
28
|
my ($self, $node) = @_; |
370
|
|
|
|
|
|
|
|
371
|
1
|
|
|
|
|
9
|
my $fmt = $node->format(); |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# print STDERR "got for: fmt='$fmt', text='" . $node->text() . "'\n"; |
374
|
|
|
|
|
|
|
|
375
|
1
|
50
|
|
|
|
15
|
if ($fmt eq 'pod2rst') { |
376
|
1
|
|
|
|
|
6
|
my $text = $node->text(); |
377
|
1
|
50
|
|
|
|
16
|
if ($text =~ /\A\s*next-code-block\s*:\s*(\S+)/) { |
378
|
1
|
|
|
|
|
4
|
my $lang = $1; |
379
|
1
|
|
|
|
|
3
|
$self->{next_code_block} = $lang; |
380
|
1
|
|
|
|
|
3
|
return ''; |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
0
|
|
|
|
|
0
|
return "\n". $node->text() . "\n\n"; |
384
|
|
|
|
|
|
|
} |
385
|
|
|
|
|
|
|
|
386
|
0
|
|
|
|
|
0
|
return $self->SUPER::view_for($node); |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
sub view_seq_code { |
390
|
29
|
|
|
29
|
1
|
200
|
my ($self, $text) = @_; |
391
|
|
|
|
|
|
|
|
392
|
29
|
|
|
|
|
74
|
return '\ ``' . $text . '``\ '; |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub view_seq_bold { |
396
|
2
|
|
|
2
|
1
|
16
|
my ($self, $text) = @_; |
397
|
|
|
|
|
|
|
|
398
|
2
|
|
|
|
|
4
|
$text =~ s/\*/\\*/g; |
399
|
2
|
|
|
|
|
4
|
$text =~ s/\`/\\`/g; |
400
|
|
|
|
|
|
|
|
401
|
2
|
|
|
|
|
7
|
return '\ **' . $text . '**\ '; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub view_seq_italic { |
405
|
3
|
|
|
3
|
1
|
32
|
my ($self, $text) = @_; |
406
|
|
|
|
|
|
|
|
407
|
3
|
|
|
|
|
6
|
$text =~ s/\*/\\*/g; |
408
|
3
|
|
|
|
|
5
|
$text =~ s/\`/\\`/g; |
409
|
|
|
|
|
|
|
|
410
|
3
|
|
|
|
|
10
|
return '\ *' . $text . '*\ '; |
411
|
|
|
|
|
|
|
} |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
sub view_seq_file { |
414
|
0
|
|
|
0
|
1
|
0
|
my ($self, $text) = @_; |
415
|
|
|
|
|
|
|
|
416
|
0
|
|
|
|
|
0
|
$text =~ s/\*/\\*/g; |
417
|
0
|
|
|
|
|
0
|
$text =~ s/\`/\\`/g; |
418
|
|
|
|
|
|
|
|
419
|
0
|
|
|
|
|
0
|
return '\ *' . $text . '*\ '; |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub view_seq_text { |
423
|
132
|
|
|
132
|
0
|
2220
|
my ($self, $node) = @_; |
424
|
|
|
|
|
|
|
|
425
|
132
|
|
|
|
|
212
|
my $text = $node . ''; |
426
|
|
|
|
|
|
|
|
427
|
132
|
|
|
|
|
186
|
$text =~ s/\*/\\*/g; |
428
|
132
|
|
|
|
|
152
|
$text =~ s/\`/\\`/g; |
429
|
|
|
|
|
|
|
|
430
|
132
|
|
|
|
|
297
|
return $text; |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
sub view_seq_zero { |
434
|
1
|
|
|
1
|
0
|
18
|
return ''; |
435
|
|
|
|
|
|
|
} |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
sub view_seq_link { |
438
|
11
|
|
|
11
|
1
|
80
|
my ($self, $text) = @_; |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
# FIXME: determine if has label, if manpage, etc., and pass that info along to the callback, |
441
|
|
|
|
|
|
|
# instead of just the text, e.g., |
442
|
|
|
|
|
|
|
# $link_cb->($label, $name, $sec, $url); |
443
|
11
|
|
|
|
|
19
|
my $link_cb = $self->{callbacks}{link}; |
444
|
11
|
50
|
|
|
|
21
|
if ($link_cb) { |
445
|
0
|
|
|
|
|
0
|
my ($url, $label) = $link_cb->($text); |
446
|
|
|
|
|
|
|
|
447
|
0
|
0
|
|
|
|
0
|
if (defined($url)) { |
448
|
0
|
0
|
0
|
|
|
0
|
if ($url eq '' and defined($label) and $label ne '') { |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
449
|
0
|
|
|
|
|
0
|
$text = $label; |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
elsif (defined($label) and $label ne '') { |
452
|
0
|
|
|
|
|
0
|
$text = qq{`$label <$url>`_}; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
else { |
455
|
0
|
|
|
|
|
0
|
$text = qq{`$url <$url>`_}; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
|
458
|
0
|
|
|
|
|
0
|
return $text; |
459
|
|
|
|
|
|
|
} |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
|
462
|
11
|
|
|
|
|
14
|
my $url = ''; |
463
|
11
|
|
|
|
|
12
|
my $label = ''; |
464
|
11
|
|
|
|
|
15
|
my $module = $text; |
465
|
11
|
|
|
|
|
15
|
my $namespace = $self->{namespace}; |
466
|
|
|
|
|
|
|
|
467
|
11
|
100
|
|
|
|
42
|
if ($text =~ m{\A/(.+)}) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
468
|
2
|
|
|
|
|
12
|
(my $section = $1) =~ s/\A"(.+)"/$1/; |
469
|
2
|
|
|
|
|
6
|
$text = qq{`$section`_}; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
elsif ($text =~ m{\Ahttps?://}) { |
472
|
4
|
|
|
|
|
18
|
$text = qq{`$text <$text>`_}; |
473
|
|
|
|
|
|
|
} |
474
|
|
|
|
|
|
|
elsif ($text =~ /::/) { |
475
|
4
|
|
|
|
|
6
|
$label = $text; |
476
|
4
|
50
|
|
|
|
13
|
if ($text =~ /\A(.+?)\|(.+::.+)/) { |
477
|
0
|
|
|
|
|
0
|
$label = $1; |
478
|
0
|
|
|
|
|
0
|
$module = $2; |
479
|
|
|
|
|
|
|
} |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
# Links in this namespace are cross refereneces |
482
|
4
|
100
|
66
|
|
|
29
|
if (($namespace) and ($text =~ /^$namespace/)) { |
483
|
1
|
50
|
|
|
|
18
|
$module = qq{$namespace\:\:$module} unless($module =~ /^$namespace/); |
484
|
1
|
|
|
|
|
10
|
$module =~ s/(?:\s)/-/g; |
485
|
1
|
|
|
|
|
6
|
$text = qq{:ref:`$label <$module>`}; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
else { |
488
|
3
|
|
|
|
|
8
|
$module = $self->_url_encode($module); |
489
|
3
|
|
|
|
|
6
|
my $url = "http://search.cpan.org/search?query=$module&mode=module"; |
490
|
3
|
|
|
|
|
8
|
$text = qq{`$label <$url>`_}; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
11
|
|
|
|
|
35
|
return $text; |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
sub _url_encode { |
498
|
3
|
|
|
3
|
|
6
|
my ($self, $str) = @_; |
499
|
|
|
|
|
|
|
|
500
|
2
|
|
|
2
|
|
13899
|
use bytes; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
501
|
3
|
|
|
|
|
10
|
$str =~ s{([^A-Za-z0-9_])}{sprintf("%%%02x", ord($1))}eg; |
|
14
|
|
|
|
|
44
|
|
502
|
3
|
|
|
|
|
7
|
return $str; |
503
|
|
|
|
|
|
|
} |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
1; |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
__END__ |