| 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-2021 Alex Muntada |
|
7
|
|
|
|
|
|
|
# LICENSE: Perl_5 |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
210381
|
use strict; |
|
|
3
|
|
|
|
|
24
|
|
|
|
3
|
|
|
|
|
90
|
|
|
11
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
71
|
|
|
12
|
3
|
|
|
3
|
|
1997
|
use Data::Dumper (); |
|
|
3
|
|
|
|
|
20980
|
|
|
|
3
|
|
|
|
|
89
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
1982
|
use Pod::POM; |
|
|
3
|
|
|
|
|
75134
|
|
|
|
3
|
|
|
|
|
269
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Pod::POM::View::Restructured; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '1.000003'; # VERSION |
|
19
|
|
|
|
|
|
|
|
|
20
|
3
|
|
|
3
|
|
26
|
use base 'Pod::POM::View::Text'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
1710
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
|
24
|
4
|
|
|
4
|
1
|
193
|
my ($class, $params) = @_; |
|
25
|
4
|
50
|
33
|
|
|
33
|
$params = { } unless $params and UNIVERSAL::isa($params, 'HASH'); |
|
26
|
|
|
|
|
|
|
|
|
27
|
4
|
|
33
|
|
|
28
|
my $self = bless { seen_something => 0, title_set => 0, params => { } }, ref($class) || $class; |
|
28
|
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
10
|
my $callbacks = $params->{callbacks}; |
|
30
|
4
|
100
|
|
|
|
11
|
$callbacks = { } unless $callbacks; |
|
31
|
4
|
|
|
|
|
24
|
$self->{callbacks} = $callbacks; |
|
32
|
4
|
|
|
|
|
12
|
$self->{namespace} = delete($params->{namespace}); |
|
33
|
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
11
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub convert_file { |
|
38
|
2
|
|
|
2
|
1
|
1197
|
my ($self, $source_file, $title, $dest_file, $callbacks) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
5
|
my $cb; |
|
41
|
2
|
50
|
|
|
|
8
|
if ($callbacks) { |
|
42
|
0
|
|
|
|
|
0
|
$cb = { %{ $self->{callbacks} }, %$callbacks }; |
|
|
0
|
|
|
|
|
0
|
|
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
else { |
|
45
|
2
|
|
|
|
|
6
|
$cb = $self->{callbacks}; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
12
|
my $view = Pod::POM::View::Restructured->new({ callbacks => $cb, namespace => $self->{namespace} }); |
|
49
|
2
|
|
|
|
|
21
|
my $parser = Pod::POM->new; |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
50
|
|
|
|
89
|
unless (-r $source_file) { |
|
52
|
0
|
|
|
|
|
0
|
warn "can't read source file $source_file"; |
|
53
|
0
|
|
|
|
|
0
|
return; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
14
|
my $pom = $parser->parse_file($source_file); |
|
57
|
|
|
|
|
|
|
|
|
58
|
2
|
50
|
|
|
|
21174
|
$view->{title_set} = 1 if defined($title); |
|
59
|
2
|
|
|
|
|
52
|
my $out = $pom->present($view); |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
50
|
|
|
|
66
|
if (defined($title)) { |
|
62
|
0
|
|
|
|
|
0
|
$out = $self->_build_header($title, '#', 1) . "\n" . $out; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
else { |
|
65
|
2
|
|
|
|
|
7
|
$title = $view->{title}; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
2
|
50
|
33
|
|
|
14
|
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
|
2
|
|
|
|
|
9
|
my $rv = { content => $out, title => $title }; |
|
85
|
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
15
|
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
|
2
|
|
|
2
|
1
|
47
|
my ($self, $node) = @_; |
|
178
|
|
|
|
|
|
|
|
|
179
|
2
|
|
|
|
|
18
|
return $node->content()->present($self); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub _generic_head { |
|
183
|
4
|
|
|
4
|
|
8
|
my ($self, $node, $marker, $do_overline) = @_; |
|
184
|
|
|
|
|
|
|
|
|
185
|
4
|
|
|
|
|
22
|
return scalar($self->_generic_head_multi($node, $marker, $do_overline)); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub _generic_head_multi { |
|
189
|
16
|
|
|
16
|
|
35
|
my ($self, $node, $marker, $do_overline) = @_; |
|
190
|
|
|
|
|
|
|
|
|
191
|
16
|
|
|
|
|
80
|
my $title = $node->title()->present($self); |
|
192
|
16
|
|
|
|
|
134
|
my $content = $node->content()->present($self); |
|
193
|
|
|
|
|
|
|
|
|
194
|
16
|
50
|
|
|
|
87
|
$title = ' ' if $title eq ''; |
|
195
|
|
|
|
|
|
|
# my $section_line = $marker x length($title); |
|
196
|
|
|
|
|
|
|
|
|
197
|
16
|
|
|
|
|
37
|
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
|
|
|
|
|
43
|
$section .= "\n"; |
|
205
|
|
|
|
|
|
|
|
|
206
|
16
|
100
|
|
|
|
127
|
return wantarray ? ($section, $content, $title) : $section; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub _build_header { |
|
210
|
17
|
|
|
17
|
|
38
|
my ($self, $text, $marker, $do_overline) = @_; |
|
211
|
|
|
|
|
|
|
|
|
212
|
17
|
|
|
|
|
40
|
my $line = $marker x length($text); |
|
213
|
17
|
|
|
|
|
37
|
my $header = $text . "\n" . $line . "\n"; |
|
214
|
|
|
|
|
|
|
|
|
215
|
17
|
100
|
|
|
|
46
|
if ($do_overline) { |
|
216
|
13
|
|
|
|
|
27
|
$header = $line . "\n" . $header; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
17
|
|
|
|
|
30
|
my $namespace = $self->{namespace}; |
|
220
|
17
|
50
|
|
|
|
35
|
if($namespace) { |
|
221
|
17
|
|
|
|
|
25
|
my $a = $text; |
|
222
|
|
|
|
|
|
|
# prepend the namesspace to gaurantee document wide unique names |
|
223
|
17
|
100
|
|
|
|
96
|
$a = "$namespace\:\:$a" unless($text =~ /^$namespace/); |
|
224
|
17
|
|
|
|
|
66
|
$a =~ s/(?:\s)/-/g; |
|
225
|
|
|
|
|
|
|
|
|
226
|
17
|
|
|
|
|
47
|
$header = qq{.. _$a:\n\n} . $header; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
17
|
|
|
|
|
75
|
return "\n" . $header; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub _do_indent { |
|
233
|
19
|
|
|
19
|
|
42
|
my ($self, $text, $indent_amount, $dbg) = @_; |
|
234
|
|
|
|
|
|
|
|
|
235
|
19
|
|
|
|
|
39
|
my $indent = ' ' x $indent_amount; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# $indent = "'$dbg" . $indent . "'"; |
|
238
|
|
|
|
|
|
|
|
|
239
|
19
|
|
|
|
|
68
|
my @lines = split /\n/, $text, -1; |
|
240
|
19
|
|
|
|
|
42
|
foreach my $line (@lines) { |
|
241
|
68
|
|
|
|
|
133
|
$line = $indent . $line; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
19
|
|
|
|
|
81
|
return join("\n", @lines); |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub view_head1 { |
|
248
|
12
|
|
|
12
|
1
|
311
|
my ($self, $node) = @_; |
|
249
|
|
|
|
|
|
|
|
|
250
|
12
|
|
|
|
|
38
|
my ($section, $content, $title) = $self->_generic_head_multi($node, '*', 1); |
|
251
|
|
|
|
|
|
|
|
|
252
|
12
|
50
|
66
|
|
|
42
|
unless ($self->{seen_something} or $self->{title_set}) { |
|
253
|
1
|
50
|
|
|
|
4
|
if ($title eq 'NAME') { |
|
254
|
1
|
|
|
|
|
3
|
$self->{seen_something} = 1; |
|
255
|
|
|
|
|
|
|
|
|
256
|
1
|
50
|
|
|
|
8
|
if ($content =~ /\A\s*(\w+(?:::\w+)+)\s+-\s+/s) { |
|
257
|
1
|
|
|
|
|
3
|
my $mod_name = $1; |
|
258
|
1
|
|
|
|
|
3
|
$self->{module_name} = $mod_name; |
|
259
|
1
|
|
|
|
|
3
|
$self->{title} = $mod_name; |
|
260
|
1
|
|
|
|
|
2
|
$self->{title_set} = 1; |
|
261
|
|
|
|
|
|
|
|
|
262
|
1
|
|
|
|
|
12
|
$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
|
|
|
|
|
4
|
return $section; |
|
269
|
|
|
|
|
|
|
} |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
11
|
|
|
|
|
19
|
$self->{seen_something} = 1; |
|
273
|
11
|
|
|
|
|
25
|
return $section; |
|
274
|
|
|
|
|
|
|
} |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub view_head2 { |
|
277
|
4
|
|
|
4
|
1
|
90
|
my ($self, $node) = @_; |
|
278
|
|
|
|
|
|
|
|
|
279
|
4
|
|
|
|
|
9
|
$self->{seen_something} = 1; |
|
280
|
4
|
|
|
|
|
11
|
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
|
16
|
|
|
16
|
1
|
461
|
my ($self, $node) = @_; |
|
299
|
|
|
|
|
|
|
|
|
300
|
16
|
|
|
|
|
28
|
$self->{seen_something} = 1; |
|
301
|
|
|
|
|
|
|
|
|
302
|
16
|
|
|
|
|
66
|
my $title = $node->title()->present($self); |
|
303
|
16
|
|
|
|
|
128
|
my $content = $node->content()->present($self); |
|
304
|
|
|
|
|
|
|
|
|
305
|
16
|
|
|
|
|
190
|
$title =~ s/\A\s+//; |
|
306
|
16
|
|
|
|
|
29
|
$title =~ s/\n/ /; |
|
307
|
16
|
100
|
|
|
|
66
|
$title = "- $title" |
|
308
|
|
|
|
|
|
|
unless $title =~ / |
|
309
|
|
|
|
|
|
|
# the line starts with |
|
310
|
|
|
|
|
|
|
\A |
|
311
|
|
|
|
|
|
|
# single unordered bullet, |
|
312
|
|
|
|
|
|
|
(?:(?:[-+] | \\[*]) |
|
313
|
|
|
|
|
|
|
# or ordered bullet followed by dot, |
|
314
|
|
|
|
|
|
|
| [1AaIi] \. |
|
315
|
|
|
|
|
|
|
# or ordered bullet within parens (first optional), |
|
316
|
|
|
|
|
|
|
| \(? [1AaIi] \) |
|
317
|
|
|
|
|
|
|
# then finally followed by whitespace. |
|
318
|
|
|
|
|
|
|
)\s |
|
319
|
|
|
|
|
|
|
/xms; |
|
320
|
|
|
|
|
|
|
# Make asterisk an actual bullet |
|
321
|
16
|
|
|
|
|
31
|
$title =~ s/ \A \\ [*]/*/xms; |
|
322
|
|
|
|
|
|
|
# $content =~ s/\n/\n /g; |
|
323
|
|
|
|
|
|
|
# $content = ' ' . $content; |
|
324
|
|
|
|
|
|
|
|
|
325
|
16
|
|
|
|
|
33
|
$self->{view_item_count}++; |
|
326
|
16
|
|
|
|
|
52
|
$content = $self->_do_indent($content, 1, "[[view_item_$self->{view_item_count}]]"); |
|
327
|
|
|
|
|
|
|
|
|
328
|
16
|
|
|
|
|
57
|
return "\n" . $title . "\n" . $content . "\n\n"; |
|
329
|
|
|
|
|
|
|
} |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub view_over { |
|
332
|
6
|
|
|
6
|
1
|
172
|
my ($self, $node) = @_; |
|
333
|
|
|
|
|
|
|
|
|
334
|
6
|
|
|
|
|
29
|
my $content = $node->content()->present($self); |
|
335
|
|
|
|
|
|
|
# my $indent = $node->indent(); |
|
336
|
|
|
|
|
|
|
|
|
337
|
6
|
|
|
|
|
77
|
return "\n" . $content; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub view_text { |
|
341
|
0
|
|
|
0
|
0
|
0
|
my ($self, $node) = @_; |
|
342
|
|
|
|
|
|
|
|
|
343
|
0
|
|
|
|
|
0
|
my @lines = split /\n/, $node; |
|
344
|
0
|
|
|
|
|
0
|
foreach my $line (@lines) { |
|
345
|
0
|
|
|
|
|
0
|
$line =~ s/\A\s+//; |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
0
|
|
|
|
|
0
|
return join("\n", @lines); |
|
349
|
|
|
|
|
|
|
} |
|
350
|
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
sub view_textblock { |
|
352
|
37
|
|
|
37
|
1
|
275
|
my ($self, $text) = @_; |
|
353
|
|
|
|
|
|
|
|
|
354
|
37
|
|
|
|
|
124
|
return "\n" . $text . "\n"; |
|
355
|
|
|
|
|
|
|
} |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
sub view_verbatim { |
|
359
|
3
|
|
|
3
|
1
|
56
|
my ($self, $node) = @_; |
|
360
|
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
# (my $node_part = ' ' . $node) =~ s/\n/\n /g; |
|
362
|
3
|
|
|
|
|
12
|
my $node_part = $self->_do_indent($node . '', 1, '[[view_verbatim]]'); |
|
363
|
|
|
|
|
|
|
|
|
364
|
3
|
|
|
|
|
6
|
my $block_part = ".. code-block:: perl\n\n"; |
|
365
|
3
|
100
|
|
|
|
11
|
if (defined($self->{next_code_block})) { |
|
366
|
1
|
|
|
|
|
3
|
my $lang = $self->{next_code_block}; |
|
367
|
1
|
|
|
|
|
3
|
delete $self->{next_code_block}; |
|
368
|
|
|
|
|
|
|
|
|
369
|
1
|
50
|
|
|
|
4
|
if ($lang eq 'none') { |
|
370
|
|
|
|
|
|
|
# FIXME: need to output a preformatted paragraph here, but no highlighting |
|
371
|
0
|
|
|
|
|
0
|
$block_part = ''; |
|
372
|
|
|
|
|
|
|
} |
|
373
|
|
|
|
|
|
|
else { |
|
374
|
1
|
|
|
|
|
4
|
$block_part = ".. code-block:: $lang\n\n"; |
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
} |
|
377
|
|
|
|
|
|
|
|
|
378
|
3
|
|
|
|
|
8
|
my $content = $block_part . $node_part; |
|
379
|
|
|
|
|
|
|
|
|
380
|
3
|
|
|
|
|
16
|
return "\n\n" . $content . "\n\n"; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
sub view_for { |
|
384
|
1
|
|
|
1
|
1
|
34
|
my ($self, $node) = @_; |
|
385
|
|
|
|
|
|
|
|
|
386
|
1
|
|
|
|
|
10
|
my $fmt = $node->format(); |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
# print STDERR "got for: fmt='$fmt', text='" . $node->text() . "'\n"; |
|
389
|
|
|
|
|
|
|
|
|
390
|
1
|
50
|
|
|
|
18
|
if ($fmt eq 'pod2rst') { |
|
391
|
1
|
|
|
|
|
6
|
my $text = $node->text(); |
|
392
|
1
|
50
|
|
|
|
21
|
if ($text =~ /\A\s*next-code-block\s*:\s*(\S+)/) { |
|
393
|
1
|
|
|
|
|
4
|
my $lang = $1; |
|
394
|
1
|
|
|
|
|
3
|
$self->{next_code_block} = $lang; |
|
395
|
1
|
|
|
|
|
3
|
return ''; |
|
396
|
|
|
|
|
|
|
} |
|
397
|
|
|
|
|
|
|
|
|
398
|
0
|
|
|
|
|
0
|
return "\n". $node->text() . "\n\n"; |
|
399
|
|
|
|
|
|
|
} |
|
400
|
|
|
|
|
|
|
|
|
401
|
0
|
|
|
|
|
0
|
return $self->SUPER::view_for($node); |
|
402
|
|
|
|
|
|
|
} |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub view_seq_code { |
|
405
|
29
|
|
|
29
|
1
|
253
|
my ($self, $text) = @_; |
|
406
|
|
|
|
|
|
|
|
|
407
|
29
|
|
|
|
|
103
|
return '\ ``' . $text . '``\ '; |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
sub view_seq_bold { |
|
411
|
2
|
|
|
2
|
1
|
21
|
my ($self, $text) = @_; |
|
412
|
|
|
|
|
|
|
|
|
413
|
2
|
|
|
|
|
4
|
$text =~ s/\*/\\*/g; |
|
414
|
2
|
|
|
|
|
4
|
$text =~ s/\`/\\`/g; |
|
415
|
|
|
|
|
|
|
|
|
416
|
2
|
|
|
|
|
9
|
return '\ **' . $text . '**\ '; |
|
417
|
|
|
|
|
|
|
} |
|
418
|
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
sub view_seq_italic { |
|
420
|
3
|
|
|
3
|
1
|
30
|
my ($self, $text) = @_; |
|
421
|
|
|
|
|
|
|
|
|
422
|
3
|
|
|
|
|
8
|
$text =~ s/\*/\\*/g; |
|
423
|
3
|
|
|
|
|
4
|
$text =~ s/\`/\\`/g; |
|
424
|
|
|
|
|
|
|
|
|
425
|
3
|
|
|
|
|
12
|
return '\ *' . $text . '*\ '; |
|
426
|
|
|
|
|
|
|
} |
|
427
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
sub view_seq_file { |
|
429
|
0
|
|
|
0
|
1
|
0
|
my ($self, $text) = @_; |
|
430
|
|
|
|
|
|
|
|
|
431
|
0
|
|
|
|
|
0
|
$text =~ s/\*/\\*/g; |
|
432
|
0
|
|
|
|
|
0
|
$text =~ s/\`/\\`/g; |
|
433
|
|
|
|
|
|
|
|
|
434
|
0
|
|
|
|
|
0
|
return '\ *' . $text . '*\ '; |
|
435
|
|
|
|
|
|
|
} |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
sub view_seq_text { |
|
438
|
134
|
|
|
134
|
0
|
2811
|
my ($self, $node) = @_; |
|
439
|
|
|
|
|
|
|
|
|
440
|
134
|
|
|
|
|
281
|
my $text = $node . ''; |
|
441
|
|
|
|
|
|
|
|
|
442
|
134
|
|
|
|
|
236
|
$text =~ s/\*/\\*/g; |
|
443
|
134
|
|
|
|
|
195
|
$text =~ s/\`/\\`/g; |
|
444
|
|
|
|
|
|
|
|
|
445
|
134
|
|
|
|
|
370
|
return $text; |
|
446
|
|
|
|
|
|
|
} |
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub view_seq_zero { |
|
449
|
1
|
|
|
1
|
0
|
57
|
return ''; |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
sub view_seq_link { |
|
453
|
10
|
|
|
10
|
1
|
89
|
my ($self, $text) = @_; |
|
454
|
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
# FIXME: determine if has label, if manpage, etc., and pass that info along to the callback, |
|
456
|
|
|
|
|
|
|
# instead of just the text, e.g., |
|
457
|
|
|
|
|
|
|
# $link_cb->($label, $name, $sec, $url); |
|
458
|
10
|
|
|
|
|
21
|
my $link_cb = $self->{callbacks}{link}; |
|
459
|
10
|
50
|
|
|
|
31
|
if ($link_cb) { |
|
460
|
0
|
|
|
|
|
0
|
my ($url, $label) = $link_cb->($text); |
|
461
|
|
|
|
|
|
|
|
|
462
|
0
|
0
|
|
|
|
0
|
if (defined($url)) { |
|
463
|
0
|
0
|
0
|
|
|
0
|
if ($url eq '' and defined($label) and $label ne '') { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
464
|
0
|
|
|
|
|
0
|
$text = $label; |
|
465
|
|
|
|
|
|
|
} |
|
466
|
|
|
|
|
|
|
elsif (defined($label) and $label ne '') { |
|
467
|
0
|
|
|
|
|
0
|
$text = qq{`$label <$url>`_}; |
|
468
|
|
|
|
|
|
|
} |
|
469
|
|
|
|
|
|
|
else { |
|
470
|
0
|
|
|
|
|
0
|
$text = qq{`$url <$url>`_}; |
|
471
|
|
|
|
|
|
|
} |
|
472
|
|
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
0
|
return $text; |
|
474
|
|
|
|
|
|
|
} |
|
475
|
|
|
|
|
|
|
} |
|
476
|
|
|
|
|
|
|
|
|
477
|
10
|
|
|
|
|
18
|
my $url = ''; |
|
478
|
10
|
|
|
|
|
14
|
my $label = ''; |
|
479
|
10
|
|
|
|
|
17
|
my $module = $text; |
|
480
|
10
|
|
|
|
|
22
|
my $namespace = $self->{namespace}; |
|
481
|
|
|
|
|
|
|
|
|
482
|
10
|
100
|
|
|
|
50
|
if ($text =~ m{\A/(.+)}) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
483
|
2
|
|
|
|
|
13
|
(my $section = $1) =~ s/\A"(.+)"/$1/; |
|
484
|
2
|
|
|
|
|
9
|
$text = qq{`$section`_}; |
|
485
|
|
|
|
|
|
|
} |
|
486
|
|
|
|
|
|
|
elsif ($text =~ m{\Ahttps?://}) { |
|
487
|
4
|
|
|
|
|
10
|
$text = qq{`$text <$text>`_}; |
|
488
|
|
|
|
|
|
|
} |
|
489
|
|
|
|
|
|
|
elsif ($text =~ /::/) { |
|
490
|
3
|
|
|
|
|
4
|
$label = $text; |
|
491
|
3
|
50
|
|
|
|
14
|
if ($text =~ /\A(.+?)\|(.+::.+)/) { |
|
492
|
0
|
|
|
|
|
0
|
$label = $1; |
|
493
|
0
|
|
|
|
|
0
|
$module = $2; |
|
494
|
|
|
|
|
|
|
} |
|
495
|
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
# Links in this namespace are cross refereneces |
|
497
|
3
|
50
|
33
|
|
|
30
|
if (($namespace) and ($text =~ /^$namespace/)) { |
|
498
|
0
|
0
|
|
|
|
0
|
$module = qq{$namespace\:\:$module} unless($module =~ /^$namespace/); |
|
499
|
0
|
|
|
|
|
0
|
$module =~ s/(?:\s)/-/g; |
|
500
|
0
|
|
|
|
|
0
|
$text = qq{:ref:`$label <$module>`}; |
|
501
|
|
|
|
|
|
|
} |
|
502
|
|
|
|
|
|
|
else { |
|
503
|
3
|
|
|
|
|
11
|
$module = $self->_url_encode($module); |
|
504
|
3
|
|
|
|
|
10
|
my $url = "http://search.cpan.org/search?query=$module&mode=module"; |
|
505
|
3
|
|
|
|
|
10
|
$text = qq{`$label <$url>`_}; |
|
506
|
|
|
|
|
|
|
} |
|
507
|
|
|
|
|
|
|
} |
|
508
|
|
|
|
|
|
|
|
|
509
|
10
|
|
|
|
|
39
|
return $text; |
|
510
|
|
|
|
|
|
|
} |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
sub _url_encode { |
|
513
|
3
|
|
|
3
|
|
6
|
my ($self, $str) = @_; |
|
514
|
|
|
|
|
|
|
|
|
515
|
3
|
|
|
3
|
|
24745
|
use bytes; |
|
|
3
|
|
|
|
|
10
|
|
|
|
3
|
|
|
|
|
23
|
|
|
516
|
3
|
|
|
|
|
14
|
$str =~ s{([^A-Za-z0-9_])}{sprintf("%%%02x", ord($1))}eg; |
|
|
14
|
|
|
|
|
51
|
|
|
517
|
3
|
|
|
|
|
24
|
return $str; |
|
518
|
|
|
|
|
|
|
} |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
1; |
|
523
|
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
__END__ |