blib/lib/Plack/App/APISchema/Document.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 52 CC 1 SCAR 6.9
CC
1
Cov
0%
call
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Plack::App::APISchema::Document;
2 use strict;
3 use warnings;
4 use parent qw(Plack::Component);
5 use Plack::Util::Accessor qw(schema);
6 use Text::Markdown::Hoedown qw(markdown);
7 use Text::MicroTemplate qw(encoded_string);
8 use Text::MicroTemplate::DataSection qw(render_mt);
9 use Encode qw(encode_utf8);
10  
11 use APISchema::Generator::Markdown;
12  
13 sub call {
14 my ($self, $env) = @_;
15  
16 my $generator = APISchema::Generator::Markdown->new;
17 my $markdown = $generator->format_schema($self->schema);
18  
19 my $body = markdown(
20 $markdown,
21 extensions => int(
22 0
23 | Text::Markdown::Hoedown::HOEDOWN_EXT_TABLES
24 | Text::Markdown::Hoedown::HOEDOWN_EXT_AUTOLINK
25 | Text::Markdown::Hoedown::HOEDOWN_EXT_FENCED_CODE
26 | Text::Markdown::Hoedown::HOEDOWN_EXT_NO_INTRA_EMPHASIS
27 )
28 );
29  
30 my $renderer = Text::MicroTemplate::DataSection->new;
31 my $title = $self->schema->title || '';
32 my $html = render_mt('template.mt', $title, $body);
33  
34 return [200, ['Content-Type' => 'text/html; charset=utf-8'], [encode_utf8 $html]];
35 }
36  
37 1;
38 __DATA__