=head1 DESCRIPTION
A functor takes a L<LaTeX::TikZ::Set> tree and clones it according to certain rules.
-Rules can apply not only to L<LaTeX::TikZ::Set> objects, but also to the L<LaTeX::TikZ::Mod> objects they contain.
+
+Rules can apply not only to L<LaTeX::TikZ::Set> consumer objects, but also to the L<LaTeX::TikZ::Mod> consumer objects they contain.
+The are stored as L<LaTeX::TikZ::Functor::Rule> objects.
+
+When the functor is called onto a set object, all its associated rules are tried successively, and the handler of the first matching rule is executed with :
+
+=over 4
+
+=item *
+
+the functor object as its first argument ;
+
+=item *
+
+the current set object as its second argument ;
+
+=item *
+
+the arguments passed to the functor itself starting at the third argument.
+
+=back
+
+The handler is expected to return the new set/mod that will in the resulting set tree.
+If the new set is different from the original, then the functor is applied to all the mods of the set, and their cloned version are added to the new set.
+
+If no matching rule is found, the object is returned as-is.
=cut
=head1 SEE ALSO
-L<LaTeX::TikZ>.
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Functor::Rule>.
=head1 AUTHOR
=head1 DESCRIPTION
-A rule specifies how functors should handle a certain kind of set or mod.
+A rule specifies how functors (L<LaTeX::TikZ::Functor> objects) should handle a certain kind of set or mod.
A functor is basically an ordered collection of rules.
=cut
=head2 C<target>
+A class or role name against which set or mod candidates will be matched.
+It must consume either L<LaTeX::TikZ::Set> or L<LaTeX::TikZ::Mod>, directly or through inheritance.
+
=cut
has 'target' => (
=head2 C<handler>
+The code reference executed when the rule handles a given set or mod object.
+It is called with the L<LaTeX::TikZ::Functor> object as its first argument, the set/mod object as its second, and then the arguments passed to the functor itself.
+
=cut
has 'handler' => (
=head2 C<is_role>
+True if and only if the target is a role.
+
=cut
has 'is_role' => (
=head2 C<is_set>
+True when the target does the L<LaTeX::TikZ::Set> role, and false when it does L<LaTeX::TikZ::Mod>.
+
=cut
has 'is_set' => (
=head2 C<< new target => $target, handler => $handler >>
+Constructs a new rule object with target C<$target> and handler C<$handler>.
+
=cut
around 'BUILDARGS' => sub {