1 <?xml version="1.0" encoding="UTF-8"?>
3 <appendix id="doc-standard">
4 <title>Zend Framework Documentation Standard</title>
6 <sect1 id="doc-standard.overview">
7 <title>Overview</title>
9 <sect2 id="doc-standard.overview.scope">
13 This document provides guidelines for creation of the end-user
14 documentation found within Zend Framework. It is intended as a
15 guide to Zend Framework contributors, who must write
16 documentation as part of component contributions, as well as to
17 documentation translators. The standards contained herein are
18 intended to ease translation of documentation, minimize
19 visual and stylistic differences between different documentation
20 files, and make finding changes in documentation easier with
21 <command>diff</command> tools.
25 You may adopt and/or modify these standards in accordance with the terms of our
26 <ulink url="http://framework.zend.com/license">license</ulink>.
30 Topics covered in Zend Framework's documentation standards include documentation
31 file formatting and recommendations for documentation quality.
36 <sect1 id="doc-standard.file-formatting">
37 <title>Documentation File Formatting</title>
39 <sect2 id="doc-standard.file-formatting.xml-tags">
40 <title>XML Tags</title>
43 Each manual file must include the following <acronym>XML</acronym> declarations at
47 <programlisting language="xml"><![CDATA[
48 <?xml version="1.0" encoding="UTF-8"?>
53 <acronym>XML</acronym> files from translated languages must also include a revision
54 tag containing the revision of the corresponding English-language file the
55 translation was based on.
58 <programlisting language="xml"><![CDATA[
59 <?xml version="1.0" encoding="UTF-8"?>
60 <!-- EN-Revision: 14978 -->
65 <sect2 id="doc-standard.file-formatting.max-line-length">
66 <title>Maximum Line Length</title>
69 The maximum line length, including tags, attributes, and indentation, is not to
70 exceed 100 characters. There is only one exception to this rule: attribute and value
71 pairs are allowed to exceed the 100 chars as they are not allowed to be separated.
75 <sect2 id="doc-standard.file-formatting.indentation">
76 <title>Indentation</title>
78 <para>Indentation should consist of 4 spaces. Tabs are not allowed.</para>
79 <para>Tags which are at the same level must have the same indentation.</para>
81 <programlisting language="xml"><![CDATA[
90 Tags which are one level under the previous tag must be indented with 4 additional
94 <programlisting language="xml"><![CDATA[
102 Multiple block tags within the same line are not allowed; multiple inline tags are
106 <programlisting language="xml"><![CDATA[
107 <!-- NOT ALLOWED: -->
113 <classname>Zend_Magic</classname> does not exist. <classname>Zend_Acl</classname> does.
118 <sect2 id="doc-standard.file-formatting.line-termination">
119 <title>Line Termination</title>
122 Line termination follows the Unix text file convention. Lines must end with a
123 single linefeed (LF) character. Linefeed characters are represented as ordinal 10,
128 Note: Do not use carriage returns (<acronym>CR</acronym>) as is the convention in
129 Apple OS's (0x0D) or the carriage return - linefeed combination
130 (<acronym>CRLF</acronym>) as is standard for the Windows OS (0x0D, 0x0A).
134 <sect2 id="doc-standard.file-formatting.empty-tags">
135 <title>Empty tags</title>
138 Empty tags are not allowed; all tags must contain text or child tags.
141 <programlisting language="xml"><![CDATA[
144 Some text. <link></link>
152 <sect2 id="doc-standard.file-formatting.whitespace">
153 <title>Usage of whitespace within documents</title>
155 <sect3 id="doc-standard.file-formatting.whitespace.trailing">
156 <title>Whitespace within tags</title>
159 Opening block tags should have no whitespace immediately following them other
160 than line breaks (and indentation on the following line).
163 <programlisting language="xml"><![CDATA[
170 Opening inline tags should have no whitespace immediately following them.
173 <programlisting language="xml"><![CDATA[
175 This is the class <classname> Zend_Class</classname>.
178 This is the class <classname>Zend_Class</classname>.
182 Closing block tags may be preceded by whitespace equivalent to the current
183 indentation level, but no more than that amount.
186 <programlisting language="xml"><![CDATA[
197 Closing inline tags must not be preceded by any whitespace.
200 <programlisting language="xml"><![CDATA[
202 This is the class <classname>Zend_Class </classname>
205 This is the class <classname>Zend_Class</classname>
209 <sect3 id="doc-standard.file-formatting.whitespace.multiple-line-breaks">
210 <title>Multiple line breaks</title>
213 Multiple line breaks within or between tags are not allowed.
216 <programlisting language="xml"><![CDATA[
241 <sect3 id="doc-standard.file-formatting.whitespace.tag-separation">
242 <title>Separation between tags</title>
245 Tags at the same level must be separated by an empty line to improve
249 <programlisting language="xml"><![CDATA[
269 The first child tag should open directly below its parent, with no empty line
270 between them; the last child tag should close directly before the closing tag of
274 <programlisting language="xml"><![CDATA[
304 <sect2 id="doc-standard.file-formatting.program-listing">
305 <title>Program Listings</title>
308 The opening <emphasis><programlisting></emphasis> tag must indicate the
309 appropriate "language" attribute and be indented at the same level as its sibling
313 <programlisting language="xml"><![CDATA[
314 <para>Sibling paragraph.</para>
316 <programlisting language="php">]]><<![CDATA[![CDATA[
320 <acronym>CDATA</acronym> should be used around all program listings.
324 <emphasis><programlisting></emphasis> sections must not add linebreaks or
325 whitespace at the beginning or end of the section, as these are then represented in
329 <programlisting language="xml"><![CDATA[
331 <programlisting language="php">]]><<![CDATA[![CDATA[
335 ]]]]>><![CDATA[</programlisting>
338 <programlisting language="php">]]><<![CDATA[![CDATA[
340 ]]]]>><![CDATA[</programlisting>
344 Ending <acronym>CDATA</acronym> and <emphasis><programlisting></emphasis>
345 tags should be on the same line, without any indentation.
348 <programlisting language="xml"><![CDATA[
350 <programlisting language="php">]]><<![CDATA[![CDATA[
356 <programlisting language="php">]]><<![CDATA[![CDATA[
358 ]]]]>><![CDATA[</programlisting>
361 <programlisting language="php">]]><<![CDATA[![CDATA[
363 ]]]]>><![CDATA[</programlisting>
367 The <emphasis><programlisting></emphasis> tag should contain the "language"
368 attribute with a value appropriate to the contents of the program listing. Typical
369 values include "css", "html", "ini", "javascript", "php", "text", and "xml".
372 <programlisting language="xml"><![CDATA[
374 <programlisting language="php">]]><<![CDATA[![CDATA[
377 <programlisting language="javascript">]]><<![CDATA[![CDATA[
380 <programlisting language="xml">]]><<![CDATA[![CDATA[
384 For program listings containing only <acronym>PHP</acronym> code,
385 <acronym>PHP</acronym> tags (e.g., "<?php", "?>") are not required, and
386 should not be used. They simply clutter the narrative, and are implied by the use
387 of the <emphasis><programlisting></emphasis> tag.
390 <programlisting language="xml"><![CDATA[
392 <programlisting language="php"]]><<![CDATA[![CDATA[<?php
394 ?>]]]]>><![CDATA[</programlisting>
396 <programlisting language="php"]]><<![CDATA[![CDATA[
400 ]]]]>><![CDATA[</programlisting>
404 Line lengths within program listings should follow the <link
405 linkend="coding-standard.php-file-formatting.max-line-length">coding standards
406 recommendations</link>.
410 Refrain from using <methodname>require_once()</methodname>,
411 <methodname>require()</methodname>, <methodname>include_once()</methodname>, and
412 <methodname>include()</methodname> calls within <acronym>PHP</acronym> listings.
413 They simply clutter the narrative, and are largely obviated when using an
414 autoloader. Use them only when they are essential to the example.
418 <title>Never use short tags</title>
421 Short tags (e.g., "<?", "<?=") should never be used within
422 <emphasis>programlisting</emphasis> or the narrative of a document.
427 <sect2 id="doc-standard.file-formatting.inline-tags">
428 <title>Notes on specific inline tags</title>
430 <sect3 id="doc-standard.file-formatting.inline-tags.classname">
431 <title>classname</title>
434 The tag <emphasis><classname></emphasis> must be used each time a class
435 name is represented by itself; it should not be used when combined with a
436 method name, variable name, or constant, and no other content is allowed within
440 <programlisting language="xml"><![CDATA[
442 The class <classname>Zend_Class</classname>.
447 <sect3 id="doc-standard.file-formatting.inline-tags.varname">
448 <title>varname</title>
451 Variables must be wrapped in the <emphasis><varname></emphasis> tag.
452 Variables must be written using the "$" sigil. No other content is allowed
453 within this tag, unless a class name is used, which indicates a class variable.
456 <programlisting language="xml"><![CDATA[
458 The variable <varname>$var</varname> and the class variable
459 <varname>Zend_Class::$var</varname>.
464 <sect3 id="doc-standard.file-formatting.inline-tags.methodname">
465 <title>methodname</title>
468 Methods must be wrapped in the <emphasis><methodname></emphasis> tag.
469 Methods must either include the full method signature or at the least a pair of
470 closing parentheses (e.g., "()"). No other content is allowed within this tag,
471 unless a class name is used, which indicates a class method.
474 <programlisting language="xml"><![CDATA[
476 The method <methodname>foo()</methodname> and the class method
477 <methodname>Zend_Class::foo()</methodname>. A method with a full signature:
478 <methodname>foo($bar, $baz)</methodname>
483 <sect3 id="doc-standard.file-formatting.inline-tags.constant">
484 <title>constant</title>
487 Use the <emphasis><constant></emphasis> tag when denoting constants.
488 Constants must be written in <acronym>UPPERCASE</acronym>. No other content is
489 allowed within this tag, unless a class name is used, which indicates a class
493 <programlisting language="xml"><![CDATA[
495 The constant <constant>FOO</constant> and the class constant
496 <constant>Zend_Class::FOO</constant>.
501 <sect3 id="doc-standard.file-formatting.inline-tags.filename">
502 <title>filename</title>
505 Filenames and paths must be wrapped in the
506 <emphasis><filename></emphasis> tag. No other content is allowed in this
510 <programlisting language="xml"><![CDATA[
512 The filename <filename>application/Bootstrap.php</filename>.
517 <sect3 id="doc-standard.file-formatting.inline-tags.command">
518 <title>command</title>
521 Commands, shell scripts, and program calls must be wrapped in the
522 <emphasis><command></emphasis> tag. If the command includes arguments,
523 these should also be included within the tag.
526 <programlisting language="xml"><![CDATA[
528 Execute <command>zf.sh create project</command>.
533 <sect3 id="doc-standard.file-formatting.inline-tags.code">
537 Usage of the <emphasis><code></emphasis> tag is discouraged, in favor of
538 the other inline tasks discussed previously.
543 <sect2 id="doc-standard.file-formatting.block-tags">
544 <title>Notes on specific block tags</title>
546 <sect3 id="doc-standard.file-formatting.block-tags.title">
550 The <emphasis><title></emphasis> tag is not allowed to hold other tags.
553 <programlisting language="xml"><![CDATA[
555 <title>Using <classname>Zend_Class</classname></title>
558 <title>Using Zend_Class</title>
564 <sect1 id="doc-standard.recommendations">
565 <title>Recommendations</title>
567 <sect2 id="doc-standard.recommendations.editors">
568 <title>Use editors without autoformatting</title>
571 For editing the documentation, typically you should not use formal
572 <acronym>XML</acronym> editors. Such editors normally autoformat existing documents
573 to fit their own standards and/or do not strictly follow the docbook standard. As
574 examples, we have seen them erase the <acronym>CDATA</acronym> tags, change 4 space
575 separation to tabs or 2 spaces, etc.
579 The style guidelines were written in large part to assist translators in recognizing
580 the lines that have changed using normal <command>diff</command> tools.
581 Autoformatting makes this process more difficult.
585 <sect2 id="doc-standard.recommendations.images">
586 <title>Use Images</title>
589 Good images and diagrams can improve readability and comprehension. Use them
590 whenever they will assist in these goals. Images should be placed in the
591 <filename>documentation/manual/en/figures/</filename> directory, and be named after
592 the section identifier in which they occur.
596 <sect2 id="doc-standard.recommendations.examples">
597 <title>Use Case Examples</title>
600 Look for good use cases submitted by the community, especially those posted in
601 proposal comments or on one of the mailing lists. Examples often illustrate usage
602 far better than the narrative does.
606 When writing your examples for inclusion in the manual, follow
607 all coding standards and documentation standards.
611 <sect2 id="doc-standard.recommendations.phpdoc">
612 <title>Avoid Replicating phpdoc Contents</title>
615 The manual is intended to be a reference guide for end-user usage. Replicating
616 the phpdoc documentation for internal-use components and classes is not wanted, and
617 the narrative should be focussed on usage, not the internal workings. In any case,
618 at this time, we would like the documentation teams to focus on translating the
619 English manual, not the phpdoc comments.
623 <sect2 id="doc-standard.recommendations.links">
624 <title>Use Links</title>
627 Link to other sections of the manual or to external sources
628 instead of recreating documentation.
632 Linking to other sections of the manual may be done using either the
633 <emphasis><xref></emphasis> tag (which will substitute the section title for
634 the link text) or the <emphasis><link></emphasis> tag (to which you must
638 <programlisting language="xml"><![CDATA[
640 "Xref" links to a section: <xref
641 linkend="doc-standard.recommendations.links" />.
645 "Link" links to a section, using descriptive text: <link
646 linkend="doc-standard.recommendations.links">documentation on
652 To link to an external resource, use <emphasis><ulink></emphasis>:
655 <programlisting language="xml"><![CDATA[
657 The <ulink url="http://framework.zend.com/">Zend Framework site</ulink>.