From 12a4bdfabf59bc6051bbd6f65772e830165eb904 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 18 Jul 2013 10:25:47 -0400 Subject: more docs --- lib/Spreadsheet/Template/Generator.pm | 6 --- lib/Spreadsheet/Template/Processor.pm | 27 ++++++++++++++ lib/Spreadsheet/Template/Processor/Identity.pm | 13 +++++++ lib/Spreadsheet/Template/Processor/Xslate.pm | 51 ++++++++++++++++++++++++++ lib/Spreadsheet/Template/Writer.pm | 28 ++++++++++++++ lib/Spreadsheet/Template/Writer/XLSX.pm | 13 +++++++ 6 files changed, 132 insertions(+), 6 deletions(-) diff --git a/lib/Spreadsheet/Template/Generator.pm b/lib/Spreadsheet/Template/Generator.pm index 79282d7..f4bf2c6 100644 --- a/lib/Spreadsheet/Template/Generator.pm +++ b/lib/Spreadsheet/Template/Generator.pm @@ -48,12 +48,6 @@ has parser_options => ( default => sub { {} }, ); -=attr parser - -The L instance that will be used. - -=cut - has parser => ( is => 'ro', does => 'Spreadsheet::Template::Generator::Parser', diff --git a/lib/Spreadsheet/Template/Processor.pm b/lib/Spreadsheet/Template/Processor.pm index 9808476..8532fea 100644 --- a/lib/Spreadsheet/Template/Processor.pm +++ b/lib/Spreadsheet/Template/Processor.pm @@ -4,6 +4,33 @@ use Moose::Role; requires 'process'; +=head1 SYNOPSIS + + package MyProcessor; + use Moose; + + with 'Spreadsheet::Template::Processor'; + + sub process { + # ... + } + +=head1 DESCRIPTION + +This role should be consumed by any class which will be used as the +C in a L instance. + +=cut + +=method process($contents, $vars) + +This method is required to be implemented by any classes which consume this +role. It should take the contents of the template and return a JSON file as +described in L. This typically just means running it +through a template engine of some kind. + +=cut + no Moose::Role; 1; diff --git a/lib/Spreadsheet/Template/Processor/Identity.pm b/lib/Spreadsheet/Template/Processor/Identity.pm index e01b835..5a47b10 100644 --- a/lib/Spreadsheet/Template/Processor/Identity.pm +++ b/lib/Spreadsheet/Template/Processor/Identity.pm @@ -4,6 +4,19 @@ use Moose; with 'Spreadsheet::Template::Processor'; +=head1 SYNOPSIS + + my $template = Spreadsheet::Template->new( + processor_class => 'Spreadsheet::Template::Processor::Identity', + ); + +=head1 DESCRIPTION + +This class implements L, and just passes +through the JSON data without modification. + +=cut + sub process { my $self = shift; my ($contents, $vars) = @_; diff --git a/lib/Spreadsheet/Template/Processor/Xslate.pm b/lib/Spreadsheet/Template/Processor/Xslate.pm index b6551ac..34e4ebf 100644 --- a/lib/Spreadsheet/Template/Processor/Xslate.pm +++ b/lib/Spreadsheet/Template/Processor/Xslate.pm @@ -6,6 +6,57 @@ use Text::Xslate; with 'Spreadsheet::Template::Processor'; +=head1 SYNOPSIS + + my $template = Spreadsheet::Template->new( + processor_class => 'Spreadsheet::Template::Processor::Xslate', + processor_options => { + syntax => 'TTerse' + }, + ); + +=head1 DESCRIPTION + +This class implements L to run the template +data through L. In addition to allowing you to use the provided +variables, it also provides some convenience macros to use when writing your +templates: + +=over 4 + +=item format($name, $options) + +Declares a named format, which can be used with the C helper. C<$name> is +the name to use for the format, and C<$options> is a hashref to use as the +value for the C entry in the cell. + +=item c($contents, $format, $type, %args) + +Returns the representation of a cell. C<$contents> is the cell contents, +C<$format> is either the name of a format declared with the C helper, +or a hashref of format options, C<$type> is either C<"string">, C<"number">, or +C<"date_time">, and C<%args> contains any other parameters (such as C, +for instance) to declare for the cell. C<$type> is optional, and if not passed, +defaults to C<"string">. + +=item true + +Returns C. + +=item false + +Returns C. + +=back + +=cut + +=attr syntax + +Which Xslate syntax engine to use. Defaults to C. + +=cut + has syntax => ( is => 'ro', isa => 'Str', diff --git a/lib/Spreadsheet/Template/Writer.pm b/lib/Spreadsheet/Template/Writer.pm index d81ef3b..4bf41ee 100644 --- a/lib/Spreadsheet/Template/Writer.pm +++ b/lib/Spreadsheet/Template/Writer.pm @@ -4,6 +4,34 @@ use Moose::Role; requires 'write'; +=head1 SYNOPSIS + + package MyWriter; + use Moose; + + with 'Spreadsheet::Template::Writer'; + + sub write { + # ... + } + +=head1 DESCRIPTION + +This role should be consumed by any class which will be used as the +C in a L instance. + +=cut + +=method write($data) + +This method is required to be implemented by any classes which consume this +role. It should use the data in C<$data> (in the format described in +L) to create a new spreadsheet file containing that +data. It should return a string containing the binary contents of the +spreadsheet file. + +=cut + no Moose::Role; 1; diff --git a/lib/Spreadsheet/Template/Writer/XLSX.pm b/lib/Spreadsheet/Template/Writer/XLSX.pm index 2b58777..680e103 100644 --- a/lib/Spreadsheet/Template/Writer/XLSX.pm +++ b/lib/Spreadsheet/Template/Writer/XLSX.pm @@ -4,6 +4,19 @@ use Moose; with 'Spreadsheet::Template::Writer::Excel'; +=head1 SYNOPSIS + + my $template = Spreadsheet::Template->new( + writer_class => 'Spreadsheet::Template::Writer::XLSX', + ); + +=head1 DESCRIPTION + +This class implements L, allowing you to +generate XLSX files. + +=cut + sub excel_class { 'Excel::Writer::XLSX' } __PACKAGE__->meta->make_immutable; -- cgit v1.2.3-54-g00ecf