4 DBIx::Class::Manual::Reading - How to read and write DBIx::Class POD.
8 This doc should help users to understand how the examples and
9 documentation found in the L<DBIx::Class> distribution can be
12 Writers of DBIx::Class POD should also check here to make sure their
13 additions are consistent with the rest of the documentation.
17 Methods should be documented in the files which also contain the code
18 for the method, or that file should be hidden from PAUSE completely,
19 in which case the methods are documented in the file which loads
20 it. Methods may also be documented and referred to in files
21 representing the major objects or components on which they can be
24 For example, L<DBIx::Class::Relationship> documents the methods
25 actually coded in the helper relationship classes like
26 DBIx::Class::Relationship::BelongsTo. The BelongsTo file itself is
27 hidden from PAUSE as it has no documentation. The accessors created by
28 relationships should be mentioned in L<DBIx::Class::Row>, the major
29 object that they will be called on.
31 =head2 Method documentation
37 Each method starts with a "head2" statement of its name.
39 Just the plain method name, not an example of how to call it, or a link.
40 This is to ensure easy linking to method documentation from other POD.
44 The header is followed by a two-item list. This contains a description
45 of the arguments the method is expected to take, and an indication of
46 what the method returns.
48 The first item provides a list of all possible values for the
49 arguments of the method in order, separated by C<, >, preceded by the
52 Example (for the belongs_to relationship):
54 =item Arguments: $accessor_name, $related_class, $fk_column|\%cond|\@cond?, \%attr?
56 The following possible argument sigils can be shown:
62 $var - A scalar (string or numeric) variable.
66 \%var - A variable containing reference to a hash.
70 \@var - A variable containing a reference to an array.
74 \$var - A variable containing a reference to a scalar variable.
78 %var - A hashref variable (list of key/value pairs) - rarely used in DBIx::Class.
80 Reading an argument as a hash variable will consume all subsequent
81 method arguments, use with caution.
85 @var - An array variable (list of values).
87 Reading an argument as a array variable will consume all subsequent
88 method arguments, use with caution.
92 L<$obj|DBIx::Class> - Reference to the source class or object definition
94 All arguments and return values should provide a link to the object's
95 class documentation or definition, even if it's the same class as the current
96 documentation. For example:
98 ## Correct, if stated within DBIx::Class::ResultSet
101 ## Correct, if stated outside DBIx::Class::ResultSet
102 L<$resultset|DBIx::Class::ResultSet>
106 ? - Optional, should be placed after the argument type and name.
109 \%myhashref|\@myarrayref?
112 \%myhashref?|\@myarrayref
114 Applies to the entire argument.
116 Optional arguments can be left out of method calls, unless the caller
117 needs to pass in any of the following arguments. In which case the
118 caller should pass C<undef> in place of the missing argument.
122 | - Alternate argument content types.
124 At least one of these must be supplied unless the argument is also
129 The second item starts with the text "Return Value:". The remainder of
130 the line is either the text "not defined" or a variable with a descriptive
134 =item Return Value: not defined
135 =item Return Value: L<$schema|DBIx::Class::Schema>
136 =item Return Value: $classname
139 =item Return Value: The names
141 "not defined" means the method does not deliberately return a value, and
142 the caller should not use or rely on anything it does return. (Perl
143 functions always return something, usually the result of the last code
144 statement, if there is no explicit return statement.) This is different
145 than specifying "undef", which means that it explicitly returns undef,
146 though usually this is used an alternate return (like C<$obj | undef>).
150 The argument/return list is followed by a single paragraph describing what
155 The description paragraph is followed by another list. Each item in
156 the list explains one of the possible argument/type combinations.
158 This list may be omitted if the author feels that the variable names are
159 self-explanatory enough to not require it. Use best judgement.
163 The argument/return list is followed by some examples of how to use the
164 method, using its various types of arguments.
166 The examples can also include ways to use the results if
167 applicable. For instance, if the documentation is for a relationship
168 type, the examples can include how to call the resulting relation
169 accessor, how to use the relation name in a search and so on.
171 If some of the examples assume default values, these should be shown
172 with and without the actual arguments, with hints about the equivalent
175 The example should be followed by one or more paragraphs explaining
178 Examples and explaining paragraphs can be repeated as necessary.
182 =head1 FURTHER QUESTIONS?
184 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
186 =head1 COPYRIGHT AND LICENSE
188 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
189 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
190 redistribute it and/or modify it under the same terms as the
191 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.