line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::JsonAPI::Autodoc::Markdown; |
2
|
14
|
|
|
14
|
|
53
|
use strict; |
|
14
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
502
|
|
3
|
14
|
|
|
14
|
|
52
|
use warnings; |
|
14
|
|
|
|
|
13
|
|
|
14
|
|
|
|
|
315
|
|
4
|
14
|
|
|
14
|
|
537
|
use utf8; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
83
|
|
5
|
14
|
|
|
14
|
|
6226
|
use Data::Section::Simple; |
|
14
|
|
|
|
|
6163
|
|
|
14
|
|
|
|
|
581
|
|
6
|
14
|
|
|
14
|
|
7739
|
use Time::Piece; |
|
14
|
|
|
|
|
91753
|
|
|
14
|
|
|
|
|
56
|
|
7
|
14
|
|
|
14
|
|
8335
|
use Text::Xslate qw(mark_raw); |
|
14
|
|
|
|
|
106002
|
|
|
14
|
|
|
|
|
871
|
|
8
|
14
|
|
|
14
|
|
6837
|
use Text::Xslate::Bridge::Star; |
|
14
|
|
|
|
|
20863
|
|
|
14
|
|
|
|
|
373
|
|
9
|
14
|
|
|
14
|
|
5208
|
use Test::JsonAPI::Autodoc::Path; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
3162
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
14
|
|
|
14
|
0
|
31
|
my ($class, $output_path, $template) = @_; |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
|
|
89
|
bless { |
15
|
|
|
|
|
|
|
output_path => $output_path, |
16
|
|
|
|
|
|
|
template => $template, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate { |
21
|
14
|
|
|
14
|
0
|
27
|
my ($self, $description, $results, $first_time) = @_; |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
145
|
my $document_path = Test::JsonAPI::Autodoc::Path->document_path($self->{output_path}); |
24
|
|
|
|
|
|
|
|
25
|
14
|
|
|
|
|
136
|
my $vpath = Data::Section::Simple->new()->get_data_section(); |
26
|
14
|
|
|
|
|
2380
|
my $tx = Text::Xslate->new( |
27
|
|
|
|
|
|
|
type => 'text', |
28
|
|
|
|
|
|
|
path => [$vpath], |
29
|
|
|
|
|
|
|
module => ['Text::Xslate::Bridge::Star'], |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
14
|
|
|
|
|
8100
|
my $fh; |
33
|
|
|
|
|
|
|
my $generated_at; |
34
|
14
|
100
|
|
|
|
45
|
if ($first_time) { |
35
|
11
|
|
|
|
|
74
|
$fh = $document_path->openw_utf8( { locked => 1 } ); |
36
|
11
|
|
|
|
|
113186
|
$generated_at = localtime->strftime('%Y-%m-%d %H:%M:%S'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
14
|
$fh = $document_path->opena_utf8( { locked => 1 } ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
14
|
|
|
|
|
2473
|
my $vars = { |
43
|
|
|
|
|
|
|
generated_at => $generated_at, |
44
|
|
|
|
|
|
|
description => $description, |
45
|
|
|
|
|
|
|
results => $results, |
46
|
|
|
|
|
|
|
}; |
47
|
14
|
100
|
|
|
|
302
|
my $rendered = $self->{template} ? $tx->render_string($self->{template}, $vars) |
48
|
|
|
|
|
|
|
: $tx->render('document.json.tx', $vars); |
49
|
14
|
|
|
|
|
192177
|
print $fh $rendered; |
50
|
14
|
|
|
|
|
1748
|
close $fh; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__DATA__ |