| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | Froody::DocServer | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | Froody::DocServer | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head2 Methods | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =over | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =cut | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | package Froody::DocServer; | ||||||||||||||||||||
| 16 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 2 | ▶ | use base qw( Froody::Server ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 2 | ▶ | use Encode; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 2 | ▶ | use Template; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | eval q{ use Apache::Constants qw( OK ); }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | =item template() | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | returns a TT template for displaying the methods in | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | my $template; | |||||||||||||||||||
| 31 | 2 | ▶ | { local $/; $template ||= <DATA>; } | ||||||||||||||||||
|
Condition33%1/3
$template ||= readline DATA
MC/DC0%0/2
$template ||= readline DATA
$template
readline DATA
Truth table33%1/3
A ||= B
A= $templateB= readline DATA
| |||||||||||||||||||||
| 32 | 0 | ▶ | sub template { | ||||||||||||||||||
|
Subroutine
template: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 33 | 0 | return $template; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =item get_methods() | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | If you want your own DocServer, override this to return a list of methods | ||||||||||||||||||||
| 39 | to display the docs for. By default, this will return the methods of the | ||||||||||||||||||||
| 40 | default repository. | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub get_methods { | ||||||||||||||||||
|
Subroutine
get_methods: not called CC=1 SCAR=0.6
Pod
documented
| |||||||||||||||||||||
| 45 | 2 | ▶ | use Froody::Dispatch; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 46 | 0 | my @methods = grep { $_->full_name !~ /^froody\./ } | |||||||||||||||||||
| 47 | Froody::Dispatch->new->repository->get_methods; | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =item html() | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | returns the HTML version fo the docs, suitable for sending to the user | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 2 | my $tt = Template->new(); | |||||||||||||||||||
| 57 | 0 | ▶ | sub html { | ||||||||||||||||||
|
Subroutine
html: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 58 | 0 | my $class = shift; | |||||||||||||||||||
| 59 | 0 | my @methods = $class->get_methods; | |||||||||||||||||||
| 60 | 0 | my $output; | |||||||||||||||||||
| 61 | 0 | ▶ | $tt->process( \$template, { methods => \@methods }, \$output ) or die $tt->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | return $output; | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 0 | ▶ | sub handler : method { | ||||||||||||||||||
|
Subroutine
handler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 66 | 0 | my ($class, $r) = @_; | |||||||||||||||||||
| 67 | 0 | $r->send_http_header("text/html; encoding=utf-8"); | |||||||||||||||||||
| 68 | 0 | $r->print( Encode::encode_utf8($class->html) ); | |||||||||||||||||||
| 69 | 0 | return OK(); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | =back | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =head1 BUGS | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | None known. | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Please report any bugs you find via the CPAN RT system. | ||||||||||||||||||||
| 79 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody> | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | Copyright Fotango 2005. All rights reserved. | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Please see the main L<Froody> documentation for details of who has worked | ||||||||||||||||||||
| 86 | on this project. | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | This module is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 89 | the same terms as Perl itself. | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =head1 SEE ALSO | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | L<Froody>, L<Froody::Request> | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | 2 | 1; | |||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | __DATA__ | ||||||||||||||||||||