Shodo - Auto-generate documents from HTTP::Request and HTTP::Response
use HTTP::Request::Common; use HTTP::Response; use Shodo; my $shodo = Shodo->new(); my $suzuri = $shodo->new_suzuri('An endpoint method.'); my $req = POST '/entry', [ id => 1, message => 'Hello Shodo' ]; $suzuri->request($req); my $res = HTTP::Response->new(200); $res->content('{ "message" : "success" }'); $suzuri->response($res); print $suzuri->document(); # print document as Markdown format
Shodo generates Web API documents as Markdown format automatically and validates parameters using HTTP::Request/Response.
THIS IS A DEVELOPMENT RELEASE. API MAY CHANGE WITHOUT NOTICE.
my $shodo = Shodo->new( document_root => 'doc' );
Create and return new Shodo object. "document_root" is optional parameter for your document root directory.
$shodo->template($tmpl);
Set custom template.
$shodo->document_root('doc');
Set document root directory.
my $suzuri = $shodo->new_suzuri('This is description.');
Create and return new Suzuri object with the description.
$shodo->stock($suzuri->doc());
Stock text of documents for writing later. The parameter document is anything ok, but Markdown based is recommended.
$shodo->write('output.md');
Write the documentation in stocks to the file and make the stock empty.
$suzuri->request($req);
Set HTTP::Request object.
$suzuri->response($res);
Set HTTP::Response object.
$suzuri->params( category => { isa => 'Str', documentation => 'Category of articles.' }, limit => { isa => 'Int', default => 20, optional => 1, documentation => 'Limitation numbers per page.' }, page => { isa => 'Int', default => 1, optional => 1, documentation => 'Page number you want to get.' } );
Parameters for validation and documentation. These rules are based on Data::Validator's interfaces.
$suzuri->validate($params);
Validate with the rules defined by "params" method. Parameter must be HASH ref.
$suzuri->doc();
Return the Markdown formatted document for Web API.
"autodoc": https://github.com/r7kamura/autodoc
Test::JsonAPI::Autodoc
What is Shodo?: http://en.wikipedia.org/wiki/Shodo
Songmu for naming as "Shodo". It's pretty.
Moznion for making Test::JsonAPI::Autodoc.
Hachioji.pm for advising.
Copyright (C) Yusuke Wada.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Yusuke Wada <yusuke@kamawada.com>
To install Shodo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Shodo
CPAN shell
perl -MCPAN -e shell install Shodo
For more information on module installation, please visit the detailed CPAN module installation guide.