]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/commitdiff
First cut at the documentation
authorVincent Pit <vince@profvince.com>
Thu, 22 Jul 2010 22:31:18 +0000 (00:31 +0200)
committerVincent Pit <vince@profvince.com>
Thu, 22 Jul 2010 22:33:10 +0000 (00:33 +0200)
20 files changed:
lib/LaTeX/TikZ.pm
lib/LaTeX/TikZ/Formatter.pm
lib/LaTeX/TikZ/Functor.pm
lib/LaTeX/TikZ/Interface.pm
lib/LaTeX/TikZ/Meta/TypeConstraint/Autocoerce.pm
lib/LaTeX/TikZ/Mod.pm
lib/LaTeX/TikZ/Point.pm
lib/LaTeX/TikZ/Scope.pm
lib/LaTeX/TikZ/Set.pm
lib/LaTeX/TikZ/Set/Circle.pm
lib/LaTeX/TikZ/Set/Line.pm
lib/LaTeX/TikZ/Set/Mutable.pm
lib/LaTeX/TikZ/Set/Op.pm
lib/LaTeX/TikZ/Set/Path.pm
lib/LaTeX/TikZ/Set/Point.pm
lib/LaTeX/TikZ/Set/Polyline.pm
lib/LaTeX/TikZ/Set/Raw.pm
lib/LaTeX/TikZ/Set/Rectangle.pm
lib/LaTeX/TikZ/Set/Sequence.pm
lib/LaTeX/TikZ/Tools.pm

index fc0c0940f33cc1aa7bb72552b9d35c9278a06b01..a7546719e7a89c37dc205b022a78c6ac71f6785d 100644 (file)
@@ -15,6 +15,44 @@ Version 0.01
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
+=head1 SYNOPSIS
+
+    use LaTeX::TikZ;
+
+    # A couple of lines
+    my $hline = Tikz->line(-1 => 1);
+    my $vline = Tikz->line([ 0, -1 ] => [ 0, -1 ]);
+
+    # Paint them in red
+    $_->mod(Tikz->color('red')) for $hline, $vline;
+
+    # An octogon
+    use Math::Complex;
+    my $octo = Tikz->closed_polyline(
+     map Math::Complex->emake(1, ($_ * pi)/4), 0 .. 7
+    );
+
+    # Only keep a portion of it
+    $octo->clip(Tikz->rectangle(-0.5*(1+i), 2*(1+i)));
+
+    # Fill it with dots
+    $octo->mod(Tikz->pattern(class => 'Dots'));
+
+    # Create a formatter object
+    my $tikz = Tikz->formatter;
+
+    # Put those objects all together and print them
+    my $seq = Tikz->seq($octo, $hline, $vline);
+    my ($head, $decl, $body) = $tikz->render($seq);
+    print "$_\n" for map @$_, $head, $decl, $body;
+
+=head1 DESCRIPTION
+
+This module provides an object model for TikZ, a graphical tookit for LaTeX.
+It allows you to build structures representing geometrical figures, apply a wide set of modifiers on them, transform them globally with functors, and print them in the context of an existing TeX document.
+
+=cut
+
 use LaTeX::TikZ::Interface;
 
 sub import {
 use LaTeX::TikZ::Interface;
 
 sub import {
@@ -40,6 +78,10 @@ sub import {
  return;
 }
 
  return;
 }
 
+=head1 SEE ALSO
+
+PGF/TikZ - L<http://pgf.sourceforge.net>.
+
 =head1 AUTHOR
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
 =head1 AUTHOR
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
index efa7dc6ed1da9c6558a18a02940163bdaa3d55b7..426263f16a517c434e7c2920fb58865c39fa99a9 100644 (file)
@@ -15,6 +15,12 @@ Version 0.01
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
+=head1 DESCRIPTION
+
+A formatter object turns a L<LaTeX::TikZ::Set> tree into the actual TikZ code, depending on some parameters such as the scale, the unit or the origin.
+
+=cut
+
 use Sub::Name ();
 
 use LaTeX::TikZ::Point;
 use Sub::Name ();
 
 use LaTeX::TikZ::Point;
@@ -26,40 +32,72 @@ use LaTeX::TikZ::Tools;
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
+=head1 ATTRIBUTES
+
+=head2 C<unit>
+
+=cut
+
 has 'unit' => (
  is      => 'ro',
  isa     => enum([ qw/cm pt/ ]),
  default => 'cm',
 );
 
 has 'unit' => (
  is      => 'ro',
  isa     => enum([ qw/cm pt/ ]),
  default => 'cm',
 );
 
+=head2 C<format>
+
+=cut
+
 has 'format' => (
  is      => 'ro',
  isa     => 'Str',
  default => '%s',
 );
 
 has 'format' => (
  is      => 'ro',
  isa     => 'Str',
  default => '%s',
 );
 
+=head2 C<scale>
+
+=cut
+
 has 'scale' => (
  is      => 'rw',
  isa     => 'Num',
  default => 1,
 );
 
 has 'scale' => (
  is      => 'rw',
  isa     => 'Num',
  default => 1,
 );
 
+=head2 C<width>
+
+=cut
+
 has 'width' => (
  is  => 'rw',
  isa => 'Maybe[Num]',
 );
 
 has 'width' => (
  is  => 'rw',
  isa => 'Maybe[Num]',
 );
 
+=head2 C<height>
+
+=cut
+
 has 'height' => (
  is  => 'rw',
  isa => 'Maybe[Num]',
 );
 
 has 'height' => (
  is  => 'rw',
  isa => 'Maybe[Num]',
 );
 
+=head2 C<origin>
+
+=cut
+
 has 'origin' => (
  is     => 'rw',
  isa    => 'LaTeX::TikZ::Point::Autocoerce',
  coerce => 1,
 );
 
 has 'origin' => (
  is     => 'rw',
  isa    => 'LaTeX::TikZ::Point::Autocoerce',
  coerce => 1,
 );
 
+=head1 METHODS
+
+=head2 C<id>
+
+=cut
+
 sub id {
  my $tikz = shift;
 
 sub id {
  my $tikz = shift;
 
@@ -76,6 +114,10 @@ sub id {
  } map($tikz->$_, qw/unit format scale width height/), $origin;
 }
 
  } map($tikz->$_, qw/unit format scale width height/), $origin;
 }
 
