summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-07-18 10:25:47 -0400
committerJesse Luehrs <doy@tozt.net>2013-07-18 10:25:47 -0400
commit12a4bdfabf59bc6051bbd6f65772e830165eb904 (patch)
tree0f0237c2ed8e8bfb005349e492726a869685cd0b
parent3ba1fc133b41eaa8cf3351e07131256fdfdf1f11 (diff)
downloadspreadsheet-template-12a4bdfabf59bc6051bbd6f65772e830165eb904.tar.gz
spreadsheet-template-12a4bdfabf59bc6051bbd6f65772e830165eb904.zip
more docs
-rw-r--r--lib/Spreadsheet/Template/Generator.pm6
-rw-r--r--lib/Spreadsheet/Template/Processor.pm27
-rw-r--r--lib/Spreadsheet/Template/Processor/Identity.pm13
-rw-r--r--lib/Spreadsheet/Template/Processor/Xslate.pm51
-rw-r--r--lib/Spreadsheet/Template/Writer.pm28
-rw-r--r--lib/Spreadsheet/Template/Writer/XLSX.pm13
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<Spreadsheet::Template::Generator::Parser> 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<processor_class> in a L<Spreadsheet::Template> 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<Spreadsheet::Template>. 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<Spreadsheet::Template::Processor>, 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<Spreadsheet::Template::Processor> to run the template
+data through L<Text::Xslate>. 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<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<format> 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<format> 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<formula>,
+for instance) to declare for the cell. C<$type> is optional, and if not passed,
+defaults to C<"string">.
+
+=item true
+
+Returns C<JSON::true>.
+
+=item false
+
+Returns C<JSON::false>.
+
+=back
+
+=cut
+
+=attr syntax
+
+Which Xslate syntax engine to use. Defaults to C<Metakolon>.
+
+=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<writer_class> in a L<Spreadsheet::Template> 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<Spreadsheet::Template>) 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<Spreadsheet::Template::Writer>, allowing you to
+generate XLSX files.
+
+=cut
+
sub excel_class { 'Excel::Writer::XLSX' }
__PACKAGE__->meta->make_immutable;