line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::JsonAPI::Autodoc::Markdown; |
2
|
13
|
|
|
13
|
|
74
|
use strict; |
|
13
|
|
|
|
|
28
|
|
|
13
|
|
|
|
|
840
|
|
3
|
13
|
|
|
13
|
|
61
|
use warnings; |
|
13
|
|
|
|
|
24
|
|
|
13
|
|
|
|
|
332
|
|
4
|
13
|
|
|
13
|
|
1081
|
use utf8; |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
104
|
|
5
|
13
|
|
|
13
|
|
18376
|
use Data::Section::Simple; |
|
13
|
|
|
|
|
8273
|
|
|
13
|
|
|
|
|
809
|
|
6
|
13
|
|
|
13
|
|
77242
|
use Time::Piece; |
|
13
|
|
|
|
|
200294
|
|
|
13
|
|
|
|
|
79
|
|
7
|
13
|
|
|
13
|
|
15259
|
use Text::Xslate qw(mark_raw); |
|
13
|
|
|
|
|
197874
|
|
|
13
|
|
|
|
|
1505
|
|
8
|
13
|
|
|
13
|
|
19493
|
use Text::Xslate::Bridge::Star; |
|
13
|
|
|
|
|
34542
|
|
|
13
|
|
|
|
|
385
|
|
9
|
13
|
|
|
13
|
|
18212
|
use Test::JsonAPI::Autodoc::Path; |
|
13
|
|
|
|
|
40
|
|
|
13
|
|
|
|
|
4428
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
13
|
|
|
13
|
0
|
39
|
my ($class, $output_path, $template) = @_; |
13
|
|
|
|
|
|
|
|
14
|
13
|
|
|
|
|
103
|
bless { |
15
|
|
|
|
|
|
|
output_path => $output_path, |
16
|
|
|
|
|
|
|
template => $template, |
17
|
|
|
|
|
|
|
}, $class; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub generate { |
21
|
13
|
|
|
13
|
0
|
35
|
my ($self, $description, $results, $first_time) = @_; |
22
|
|
|
|
|
|
|
|
23
|
13
|
|
|
|
|
198
|
my $document_path = Test::JsonAPI::Autodoc::Path->document_path($self->{output_path}); |
24
|
|
|
|
|
|
|
|
25
|
13
|
|
|
|
|
156
|
my $vpath = Data::Section::Simple->new()->get_data_section(); |
26
|
13
|
|
|
|
|
2948
|
my $tx = Text::Xslate->new( |
27
|
|
|
|
|
|
|
type => 'text', |
28
|
|
|
|
|
|
|
path => [$vpath], |
29
|
|
|
|
|
|
|
module => ['Text::Xslate::Bridge::Star'], |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
13
|
|
|
|
|
9584
|
my $fh; |
33
|
|
|
|
|
|
|
my $generated_at; |
34
|
13
|
100
|
|
|
|
58
|
if ($first_time) { |
35
|
10
|
|
|
|
|
80
|
$fh = $document_path->openw_utf8( { locked => 1 } ); |
36
|
10
|
|
|
|
|
195925
|
$generated_at = localtime->strftime('%Y-%m-%d %H:%M:%S'); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
3
|
|
|
|
|
24
|
$fh = $document_path->opena_utf8( { locked => 1 } ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
13
|
|
|
|
|
3299
|
my $vars = { |
43
|
|
|
|
|
|
|
generated_at => $generated_at, |
44
|
|
|
|
|
|
|
description => $description, |
45
|
|
|
|
|
|
|
results => $results, |
46
|
|
|
|
|
|
|
}; |
47
|
13
|
100
|
|
|
|
372
|
my $rendered = $self->{template} ? $tx->render_string($self->{template}, $vars) |
48
|
|
|
|
|
|
|
: $tx->render('document.json.tx', $vars); |
49
|
13
|
|
|
|
|
124380
|
print $fh $rendered; |
50
|
13
|
|
|
|
|
2602
|
close $fh; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__DATA__ |