+=head2 C<render>
+
+=cut
+
 my $find_mods = do {
  our %seen;
 
 my $find_mods = do {
  our %seen;
 
@@ -183,6 +225,10 @@ sub render {
  return \@header, \@decls, @bodies;
 }
 
  return \@header, \@decls, @bodies;
 }
 
+=head2 C<len>
+
+=cut
+
 sub len {
  my ($tikz, $len) = @_;
 
 sub len {
  my ($tikz, $len) = @_;
 
@@ -191,6 +237,10 @@ sub len {
  sprintf $tikz->format . $tikz->unit, $len * $tikz->scale;
 }
 
  sprintf $tikz->format . $tikz->unit, $len * $tikz->scale;
 }
 
+=head2 C<angle>
+
+=cut
+
 sub angle {
  my ($tikz, $a) = @_;
 
 sub angle {
  my ($tikz, $a) = @_;
 
@@ -201,6 +251,10 @@ sub angle {
  sprintf $tikz->format, POSIX::ceil($a);
 }
 
  sprintf $tikz->format, POSIX::ceil($a);
 }
 
+=head2 C<label>
+
+=cut
+
 sub label {
  my ($tikz, $name, $pos) = @_;
 
 sub label {
  my ($tikz, $name, $pos) = @_;
 
@@ -209,6 +263,10 @@ sub label {
  "node[scale=$scale,$pos] {$name}";
 }
 
  "node[scale=$scale,$pos] {$name}";
 }
 
+=head2 C<thickness>
+
+=cut
+
 sub thickness {
  my ($tikz, $width) = @_;
 
 sub thickness {
  my ($tikz, $width) = @_;
 
index 8c97432f2c57e1f7df9712b6cced21c4ffff30ef..344816438038170d7a7f5668f9929fc14b67ade9 100644 (file)
@@ -15,6 +15,12 @@ Version 0.01
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
+=head1 DESCRIPTION
+
+A functor takes a L<LaTeX::TikZ::Set> tree and clones it according to certain rules.
+
+=cut
+
 use Carp ();
 
 use Sub::Name ();
 use Carp ();
 
 use Sub::Name ();
@@ -76,6 +82,12 @@ BEGIN {
  });
 }
 
  });
 }
 
+=head1 METHODS
+
+=head2 C<default_rule>
+
+=cut
+
 sub default_rule {
  shift;
 
 sub default_rule {
  shift;
 
@@ -84,6 +96,10 @@ sub default_rule {
  $insert_rule->($rule, $rule->[2] ? \@default_set_rules : \@default_mod_rules);
 }
 
  $insert_rule->($rule, $rule->[2] ? \@default_set_rules : \@default_mod_rules);
 }
 
+=head2 C<< new rules => [ $class_name => sub { ... }, ... ] >>
+
+=cut
+
 sub new {
  my ($class, %args) = @_;
 
 sub new {
  my ($class, %args) = @_;
 
index adf63f90802f2a2d5ee44fbe5d1779ed4cf0b207..ef78fa8b1644abb7765861bb95699028f21d0a05 100644 (file)
@@ -17,6 +17,14 @@ our $VERSION = '0.01';
 
 use Sub::Name ();
 
 
 use Sub::Name ();
 
+=head1 METHODS
+
+=head2 C<< register $keyword => $code >>
+
+Registers C<$code> to be available with C<< Tikz->$keyword >>.
+
+=cut
+
 sub register {
  shift;
 
 sub register {
  shift;
 
@@ -49,6 +57,12 @@ sub register {
  return;
 }
 
  return;
 }
 
+=head2 C<load>
+
+Load all the modules of the L<LaTeX::TikZ> official suite that register a keyword in the interface.
+
+=cut
+
 sub load {
  require LaTeX::TikZ::Formatter;      # formatter
  require LaTeX::TikZ::Functor;        # functor
 sub load {
  require LaTeX::TikZ::Formatter;      # formatter
  require LaTeX::TikZ::Functor;        # functor
index 9cc2322913697542f680313b7c9bba6aeba995dc..521a473b67c083524d503c32a6e5e40820a14ea6 100644 (file)
@@ -21,23 +21,41 @@ use Any::Moose;
 
 extends any_moose('Meta::TypeConstraint');
 
 
 extends any_moose('Meta::TypeConstraint');
 
+=head1 ATTRIBUTES
+
+=head2 C<mapper>
+
+=cut
+
 has 'mapper' => (
  is  => 'ro',
  isa => 'CodeRef',
 );
 
 has 'mapper' => (
  is  => 'ro',
  isa => 'CodeRef',
 );
 
+=head2 C<parent_name>
+
+=cut
+
 has 'parent_name' => (
  is       => 'ro',
  isa      => 'ClassName',
  required => 1,
 );
 
 has 'parent_name' => (
  is       => 'ro',
  isa      => 'ClassName',
  required => 1,
 );
 
+=head2 C<user_constraint>
+
+=cut
+
 has 'user_constraint' => (
  is       => 'ro',
  isa      => 'Maybe[CodeRef]',
  required => 1,
 );
 
 has 'user_constraint' => (
  is       => 'ro',
  isa      => 'Maybe[CodeRef]',
  required => 1,
 );
 
+=head1 METHODS
+
+=cut
+
 around 'new' => sub {
  my ($orig, $class, %args) = @_;
 
 around 'new' => sub {
  my ($orig, $class, %args) = @_;
 
@@ -67,6 +85,10 @@ around 'new' => sub {
  $tc = $class->$orig(%args);
 };
 
  $tc = $class->$orig(%args);
 };
 
+=head2 C<load>
+
+=cut
+
 sub load {
  my ($tc, $thing) = @_;
 
 sub load {
  my ($tc, $thing) = @_;
 
index b5921e9bcd3199d79b662e84a1481804e56af81c..87cec117c14162236baeeff5f8dbf6ca6811f994 100644 (file)
@@ -15,9 +15,41 @@ Version 0.01
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
+=head1 DESCRIPTION
+
+This role should be consumed by all the modifier classes.
+
+=cut
+
 use Any::Moose 'Role';
 use Any::Moose 'Util::TypeConstraints';
 
 use Any::Moose 'Role';
 use Any::Moose 'Util::TypeConstraints';
 
+=head1 METHODS
+
+These methods are required by the interface :
+
+=over 4
+
+=item *
+
+C<tag>
+
+=item *
+
+C<cover>
+
+=item *
+
+C<declare>
+
+=item *
+
+C<apply>
+
+=back
+
+=cut
+
 requires qw(
  tag
  cover
 requires qw(
  tag
  cover
index 316624860c33e0ad95985437b176ccd3af609edb..7fa3fa1076b0a61a8689284df875aaea90856c32 100644 (file)
@@ -24,12 +24,26 @@ use Any::Moose 'Util::TypeConstraints' => [ qw/
  register_type_constraint
 / ];
 
  register_type_constraint
 / ];
 
+=head1 ATTRIBUTES
+
+=head2 C<x>
+
+The abscissa of the point.
+
+=cut
+
 has 'x' => (
  is       => 'ro',
  isa      => 'Num',
  required => 1,
 );
 
 has 'x' => (
  is       => 'ro',
  isa      => 'Num',
  required => 1,
 );
 
+=head2 C<y>
+
+The ordinate of the point.
+
+=cut
+
 has 'y' => (
  is       => 'ro',
  isa      => 'Num',
 has 'y' => (
  is       => 'ro',
  isa      => 'Num',
index 3686beb28b5e7f73d4b5302524f41b8d317b7fb8..e973adc20d6baa6af64b81c16fe6cc0b2b45b9f4 100644 (file)
@@ -21,6 +21,12 @@ use LaTeX::TikZ::Tools;
 
 use Any::Moose;
 
 
 use Any::Moose;
 
+=head1 ATTRIBUTES
+
+=head2 C<mods>
+
+=cut
+
 has '_mods' => (
  is       => 'ro',
  isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Mod::Formatted]]',
 has '_mods' => (
  is       => 'ro',
  isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Mod::Formatted]]',
@@ -37,6 +43,10 @@ has '_mods_cache' => (
  default  => sub { +{ } },
 );
 
  default  => sub { +{ } },
 );
 
+=head2 C<body>
+
+=cut
+
 has '_body' => (
  is       => 'rw',
  isa      => 'LaTeX::TikZ::Scope|ArrayRef[Str]',
 has '_body' => (
  is       => 'rw',
  isa      => 'LaTeX::TikZ::Scope|ArrayRef[Str]',
@@ -48,6 +58,12 @@ my $ltmf_tc  = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Formatted'
 my $_body_tc = __PACKAGE__->meta->find_attribute_by_name('_body')
                                 ->type_constraint;
 
 my $_body_tc = __PACKAGE__->meta->find_attribute_by_name('_body')
                                 ->type_constraint;
 
+=head1 METHODS
+
+=head2 C<mod>
+
+=cut
+
 sub mod {
  my $scope = shift;
 
 sub mod {
  my $scope = shift;
 
@@ -65,6 +81,10 @@ sub mod {
  $scope;
 }
 
  $scope;
 }
 
+=head2 C<body>
+
+=cut
+
 sub body {
  my $scope = shift;
 
 sub body {
  my $scope = shift;
 
@@ -80,6 +100,10 @@ use overload (
  '@{}' => 'dereference',
 );
 
  '@{}' => 'dereference',
 );
 
+=head2 C<flatten>
+
+=cut
+
 sub flatten {
  my ($scope) = @_;
 
 sub flatten {
  my ($scope) = @_;
 
@@ -114,6 +138,10 @@ my $inter = Sub::Name::subname('inter' => sub {
  return \@left, \@common, \@right;
 });
 
  return \@left, \@common, \@right;
 });
 
+=head2 C<instantiate>
+
+=cut
+
 sub instantiate {
  my ($scope) = @_;
 
 sub instantiate {
  my ($scope) = @_;
 
@@ -164,8 +192,16 @@ sub instantiate {
  return @body;
 }
 
  return @body;
 }
 
+=head2 C<dereference>
+
+=cut
+
 sub dereference { [ $_[0]->instantiate ] }
 
 sub dereference { [ $_[0]->instantiate ] }
 
+=head2 C<fold>
+
+=cut
+
 sub fold {
  my ($left, $right, $rev) = @_;
 
 sub fold {
  my ($left, $right, $rev) = @_;
 
index e0886cb1bdd04560ea125857d5e774c20acde08b..505dfec1a823712e0ce06477ed39a186d4416a5c 100644 (file)
@@ -23,9 +23,13 @@ use LaTeX::TikZ::Tools;
 
 use Any::Moose 'Role';
 
 
 use Any::Moose 'Role';
 
-requires qw(
- draw
-);
+=head1 ATTRIBUTES
+
+=head2 C<mods>
+
+Returns the list of the L<LaTeX::TikZ::Mod> objects associated with the current set.
+
+=cut
 
 has '_mods' => (
  is       => 'ro',
 
 has '_mods' => (
  is       => 'ro',
@@ -37,6 +41,30 @@ has '_mods' => (
 
 sub mods { @{$_[0]->_mods} }
 
 
 sub mods { @{$_[0]->_mods} }
 
+=head1 METHODS
+
+This method is required by the interface :
+
+=over 4
+
+=item *
+
+C<draw>
+
+=back
+
+=cut
+
+requires qw(
+ draw
+);
+
+=head2 C<mod @mods>
+
+Apply the given list of L<LaTeX::TikZ::Mod> objects to the current set.
+
+=cut
+
 my $ltm_tc  = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod');
 my $ltml_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Layer');
 my $ltmc_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Clip');
 my $ltm_tc  = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod');
 my $ltml_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Layer');
 my $ltmc_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Mod::Clip');
@@ -110,6 +138,13 @@ MOD:
  };
 }
 
  };
 }
 
+=head2 C<layer $layer>
+
+Puts the current set in the corresponding layer.
+This is a shortcut for C<< $set->mod(Tikz->layer($layer)) >>.
+
+=cut
+
 sub layer {
  return $_[0] unless @_ > 1;
 
 sub layer {
  return $_[0] unless @_ > 1;
 
@@ -121,6 +156,13 @@ sub layer {
  )
 }
 
  )
 }
 
+=head2 C<clip $path>
+
+Clips the current set by the path given by C<$path>.
+This is a shortcut for C<< $set->mod(Tikz->clip($path)) >>.
+
+=cut
+
 sub clip {
  return $_[0] unless @_ > 1;
 
 sub clip {
  return $_[0] unless @_ > 1;
 
index 8efdd9841155eb25a12275eac0522ab9a368bd49..c035562cad6fbe0d5505fec979dd8e25c634796a 100644 (file)
@@ -25,8 +25,22 @@ use LaTeX::TikZ::Tools;
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 with 'LaTeX::TikZ::Set::Op';
 
+=head1 ATTRIBUTES
+
+=head2 C<center>
+
+A L<LaTeX::TikZ::Set::Point> object describing the center of the circle.
+
+=cut
+
 has 'center' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
 has 'center' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
@@ -34,12 +48,24 @@ has 'center' => (
  coerce   => 1,
 );
 
  coerce   => 1,
 );
 
+=head2 C<radius>
+
+The radius of the circle as a non-negative real number.
+
+=cut
+
 has 'radius' => (
  is       => 'ro',
  isa      => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) > 0 }),
  required => 1,
 );
 
 has 'radius' => (
  is       => 'ro',
  isa      => subtype('Num' => where { LaTeX::TikZ::Tools::numcmp($_, 0) > 0 }),
  required => 1,
 );
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path {
  my $set  = shift;
  my $tikz = $_[0];
 sub path {
  my $set  = shift;
  my $tikz = $_[0];
index ffe5975c89a27be0db00f3ec03860b0903fb1829..bf41d14ac24fcfedbb30e20560765df3897726ff 100644 (file)
@@ -22,8 +22,22 @@ use LaTeX::TikZ::Functor;
 
 use Any::Moose;
 
 
 use Any::Moose;
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 with 'LaTeX::TikZ::Set::Op';
 
+=head1 ATTRIBUTES
+
+=head2 C<from>
+
+The first endpoint of the line, as a L<LaTeX::TikZ::Set::Point> object.
+
+=cut
+
 has 'from' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
 has 'from' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
@@ -31,6 +45,12 @@ has 'from' => (
  coerce   => 1,
 );
 
  coerce   => 1,
 );
 
+=head2 C<to>
+
+The second endpoint of the line, also as a L<LaTeX::TikZ::Set::Point> object.
+
+=cut
+
 has 'to' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
 has 'to' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
@@ -38,6 +58,12 @@ has 'to' => (
  coerce   => 1,
 );
 
  coerce   => 1,
 );
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path {
  my $set = shift;
 
 sub path {
  my $set = shift;
 
index c6e21434e65e9a3bcf0e3500d3dfb24ae045334c..863a56156d24af3b605a6559e8c83f40a7d2a686 100644 (file)
@@ -11,12 +11,31 @@ LaTeX::TikZ::Set::Mutable - A role for set objects that can be appended to.
 
 Version 0.01
 
 
 Version 0.01
 
+=head1 DESCRIPTION
+
+L<LaTeX::TikZ::Set> objects that are mutable consume this role.
+This forces them to implement an C<add> method describing how more elements can be added to the set.
+
 =cut
 
 our $VERSION = '0.01';
 
 use Any::Moose 'Role';
 
 =cut
 
 our $VERSION = '0.01';
 
 use Any::Moose 'Role';
 
+=head1 METHODS
+
+This method is required by the interface :
+
+=over 4
+
+=item *
+
+C<add>
+
+=back
+
+=cut
+
 requires qw(
  add
 );
 requires qw(
  add
 );
index f37fdc87e6fa860853d49fa2d3a9efebc45002fc..c7b6b57bebe97a9b0f8f83dc8069c686269f2d5b 100644 (file)
@@ -15,14 +15,46 @@ Version 0.01
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
+=head1 DESCRIPTION
+
+Ops are the components of a path.
+They can be built together to form a path.
+Thus, they are all the elements against which we can call the C<path> method.
+
+=cut
+
 use Any::Moose 'Role';
 
 use Any::Moose 'Role';
 
+=head1 RELATIONSHIPS
+
+This role consumes the L<LaTeX::TikZ::Set> role, and as such implements the L</draw> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set';
 
 with 'LaTeX::TikZ::Set';
 
+=head1 METHODS
+
+This method is required by the interface :
+
+=over 4
+
+=item *
+
+C<path>
+
+=back
+
+=cut
+
 requires qw(
  path
 );
 
 requires qw(
  path
 );
 
+=head2 C<draw>
+
+=cut
+
 sub draw {
  my $set = shift;
 
 sub draw {
  my $set = shift;
 
index 5a9e59c283432bd5b814cb52fc4b28fd15ba22a9..7a8793d1232e9cd82167e273d2c3dbe74bd9d8de 100644 (file)
@@ -22,11 +22,25 @@ use Any::Moose;
 use Any::Moose 'Util::TypeConstraints'
                => [ qw/subtype as where find_type_constraint/ ];
 
 use Any::Moose 'Util::TypeConstraints'
                => [ qw/subtype as where find_type_constraint/ ];
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> and L<LaTeX::TikZ::Set::Mutable> roles, and as such implements the L</path> and L</add> methods.
+
+=cut
+
 with qw(
  LaTeX::TikZ::Set::Op
  LaTeX::TikZ::Set::Mutable
 );
 
 with qw(
  LaTeX::TikZ::Set::Op
  LaTeX::TikZ::Set::Mutable
 );
 
+=head1 ATTRIBUTES
+
+=head2 C<ops>
+
+The L<LaTeX::TikZ::Set::Op> objects that from the path.
+
+=cut
+
 subtype 'LaTeX::TikZ::Set::Path::Elements'
      => as 'Object'
      => where { $_->does('LaTeX::TikZ::Set::Op') };
 subtype 'LaTeX::TikZ::Set::Path::Elements'
      => as 'Object'
      => where { $_->does('LaTeX::TikZ::Set::Op') };
@@ -40,6 +54,12 @@ has '_ops' => (
 
 sub ops { @{$_[0]->_ops} }
 
 
 sub ops { @{$_[0]->_ops} }
 
+=head1 METHODS
+
+=head2 C<add>
+
+=cut
+
 my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements');
 
 sub add {
 my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements');
 
 sub add {
@@ -52,6 +72,10 @@ sub add {
  $set;
 }
 
  $set;
 }
 
+=head2 C<path>
+
+=cut
+
 sub path {
  my $set = shift;
 
 sub path {
  my $set = shift;
 
index b45adaf41411a21415fcba9a9966bb977c1b940c..b226fd41ec6b0efed1ce2bfdf54277fae09d7198 100644 (file)
@@ -23,8 +23,22 @@ use LaTeX::TikZ::Functor;
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 with 'LaTeX::TikZ::Set::Op';
 
+=head1 ATTRIBUTES
+
+=head2 C<point>
+
+The L<LaTeX::TikZ::Point> object representing the underlying geometrical point.
+
+=cut
+
 has 'point' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Point::Autocoerce',
 has 'point' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Point::Autocoerce',
@@ -33,12 +47,24 @@ has 'point' => (
  handles  => [ qw/x y/ ],
 );
 
  handles  => [ qw/x y/ ],
 );
 
+=head2 C<label>
+
+An optional label for the point.
+
+=cut
+
 has 'label' => (
  is      => 'rw',
  isa     => 'Maybe[Str]',
  default => undef,
 );
 
 has 'label' => (
  is      => 'rw',
  isa     => 'Maybe[Str]',
  default => undef,
 );
 
+=head2 C<pos>
+
+The position of the label around the point.
+
+=cut
+
 enum 'LaTeX::TikZ::Set::Point::Positions' => (
  'below left',
  'below',
 enum 'LaTeX::TikZ::Set::Point::Positions' => (
  'below left',
  'below',
@@ -63,6 +89,12 @@ coerce 'LaTeX::TikZ::Point::Autocoerce'
     => from 'LaTeX::TikZ::Set::Point'
     => via { $_->point };
 
     => from 'LaTeX::TikZ::Set::Point'
     => via { $_->point };
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path {
  my ($set, $tikz) = @_;
 
 sub path {
  my ($set, $tikz) = @_;
 
index 705cac313083fdb4e13a9a86fb2e4a7230910204..e1172eb36b0f25590138aca3e33d04fcaf0a679f 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 =head1 NAME
 
 
 =head1 NAME
 
-LaTeX::TikZ::Set::Polyline - A set object representing a line.
+LaTeX::TikZ::Set::Polyline - A set object representing a possibly closed path composed of contiguous lines.
 
 =head1 VERSION
 
 
 =head1 VERSION
 
@@ -23,6 +23,12 @@ use LaTeX::TikZ::Functor;
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
 use Any::Moose;
 use Any::Moose 'Util::TypeConstraints';
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 subtype 'LaTeX::TikZ::Set::Polyline::Vertices'
 with 'LaTeX::TikZ::Set::Op';
 
 subtype 'LaTeX::TikZ::Set::Polyline::Vertices'
@@ -34,6 +40,14 @@ coerce 'LaTeX::TikZ::Set::Polyline::Vertices'
     => from 'ArrayRef[Any]'
     => via { [ map LaTeX::TikZ::Set::Point->new(point => $_), @$_ ] };
 
     => from 'ArrayRef[Any]'
     => via { [ map LaTeX::TikZ::Set::Point->new(point => $_), @$_ ] };
 
+=head1 ATTRIBUTES
+
+=head2 C<points>
+
+The list of the successive vertices of the path.
+
+=cut
+
 has '_points' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Polyline::Vertices',
 has '_points' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Polyline::Vertices',
@@ -44,12 +58,24 @@ has '_points' => (
 
 sub points { @{$_[0]->_points} }
 
 
 sub points { @{$_[0]->_points} }
 
+=head2 C<closed>
+
+A boolean that indicates whether the path is closed or not.
+
+=cut
+
 has 'closed' => (
  is      => 'ro',
  isa     => 'Bool',
  default => 0,
 );
 
 has 'closed' => (
  is      => 'ro',
  isa     => 'Bool',
  default => 0,
 );
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path {
  my $set = shift;
 
 sub path {
  my $set = shift;
 
index 46d8da165906ce1c86840677c679941537e3587b..ee61e8f0612b66dcf05ca77b356f1842db567ec1 100644 (file)
@@ -20,14 +20,34 @@ use LaTeX::TikZ::Functor;
 
 use Any::Moose;
 
 
 use Any::Moose;
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 with 'LaTeX::TikZ::Set::Op';
 
+=head1 ATTRIBUTES
+
+=head2 C<content>
+
+The bare string the raw mod is made of.
+
+=cut
+
 has 'content' => (
  is       => 'ro',
  isa      => 'Str',
  required => 1,
 );
 
 has 'content' => (
  is       => 'ro',
  isa      => 'Str',
  required => 1,
 );
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path { $_[0]->content }
 
 LaTeX::TikZ::Interface->register(
 sub path { $_[0]->content }
 
 LaTeX::TikZ::Interface->register(
index 5c20fa8e95a0a769d3c84ce9cbfd085fa66ba3b9..3d11cc57a5aaf1f514edfdf18d2cd626ab00453b 100644 (file)
@@ -22,8 +22,22 @@ use LaTeX::TikZ::Functor;
 
 use Any::Moose;
 
 
 use Any::Moose;
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
+
+=cut
+
 with 'LaTeX::TikZ::Set::Op';
 
 with 'LaTeX::TikZ::Set::Op';
 
+=head1 ATTRIBUTES
+
+=head2 C<from>
+
+The first corner of the rectangle, as a L<LaTeX::TikZ::Set::Point> object.
+
+=cut
+
 has 'from' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
 has 'from' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
@@ -31,6 +45,12 @@ has 'from' => (
  coerce   => 1,
 );
 
  coerce   => 1,
 );
 
+=head2 C<to>
+
+The opposite endpoint of the rectangle, also as a L<LaTeX::TikZ::Set::Point> object.
+
+=cut
+
 has 'to' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
 has 'to' => (
  is       => 'ro',
  isa      => 'LaTeX::TikZ::Set::Point',
@@ -38,16 +58,34 @@ has 'to' => (
  coerce   => 1,
 );
 
  coerce   => 1,
 );
 
+=head2 C<width>
+
+The algebraic width of the rectangle.
+
+=cut
+
 has 'width' => (
  is  => 'ro',
  isa => 'Num',
 );
 
 has 'width' => (
  is  => 'ro',
  isa => 'Num',
 );
 
+=head2 C<height>
+
+The algebraic height of the rectangle.
+
+=cut
+
 has 'height' => (
  is  => 'ro',
  isa => 'Num',
 );
 
 has 'height' => (
  is  => 'ro',
  isa => 'Num',
 );
 
+=head1 METHODS
+
+=head2 C<path>
+
+=cut
+
 sub path {
  my $set = shift;
 
 sub path {
  my $set = shift;
 
index 0bf9222d28e1e0f38a30b45959aeb0ee219e6b68..ca7143f8e3f1bce3a26cf5664409a7489660d080 100644 (file)
@@ -26,6 +26,12 @@ use Any::Moose;
 use Any::Moose 'Util::TypeConstraints'
                => [ qw/subtype as where find_type_constraint/ ];
 
 use Any::Moose 'Util::TypeConstraints'
                => [ qw/subtype as where find_type_constraint/ ];
 
+=head1 RELATIONSHIPS
+
+This class consumes the L<LaTeX::TikZ::Set> and L<LaTeX::TikZ::Set::Mutable> roles, and as such implements the L</draw> and L</add> methods.
+
+=cut
+
 with qw(
  LaTeX::TikZ::Set
  LaTeX::TikZ::Set::Mutable
 with qw(
  LaTeX::TikZ::Set
  LaTeX::TikZ::Set::Mutable
@@ -38,6 +44,14 @@ subtype 'LaTeX::TikZ::Set::Sequence::Elements'
           or $_->isa('LaTeX::TikZ::Set::Sequence')
      };
 
           or $_->isa('LaTeX::TikZ::Set::Sequence')
      };
 
+=head1 ATTRIBUTES
+
+=head2 C<kids>
+
+The L<LaTeX::TikZ::Set::Op> or L<LaTeX::TikZ::Set::Sequence> objects that from the sequence.
+
+=cut
+
 has '_kids' => (
  is       => 'ro',
  isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Sequence::Elements]]',
 has '_kids' => (
  is       => 'ro',
  isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Sequence::Elements]]',
@@ -47,6 +61,12 @@ has '_kids' => (
 
 sub kids { @{$_[0]->_kids} }
 
 
 sub kids { @{$_[0]->_kids} }
 
+=head1 METHODS
+
+=head2 C<add>
+
+=cut
+
 my $ltsse_tc = find_type_constraint('LaTeX::TikZ::Set::Sequence::Elements');
 
 sub add {
 my $ltsse_tc = find_type_constraint('LaTeX::TikZ::Set::Sequence::Elements');
 
 sub add {
@@ -59,6 +79,10 @@ sub add {
  $set;
 }
 
  $set;
 }
 
+=head2 C<draw>
+
+=cut
+
 sub draw {
  my $set = shift;
 
 sub draw {
  my $set = shift;
 
index 9a33324ea1dce4eb933e5f40b62b54088b5a5724..6a45fe427545a520c353aab9dd4b9373f2041948 100644 (file)
@@ -17,18 +17,44 @@ our $VERSION = '0.01';
 
 use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ];
 
 
 use Any::Moose 'Util::TypeConstraints' => [ 'find_type_constraint' ];
 
+=head1 CONSTANTS
+
+=head2 C<EPS>
+
+=cut
+
 use constant EPS => 1e-10;
 
 use constant EPS => 1e-10;
 
+=head1 FUNCTIONS
+
+=head2 C<numeq>
+
+=cut
+
 sub numeq { abs($_[0] - $_[1]) < EPS }
 
 sub numeq { abs($_[0] - $_[1]) < EPS }
 
+=head2 C<numcmp>
+
+=cut
+
 sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 }
 
 sub numcmp { $_[0] < $_[1] - EPS ? -1 : $_[0] > $_[1] + EPS ? 1 : 0 }
 
+=head2 C<numround>
+
+=cut
+
 sub numround {
  my $x = $_[0];
  my $i = int $x;
  $x + EPS < $i + 0.5 ? $i : $i + 1;
 }
 
 sub numround {
  my $x = $_[0];
  my $i = int $x;
  $x + EPS < $i + 0.5 ? $i : $i + 1;
 }
 
+=head2 C<type_constraint $class>
+
+Find the type constraint for C<$class> by loading the relevant F<.pm> file beforehand.
+
+=cut
+
 sub type_constraint {
  my ($class) = @_;
 
 sub type_constraint {
  my ($class) = @_;