=head1 NAME Froody::DocServer =head1 DESCRIPTION Froody::DocServer =head2 Methods =over =cut package Froody::DocServer; use warnings; use strict; use base qw( Froody::Server ); use Encode; use Template; eval q{ use Apache::Constants qw( OK ); }; =item template() returns a TT template for displaying the methods in =cut my $template; { local $/; $template ||= ; } sub template { return $template; } =item get_methods() If you want your own DocServer, override this to return a list of methods to display the docs for. By default, this will return the methods of the default repository. =cut sub get_methods { use Froody::Dispatch; my @methods = grep { $_->full_name !~ /^froody\./ } Froody::Dispatch->new->repository->get_methods; } =item html() returns the HTML version fo the docs, suitable for sending to the user =cut my $tt = Template->new(); sub html { my $class = shift; my @methods = $class->get_methods; my $output; $tt->process( \$template, { methods => \@methods }, \$output ) or die $tt->error; return $output; } sub handler : method { my ($class, $r) = @_; $r->send_http_header("text/html; encoding=utf-8"); $r->print( Encode::encode_utf8($class->html) ); return OK(); } =back =head1 BUGS None known. Please report any bugs you find via the CPAN RT system. L =head1 AUTHOR Copyright Fotango 2005. All rights reserved. Please see the main L documentation for details of who has worked on this project. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L =cut 1; __DATA__ Froody Server Documentation

Methods

Method specifications

[% FOR method IN methods.sort('full_name') %]

» [% method.full_name %]

[% method.description %]

Arguments

[% SET class = 0; SET other_attrib = 0; %] [% FOR arg_name IN method.arguments.keys.sort %] [% SET arg = method.arguments.$arg_name %] [% IF arg %] [% SET class = class + 1 %] [% ELSE %][% SET other_attrib = 1 %][% END %] [% END %] [% IF other_attrib %] [% END %]
name type description required
[% arg_name %] [% arg.type.join(', ') %] [% arg.doc %] [% arg.optional ? "optional" : "required" %]
remaining arguments are passed to the method directly

Example response

[% ( method.example_response.as_xml.render(1) || 'empty response' ) | html %]
  
[% END %]

COPYRIGHT

This document copyright 2006 Fotango