line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::JsonAPI::Autodoc::Markdown; |
2
|
15
|
|
|
15
|
|
61
|
use strict; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
687
|
|
3
|
15
|
|
|
15
|
|
68
|
use warnings; |
|
15
|
|
|
|
|
17
|
|
|
15
|
|
|
|
|
403
|
|
4
|
15
|
|
|
15
|
|
573
|
use utf8; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
90
|
|
5
|
15
|
|
|
15
|
|
7743
|
use Data::Section::Simple; |
|
15
|
|
|
|
|
7353
|
|
|
15
|
|
|
|
|
675
|
|
6
|
15
|
|
|
15
|
|
7959
|
use Time::Piece; |
|
15
|
|
|
|
|
105310
|
|
|
15
|
|
|
|
|
64
|
|
7
|
15
|
|
|
15
|
|
9379
|
use Text::Xslate qw(mark_raw); |
|
15
|
|
|
|
|
120091
|
|
|
15
|
|
|
|
|
1078
|
|
8
|
15
|
|
|
15
|
|
8276
|
use Text::Xslate::Bridge::Star; |
|
15
|
|
|
|
|
23366
|
|
|
15
|
|
|
|
|
385
|
|
9
|
15
|
|
|
15
|
|
5655
|
use Test::JsonAPI::Autodoc::Path; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
3304
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
16
|
|
|
16
|
0
|
36
|
my ($class, $output_path, $template) = @_; |
13
|
|
|
|
|
|
|
|
14
|
16
|
|
|
|
|
103
|
bless { |
15
|
|
|
|
|
|
|
output_path => $output_path, |
16
|
|
|
|
|
|
|
template => $template, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate { |
21
|
16
|
|
|
16
|
0
|
30
|
my ($self, $description, $results, $first_time) = @_; |
22
|
|
|
|
|
|
|
|
23
|
16
|
|
|
|
|
172
|
my $document_path = Test::JsonAPI::Autodoc::Path->document_path($self->{output_path}); |
24
|
|
|
|
|
|
|
|
25
|
16
|
|
|
|
|
164
|
my $vpath = Data::Section::Simple->new()->get_data_section(); |
26
|
16
|
|
|
|
|
2779
|
my $tx = Text::Xslate->new( |
27
|
|
|
|
|
|
|
type => 'text', |
28
|
|
|
|
|
|
|
path => [$vpath], |
29
|
|
|
|
|
|
|
module => ['Text::Xslate::Bridge::Star'], |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
16
|
|
|
|
|
9836
|
my $fh; |
33
|
|
|
|
|
|
|
my $generated_at; |
34
|
16
|
100
|
|
|
|
54
|
if ($first_time) { |
35
|
12
|
|
|
|
|
85
|
$fh = $document_path->openw_utf8( { locked => 1 } ); |
36
|
12
|
|
|
|
|
117898
|
$generated_at = localtime->strftime('%Y-%m-%d %H:%M:%S'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
4
|
|
|
|
|
23
|
$fh = $document_path->opena_utf8( { locked => 1 } ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
16
|
|
|
|
|
3181
|
my $vars = { |
43
|
|
|
|
|
|
|
generated_at => $generated_at, |
44
|
|
|
|
|
|
|
description => $description, |
45
|
|
|
|
|
|
|
results => $results, |
46
|
|
|
|
|
|
|
}; |
47
|
16
|
100
|
|
|
|
424
|
my $rendered = $self->{template} ? $tx->render_string($self->{template}, $vars) |
48
|
|
|
|
|
|
|
: $tx->render('document.json.tx', $vars); |
49
|
16
|
|
|
|
|
77630
|
print $fh $rendered; |
50
|
16
|
|
|
|
|
1913
|
close $fh; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__DATA__ |