Dancer::Plugin::Documentation - register documentation for routes
Version 0.02
Dancer::Plugin::Documentation provides a few keywords to associate documentation with a fully pathed route. This is especially useful when the route path is externally modified by the prefix command. Documentation my be anything from a string to a complex data structure.
Example usage:
package Foo;
use Dancer;
use Dancer::Plugin::Documentation qw{:all};
document_section 'Helpers';
document_route 'Display documentation'
get '/resources' => sub {
status 200;
return join "\n\n",
map {
$_->isa('Dancer::Plugin::Documentation::Section') ? ($_->section, $_->documentation || ()) :
$_->isa('Dancer::Plugin::Documentation::Route') ? ($_->method . ' ' . $_->path, $_->documentation) :
$_->documentation
} documentation;
};
prefix '/v1';
document_section 'Foo', 'Manage your foo';
document_route 'A route to retrieve foo',
get '/foo' => sub { status 200; return 'foo' };
package main;
dance;
Given a documentation argument and a list of routes, associate the documentation with all of the routes.
Given a label, set the section grouping for all subsequent document_route calls. Optionally, supply documentation to associate with the section. Disable the current section by passing undef or the empty string for the label.
Retrieve all documentation for the current app with sections interweaved with routes. Supports all arguments for documentation_for_routes and documentation_for_sections.
Retrieve all route documentation for the current app. Supports all the same arguments as get_route_documentation besides app.
Retrieve all section documentation for the current app. Supports all the same arguments as get_section_documentation besides app.
Retrieve the route documentation for an app in lexicographical order by section, route, then method. Any/all of the following may be supplied to filter the documentation: method, path, section
Retrieve the section documentation for an app in lexicographical order. Any/all of the following may be supplied to filter the documentation: section
Register documentation for the method and route of a particular app.
Register documentation for the section of a particular app.
Get the name of the active section for the application.
Set the name of the active section for the application.
- any
-
The documentation keyword does not work with the any keyword as it does not return the list of registered routes, but rather the number of routes registered. Fixing this behavior will require a patch to Dancer.
- get
-
The get keyword generates both get and head routes. Documentation will be attached to both.
Aaron Cohen, <aarondcohen at gmail.com>
This module was made possible by Shutterstock (@ShutterTech). Additional open source projects from Shutterstock can be found at code.shutterstock.com.
Please report any bugs or feature requests to bug-Dancer-Plugin-Documentation at rt.cpan.org
, or through the web interface at https://github.com/aarondcohen/perl-dancer-plugin-documentation/issues. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Dancer::Plugin::Documentation
You can also look for information at:
Official GitHub Repo
https://github.com/aarondcohen/perl-dancer-plugin-documentation
GitHub's Issue Tracker (report bugs here)
https://github.com/aarondcohen/perl-dancer-plugin-documentation/issues
CPAN Ratings
Official CPAN Page
Copyright 2014 Aaron Cohen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.