documentation-standard.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <appendix id="doc-standard">
  4. <title>Zend Framework Documentation Standard</title>
  5. <sect1 id="doc-standard.overview">
  6. <title>Overview</title>
  7. <sect2 id="doc-standard.overview.scope">
  8. <title>Scope</title>
  9. <para>
  10. This document provides guidelines for creation of the end-user
  11. documentation found within Zend Framework. It is intended as a
  12. guide to Zend Framework contributors, who must write
  13. documentation as part of component contributions, as well as to
  14. documentation translators. The standards contained herein are
  15. intended to ease translation of documentation, minimize
  16. visual and stylistic differences between different documentation
  17. files, and make finding changes in documentation easier with
  18. <command>diff</command> tools.
  19. </para>
  20. <para>
  21. You may adopt and/or modify these standards in accordance with the terms of our
  22. <ulink url="http://framework.zend.com/license">license</ulink>.
  23. </para>
  24. <para>
  25. Topics covered in Zend Framework's documentation standards include documentation
  26. file formatting and recommendations for documentation quality.
  27. </para>
  28. </sect2>
  29. </sect1>
  30. <sect1 id="doc-standard.file-formatting">
  31. <title>Documentation File Formatting</title>
  32. <sect2 id="doc-standard.file-formatting.xml-tags">
  33. <title>XML Tags</title>
  34. <para>
  35. Each manual file must include the following <acronym>XML</acronym> declarations at
  36. the top of the file:
  37. </para>
  38. <programlisting language="xml"><![CDATA[
  39. <?xml version="1.0" encoding="UTF-8"?>
  40. <!-- Reviewed: no -->
  41. ]]></programlisting>
  42. <para>
  43. <acronym>XML</acronym> files from translated languages must also include a revision
  44. tag containing the revision of the corresponding English-language file the
  45. translation was based on.
  46. </para>
  47. <programlisting language="xml"><![CDATA[
  48. <?xml version="1.0" encoding="UTF-8"?>
  49. <!-- EN-Revision: 14978 -->
  50. <!-- Reviewed: no -->
  51. ]]></programlisting>
  52. </sect2>
  53. <sect2 id="doc-standard.file-formatting.max-line-length">
  54. <title>Maximum Line Length</title>
  55. <para>
  56. The maximum line length, including tags, attributes, and indentation, is not to
  57. exceed 100 characters. There is only one exception to this rule: attribute and value
  58. pairs are allowed to exceed the 100 chars as they are not allowed to be separated.
  59. </para>
  60. </sect2>
  61. <sect2 id="doc-standard.file-formatting.indentation">
  62. <title>Indentation</title>
  63. <para>Indentation should consist of 4 spaces. Tabs are not allowed.</para>
  64. <para>Tags which are at the same level must have the same indentation.</para>
  65. <programlisting language="xml"><![CDATA[
  66. <sect1>
  67. </sect1>
  68. <sect1>
  69. </sect1>
  70. ]]></programlisting>
  71. <para>
  72. Tags which are one level under the previous tag must be indented with 4 additional
  73. spaces.
  74. </para>
  75. <programlisting language="xml"><![CDATA[
  76. <sect1>
  77. <sect2>
  78. </sect2>
  79. </sect1>
  80. ]]></programlisting>
  81. <para>
  82. Multiple block tags within the same line are not allowed; multiple inline tags are
  83. allowed, however.
  84. </para>
  85. <programlisting language="xml"><![CDATA[
  86. <!-- NOT ALLOWED: -->
  87. <sect1><sect2>
  88. </sect2></sect1>
  89. <!-- ALLOWED -->
  90. <para>
  91. <classname>Zend_Magic</classname> does not exist. <classname>Zend_Acl</classname> does.
  92. </para>
  93. ]]></programlisting>
  94. </sect2>
  95. <sect2 id="doc-standard.file-formatting.line-termination">
  96. <title>Line Termination</title>
  97. <para>
  98. Line termination follows the Unix text file convention. Lines must end with a
  99. single linefeed (LF) character. Linefeed characters are represented as ordinal 10,
  100. or hexadecimal 0x0A.
  101. </para>
  102. <para>
  103. Note: Do not use carriage returns (<acronym>CR</acronym>) as is the convention in
  104. Apple OS's (0x0D) or the carriage return - linefeed combination
  105. (<acronym>CRLF</acronym>) as is standard for the Windows OS (0x0D, 0x0A).
  106. </para>
  107. </sect2>
  108. <sect2 id="doc-standard.file-formatting.empty-tags">
  109. <title>Empty tags</title>
  110. <para>
  111. Empty tags are not allowed; all tags must contain text or child tags.
  112. </para>
  113. <programlisting language="xml"><![CDATA[
  114. <!-- NOT ALLOWED -->
  115. <para>
  116. Some text. <link></link>
  117. </para>
  118. <para>
  119. </para>
  120. ]]></programlisting>
  121. </sect2>
  122. <sect2 id="doc-standard.file-formatting.whitespace">
  123. <title>Usage of whitespace within documents</title>
  124. <sect3 id="doc-standard.file-formatting.whitespace.trailing">
  125. <title>Whitespace within tags</title>
  126. <para>
  127. Opening block tags should have no whitespace immediately following them other
  128. than line breaks (and indentation on the following line).
  129. </para>
  130. <programlisting language="xml"><![CDATA[
  131. <!-- NOT ALLOWED -->
  132. <sect1>WHITESPACE
  133. </sect1>
  134. ]]></programlisting>
  135. <para>
  136. Opening inline tags should have no whitespace immediately following them.
  137. </para>
  138. <programlisting language="xml"><![CDATA[
  139. <!-- NOT ALLOWED -->
  140. This is the class <classname> Zend_Class</classname>.
  141. <!-- OK -->
  142. This is the class <classname>Zend_Class</classname>.
  143. ]]></programlisting>
  144. <para>
  145. Closing block tags may be preceded by whitespace equivalent to the current
  146. indentation level, but no more than that amount.
  147. </para>
  148. <programlisting language="xml"><![CDATA[
  149. <!-- NOT ALLOWED -->
  150. <sect1>
  151. </sect1>
  152. <!-- OK -->
  153. <sect1>
  154. </sect1>
  155. ]]></programlisting>
  156. <para>
  157. Closing inline tags must not be preceded by any whitespace.
  158. </para>
  159. <programlisting language="xml"><![CDATA[
  160. <!-- NOT ALLOWED -->
  161. This is the class <classname>Zend_Class </classname>
  162. <!-- OK -->
  163. This is the class <classname>Zend_Class</classname>
  164. ]]></programlisting>
  165. </sect3>
  166. <sect3 id="doc-standard.file-formatting.whitespace.multiple-line-breaks">
  167. <title>Multiple line breaks</title>
  168. <para>
  169. Multiple line breaks within or between tags are not allowed.
  170. </para>
  171. <programlisting language="xml"><![CDATA[
  172. <!-- NOT ALLOWED -->
  173. <para>
  174. Some text...
  175. ... and more text
  176. </para>
  177. <para>
  178. Another paragraph.
  179. </para>
  180. <!-- OK -->
  181. <para>
  182. Some text...
  183. ... and more text
  184. </para>
  185. <para>
  186. Another paragraph.
  187. </para>
  188. ]]></programlisting>
  189. </sect3>
  190. <sect3 id="doc-standard.file-formatting.whitespace.tag-separation">
  191. <title>Separation between tags</title>
  192. <para>
  193. Tags at the same level must be separated by an empty line to improve
  194. readability.
  195. </para>
  196. <programlisting language="xml"><![CDATA[
  197. <!-- NOT ALLOWED -->
  198. <para>
  199. Some text...
  200. </para>
  201. <para>
  202. More text...
  203. </para>
  204. <!-- OK -->
  205. <para>
  206. Some text...
  207. </para>
  208. <para>
  209. More text...
  210. </para>
  211. ]]></programlisting>
  212. <para>
  213. The first child tag should open directly below its parent, with no empty line
  214. between them; the last child tag should close directly before the closing tag of
  215. its parent.
  216. </para>
  217. <programlisting language="xml"><![CDATA[
  218. <!-- NOT ALLOWED -->
  219. <sect1>
  220. <sect2>
  221. </sect2>
  222. <sect2>
  223. </sect2>
  224. <sect2>
  225. </sect2>
  226. </sect1>
  227. <!-- OK -->
  228. <sect1>
  229. <sect2>
  230. </sect2>
  231. <sect2>
  232. </sect2>
  233. <sect2>
  234. </sect2>
  235. </sect1>
  236. ]]></programlisting>
  237. </sect3>
  238. </sect2>
  239. <sect2 id="doc-standard.file-formatting.program-listing">
  240. <title>Program Listings</title>
  241. <para>
  242. The opening <emphasis>&lt;programlisting&gt;</emphasis> tag must indicate the
  243. appropriate "language" attribute and be indented at the same level as its sibling
  244. blocks.
  245. </para>
  246. <programlisting language="xml"><![CDATA[
  247. <para>Sibling paragraph.</para>
  248. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  249. ]]></programlisting>
  250. <para>
  251. <acronym>CDATA</acronym> should be used around all program listings.
  252. </para>
  253. <para>
  254. <emphasis>&lt;programlisting&gt;</emphasis> sections must not add linebreaks or
  255. whitespace at the beginning or end of the section, as these are then represented in
  256. the final output.
  257. </para>
  258. <programlisting language="xml"><![CDATA[
  259. <!-- NOT ALLOWED -->
  260. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  261. $render = "xxx";
  262. ]]]]>&gt;<![CDATA[</programlisting>
  263. <!-- OK -->
  264. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  265. $render = "xxx";
  266. ]]]]>&gt;<![CDATA[</programlisting>
  267. ]]></programlisting>
  268. <para>
  269. Ending <acronym>CDATA</acronym> and <emphasis>&lt;programlisting&gt;</emphasis>
  270. tags should be on the same line, without any indentation.
  271. </para>
  272. <programlisting language="xml"><![CDATA[
  273. <!-- NOT ALLOWED -->
  274. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  275. $render = "xxx";
  276. ]]]]>&gt;<![CDATA[
  277. </programlisting>
  278. <!-- NOT ALLOWED -->
  279. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  280. $render = "xxx";
  281. ]]]]>&gt;<![CDATA[</programlisting>
  282. <!-- OK -->
  283. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  284. $render = "xxx";
  285. ]]]]>&gt;<![CDATA[</programlisting>
  286. ]]></programlisting>
  287. <para>
  288. The <emphasis>&lt;programlisting&gt;</emphasis> tag should contain the "language"
  289. attribute with a value appropriate to the contents of the program listing. Typical
  290. values include "css", "html", "ini", "javascript", "php", "text", and "xml".
  291. </para>
  292. <programlisting language="xml"><![CDATA[
  293. <!-- PHP -->
  294. <programlisting language="php">]]>&lt;<![CDATA[![CDATA[
  295. <!-- Javascript -->
  296. <programlisting language="javascript">]]>&lt;<![CDATA[![CDATA[
  297. <!-- XML -->
  298. <programlisting language="xml">]]>&lt;<![CDATA[![CDATA[
  299. ]]></programlisting>
  300. <para>
  301. For program listings containing only <acronym>PHP</acronym> code,
  302. <acronym>PHP</acronym> tags (e.g., "&lt;?php", "?&gt;") are not required, and
  303. should not be used. They simply clutter the narrative, and are implied by the use
  304. of the <emphasis>&lt;programlisting&gt;</emphasis> tag.
  305. </para>
  306. <programlisting language="xml"><![CDATA[
  307. <!-- NOT ALLOWED -->
  308. <programlisting language="php"]]>&lt;<![CDATA[![CDATA[<?php
  309. // ...
  310. ?>]]]]>&gt;<![CDATA[</programlisting>
  311. <programlisting language="php"]]>&lt;<![CDATA[![CDATA[
  312. <?php
  313. // ...
  314. ?>
  315. ]]]]>&gt;<![CDATA[</programlisting>
  316. ]]></programlisting>
  317. <para>
  318. Line lengths within program listings should follow the <link
  319. linkend="coding-standard.php-file-formatting.max-line-length">coding standards
  320. recommendations</link>.
  321. </para>
  322. <para>
  323. Refrain from using <methodname>require_once()</methodname>,
  324. <methodname>require()</methodname>, <methodname>include_once()</methodname>, and
  325. <methodname>include()</methodname> calls within <acronym>PHP</acronym> listings.
  326. They simply clutter the narrative, and are largely obviated when using an
  327. autoloader. Use them only when they are essential to the example.
  328. </para>
  329. <note>
  330. <title>Never use short tags</title>
  331. <para>
  332. Short tags (e.g., "&lt;?", "&lt;?=") should never be used within
  333. <emphasis>programlisting</emphasis> or the narrative of a document.
  334. </para>
  335. </note>
  336. </sect2>
  337. <sect2 id="doc-standard.file-formatting.inline-tags">
  338. <title>Notes on specific inline tags</title>
  339. <sect3 id="doc-standard.file-formatting.inline-tags.classname">
  340. <title>classname</title>
  341. <para>
  342. The tag <emphasis>&lt;classname&gt;</emphasis> must be used each time a class
  343. name is represented by itself; it should not be used when combined with a
  344. method name, variable name, or constant, and no other content is allowed within
  345. the tag.
  346. </para>
  347. <programlisting language="xml"><![CDATA[
  348. <para>
  349. The class <classname>Zend_Class</classname>.
  350. </para>
  351. ]]></programlisting>
  352. </sect3>
  353. <sect3 id="doc-standard.file-formatting.inline-tags.varname">
  354. <title>varname</title>
  355. <para>
  356. Variables must be wrapped in the <emphasis>&lt;varname&gt;</emphasis> tag.
  357. Variables must be written using the "$" sigil. No other content is allowed
  358. within this tag, unless a class name is used, which indicates a class variable.
  359. </para>
  360. <programlisting language="xml"><![CDATA[
  361. <para>
  362. The variable <varname>$var</varname> and the class variable
  363. <varname>Zend_Class::$var</varname>.
  364. </para>
  365. ]]></programlisting>
  366. </sect3>
  367. <sect3 id="doc-standard.file-formatting.inline-tags.methodname">
  368. <title>methodname</title>
  369. <para>
  370. Methods must be wrapped in the <emphasis>&lt;methodname&gt;</emphasis> tag.
  371. Methods must either include the full method signature or at the least a pair of
  372. closing parentheses (e.g., "()"). No other content is allowed within this tag,
  373. unless a class name is used, which indicates a class method.
  374. </para>
  375. <programlisting language="xml"><![CDATA[
  376. <para>
  377. The method <methodname>foo()</methodname> and the class method
  378. <methodname>Zend_Class::foo()</methodname>. A method with a full signature:
  379. <methodname>foo($bar, $baz)</methodname>
  380. </para>
  381. ]]></programlisting>
  382. </sect3>
  383. <sect3 id="doc-standard.file-formatting.inline-tags.constant">
  384. <title>constant</title>
  385. <para>
  386. Use the <emphasis>&lt;constant&gt;</emphasis> tag when denoting constants.
  387. Constants must be written in <acronym>UPPERCASE</acronym>. No other content is
  388. allowed within this tag, unless a class name is used, which indicates a class
  389. constant.
  390. </para>
  391. <programlisting language="xml"><![CDATA[
  392. <para>
  393. The constant <constant>FOO</constant> and the class constant
  394. <constant>Zend_Class::FOO</constant>.
  395. </para>
  396. ]]></programlisting>
  397. </sect3>
  398. <sect3 id="doc-standard.file-formatting.inline-tags.filename">
  399. <title>filename</title>
  400. <para>
  401. Filenames and paths must be wrapped in the
  402. <emphasis>&lt;filename&gt;</emphasis> tag. No other content is allowed in this
  403. tag.
  404. </para>
  405. <programlisting language="xml"><![CDATA[
  406. <para>
  407. The filename <filename>application/Bootstrap.php</filename>.
  408. </para>
  409. ]]></programlisting>
  410. </sect3>
  411. <sect3 id="doc-standard.file-formatting.inline-tags.command">
  412. <title>command</title>
  413. <para>
  414. Commands, shell scripts, and program calls must be wrapped in the
  415. <emphasis>&lt;command&gt;</emphasis> tag. If the command includes arguments,
  416. these should also be included within the tag.
  417. </para>
  418. <programlisting language="xml"><![CDATA[
  419. <para>
  420. Execute <command>zf.sh create project</command>.
  421. </para>
  422. ]]></programlisting>
  423. </sect3>
  424. <sect3 id="doc-standard.file-formatting.inline-tags.code">
  425. <title>code</title>
  426. <para>
  427. Usage of the <emphasis>&lt;code&gt;</emphasis> tag is discouraged, in favor of
  428. the other inline tasks discussed previously.
  429. </para>
  430. </sect3>
  431. </sect2>
  432. <sect2 id="doc-standard.file-formatting.block-tags">
  433. <title>Notes on specific block tags</title>
  434. <sect3 id="doc-standard.file-formatting.block-tags.title">
  435. <title>title</title>
  436. <para>
  437. The <emphasis>&lt;title&gt;</emphasis> tag is not allowed to hold other tags.
  438. </para>
  439. <programlisting language="xml"><![CDATA[
  440. <!-- NOT ALLOWED -->
  441. <title>Using <classname>Zend_Class</classname></title>
  442. <!-- OK -->
  443. <title>Using Zend_Class</title>
  444. ]]></programlisting>
  445. </sect3>
  446. </sect2>
  447. </sect1>
  448. <sect1 id="doc-standard.recommendations">
  449. <title>Recommendations</title>
  450. <sect2 id="doc-standard.recommendations.editors">
  451. <title>Use editors without autoformatting</title>
  452. <para>
  453. For editing the documentation, typically you should not use formal
  454. <acronym>XML</acronym> editors. Such editors normally autoformat existing documents
  455. to fit their own standards and/or do not strictly follow the docbook standard. As
  456. examples, we have seen them erase the <acronym>CDATA</acronym> tags, change 4 space
  457. separation to tabs or 2 spaces, etc.
  458. </para>
  459. <para>
  460. The style guidelines were written in large part to assist translators in recognizing
  461. the lines that have changed using normal <command>diff</command> tools.
  462. Autoformatting makes this process more difficult.
  463. </para>
  464. </sect2>
  465. <sect2 id="doc-standard.recommendations.images">
  466. <title>Use Images</title>
  467. <para>
  468. Good images and diagrams can improve readability and comprehension. Use them
  469. whenever they will assist in these goals. Images should be placed in the
  470. <filename>documentation/manual/en/figures/</filename> directory, and be named after
  471. the section identifier in which they occur.
  472. </para>
  473. </sect2>
  474. <sect2 id="doc-standard.recommendations.examples">
  475. <title>Use Case Examples</title>
  476. <para>
  477. Look for good use cases submitted by the community, especially those posted in
  478. proposal comments or on one of the mailing lists. Examples often illustrate usage
  479. far better than the narrative does.
  480. </para>
  481. <para>
  482. When writing your examples for inclusion in the manual, follow
  483. all coding standards and documentation standards.
  484. </para>
  485. </sect2>
  486. <sect2 id="doc-standard.recommendations.phpdoc">
  487. <title>Avoid Replicating phpdoc Contents</title>
  488. <para>
  489. The manual is intended to be a reference guide for end-user usage. Replicating
  490. the phpdoc documentation for internal-use components and classes is not wanted, and
  491. the narrative should be focussed on usage, not the internal workings. In any case,
  492. at this time, we would like the documentation teams to focus on translating the
  493. English manual, not the phpdoc comments.
  494. </para>
  495. </sect2>
  496. <sect2 id="doc-standard.recommendations.links">
  497. <title>Use Links</title>
  498. <para>
  499. Link to other sections of the manual or to external sources
  500. instead of recreating documentation.
  501. </para>
  502. <para>
  503. Linking to other sections of the manual may be done using the
  504. <emphasis>&lt;link&gt;</emphasis> tag (to which you must provide link text).
  505. </para>
  506. <programlisting language="xml"><![CDATA[
  507. <para>
  508. "Link" links to a section, using descriptive text: <link
  509. linkend="doc-standard.recommendations.links">documentation on
  510. links</link>.
  511. </para>
  512. ]]></programlisting>
  513. <para>
  514. To link to an external resource, use <emphasis>&lt;ulink&gt;</emphasis>:
  515. </para>
  516. <programlisting language="xml"><![CDATA[
  517. <para>
  518. The <ulink url="http://framework.zend.com/">Zend Framework site</ulink>.
  519. </para>
  520. ]]></programlisting>
  521. </sect2>
  522. </sect1>
  523. </appendix>