Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<refentry id="{@id}">
2
 <refnamediv>
3
  <refname>Documentable PHP Elements</refname>
4
  <refpurpose>Elements of PHP source that phpDocumentor can automatically document</refpurpose>
5
 </refnamediv>
6
 <refsynopsisdiv>
7
  <authorgroup>
8
   <author>
9
    Joshua Eichorn
10
    <authorblurb>
11
     {@link mailto:jeichorn@phpdoc.org jeichorn@phpdoc.org}
12
    </authorblurb>
13
   </author>
14
   <author>
15
    Gregory Beaver
16
    <authorblurb>
17
     {@link mailto:cellog@php.net cellog@php.net}
18
    </authorblurb>
19
   </author>
20
  </authorgroup>
21
 </refsynopsisdiv>
22
 {@toc}
23
 <refsect1 id="{@id intro}">
24
  <title>Introduction to Documentable Elements</title>
25
  <para>phpDocumentor is capable of automatically documenting include statements, define statements, functions, procedural pages, classes, class variables, and class methods.</para>
26
 </refsect1>
27
 <refsect1 id="{@id procedural}">
28
  <title>Procedural Elements</title>
29
  <para>From phpDocumentor's perspective, the basic container for procedural elements (as in real life) is the file that contains them.  To reflect this, it is possible to document information about the entire contents of a file.  This is accomplished through the use of a page-level DocBlock (see {@tutorial phpDocumentor.howto.pkg#basics.docblock} for basic information on what a DocBlock is).  A page-level DocBlock is the only DocBlock that cannot precede the element that it is documenting, as there is no way to precede a file.  To solve this issue, the way phpDocumentor finds a page-level DocBlock is to parse the first DocBlock in a file as the page-level DocBlock, with certain conditions.</para>
30
  <para>
31
   <programlisting role="php">
32
   <![CDATA[
33
<?php
34
/**
35
 * Page-level DocBlock
36
 */
37
define('oops','Page-level DocBlock it is not!');
38
?>
39
   ]]>
40
   </programlisting>
41
  </para>
42
  <para>This last example has one DocBlock, and it is the first DocBlock in a file, but it is not a Page-level DocBlock.  How can phpDocumentor tell the difference between a Page-level DocBlock and any other DocBlock?  Simple:</para>
43
  <para>
44
   <programlisting role="php">
45
   <![CDATA[
46
<?php
47
/**
48
 * Pretend this is a file
49
 *
50
 * Page-level DocBlock is here because it is the first DocBlock
51
 * in the file, and contains a @package tag
52
 * @package pagepackage
53
 */
54
define("almost","Now the Page-level DocBlock is for the page, and the Define has no docblock");?>
55
   ]]>
56
   </programlisting>
57
  </para>
58
  <para>In phpDocumentor version 1.2.2, a Page-level DocBlock is the first DocBlock in a file if it contains a {@tutorial tags.package.pkg} tag.  However, this example will raise a warning like <screen>WARNING in test.php on line 8: Page-level DocBlock precedes "define almost", use another DocBlock to document the source element</screen>.  You can eliminate the warning by adding documentation to the define as follows:</para>
59
  <para>
60
   <programlisting role="php">
61
   <![CDATA[
62
<?php
63
/**
64
 * Page-level DocBlock
65
 * @package pagepackage
66
 */
67
/**
68
 * Define DocBlock
69
 */
70
define("ahhhh","Now the Page-level DocBlock is for the page, and the Define DocBlock for the define");
71
?>
72
   ]]>
73
   </programlisting>
74
  </para>
75
  <para>Now, the page has its documentation, and the define has its own documentation.</para>
76
  <para>So, a DocBlock is a page-level DocBlock IF AND ONLY IF it is both:
77
   <orderedlist>
78
    <listitem><para>The first DocBlock in a file</para></listitem>
79
    <listitem><para>One of:
80
     <unorderedlist>
81
      <listitem><para>Contains a {@tutorial tags.package.pkg} tag</para></listitem>
82
      <listitem><para>Immediately followed by another DocBlock for any documentable PHP element <emphasis>this is deprecated, always use a @package tag</emphasis></para></listitem>
83
     </unorderedlist>
84
    </para></listitem>
85
   </orderedlist>
86
  </para>
87
  <para>A Page-level DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tags:
88
   <itemizedlist>
89
    <listitem><para>{@tutorial tags.package.pkg}</para></listitem>
90
    <listitem><para>{@tutorial tags.subpackage.pkg}</para></listitem>
91
   </itemizedlist>
92
  </para>
93
  <caution>phpDocumentor will not document a file like the first example, there must be at least one documentable PHP element in the file.</caution>
94
  <refsect2 id="{@id include}">
95
   <title>include/require/include_once/require_once statements</title>
