documentation-standard.xml 21 KB

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