96
   <para>phpDocumentor extracts the filename and attempts to link to documentation for that filename if possible.  Include statements may only have any of the {@tutorial tags.pkg#manual.standard}</para>
97
   <para>phpDocumentor will attempt to locate the included file in the list of files parsed, and if found will make a link to that file's documentation.</para>
98
  </refsect2>
99
  <refsect2 id="{@id define}">
100
   <title>define statements</title>
101
   <para>A define statement's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tag:
102
    <itemizedlist>
103
     <listitem><para>{@tutorial tags.name.pkg}</para></listitem>
104
    </itemizedlist>
105
   </para>
106
  </refsect2>
107
  <refsect2 id="{@id function}">
108
   <title>function declarations</title>
109
   <para>A function's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tags:
110
    <itemizedlist>
111
     <listitem><para>{@tutorial tags.global.pkg}</para></listitem>
112
     <listitem><para>{@tutorial tags.param.pkg}</para></listitem>
113
     <listitem><para>{@tutorial tags.return.pkg}</para></listitem>
114
     <listitem><para>{@tutorial tags.staticvar.pkg}</para></listitem>
115
     <listitem><para>{@tutorial tags.inlinesource.pkg}</para></listitem>
116
    </itemizedlist>
117
   </para>
118
  </refsect2>
119
  <refsect2 id="{@id global}">
120
   <title>global variables</title>
121
   <para>A global variable's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tag:
122
    <itemizedlist>
123
     <listitem><para>{@tutorial tags.name.pkg}</para></listitem>
124
    </itemizedlist>
125
    In addition, the global variable's DocBlock <emphasis>must</emphasis> contain the {@tutorial tags.global.pkg} tag.
126
   </para>
127
  </refsect2>
128
 </refsect1>
129
 <refsect1 id="{@id class}">
130
  <title>Class Elements</title>
131
  <para>A class's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tags:
132
   <itemizedlist>
133
    <listitem><para>{@tutorial tags.package.pkg}</para></listitem>
134
    <listitem><para>{@tutorial tags.subpackage.pkg}</para></listitem>
135
    <listitem><para>{@tutorial tags.static.pkg}</para></listitem>
136
   </itemizedlist>
137
  </para>
138
  <refsect2 id="{@id inheritance}">
139
   <title>DocBlock inheritance</title>
140
   <para>New in version 1.2.0, DocBlock's are inherited by child classes, variables, and methods.  There are a few simple rules for inheritance:
141
    <itemizedlist>
142
     <listitem><para>tags {@tutorial tags.author.pkg}, {@tutorial tags.version.pkg}, and {@tutorial tags.copyright.pkg} are automatically inherited unless explicitly specified in the DocBlock</para></listitem>
143
     <listitem><para>As in previous versions, {@tutorial tags.package.pkg} and {@tutorial tags.subpackage.pkg} are inherited unless explicitly specified in the DocBlock.  We recommend that you explicitly use @package and @subpackage for every class to avoid problems with name conflicts that may arise</para></listitem>
144
     <listitem><para>If there is no short description, the short description will be inherited.</para></listitem>
145
     <listitem><para>If there is no long description, the long description will be inherited.</para></listitem>
146
     <listitem><para>If there is a long description, and you still want to inherit the parent's description, use {@tutorial tags.inlineinheritdoc.pkg}</para></listitem>
147
    </itemizedlist>
148
   </para>
149
   <para>
150
    <programlisting role="php">
151
    <![CDATA[
152
/**
153
 * short desc
154
 *
155
 * long desc
156
 * @package test
157
 * @author me
158
 * @version 1.0
159
 * @abstract
160
 * @copyright never
161
 */
162
class parclass
163
{
164
}
165
 
166
// inherits entire DocBlock minus @abstract
167
class child1 extends parclass
168
{
169
}
170
 
171
// inherits DocBlock minus @abtract, short desc
172
/**
173
 * overriding short desc
174
 */
175
class child2 extends parclass
176
{
177
}
178
 
179
// inherits @author, @version, @copyright, @package
180
/**
181
 * overriding short desc
182
 *
183
 * overriding long desc
184
 */
185
class child3 extends parclass
186
{
187
}
188
 
189
// inherits @version, @copyright, @package
190
/**
191
 * overriding short desc
192
 *
193
 * overriding long desc
194
 * @author you
195
 */
196
class child4 extends parclass
197
{
198
}
199
    ]]>
200
    </programlisting>
201
   </para>
202
  </refsect2>
203
  <refsect2 id="{@id var}">
204
   <title>class variables</title>
205
   <para>A class variable's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tag:
206
    <itemizedlist>
207
     <listitem><para>{@tutorial tags.var.pkg}</para></listitem>
208
    </itemizedlist>
209
   </para>
210
  </refsect2>
211
  <refsect2 id="{@id method}">
212
   <title>class methods</title>
213
   <para>A method's DocBlock may have any of the standard phpDocumentor Tags (see {@tutorial tags.pkg#manual.standard}) plus the following tags:
214
    <itemizedlist>
215
     <listitem><para>{@tutorial tags.global.pkg}</para></listitem>
216
     <listitem><para>{@tutorial tags.param.pkg}</para></listitem>
217
     <listitem><para>{@tutorial tags.return.pkg}</para></listitem>
218
     <listitem><para>{@tutorial tags.static.pkg}</para></listitem>
219
     <listitem><para>{@tutorial tags.staticvar.pkg}</para></listitem>
220
     <listitem><para>{@tutorial tags.inlinesource.pkg}</para></listitem>
221
    </itemizedlist>
222
   </para>
223
  </refsect2>
224
 </refsect1>
225
</refentry>