/docs/docblock-templates.md

https://gitlab.com/digitalpoetry/fnf · Markdown · 422 lines · 371 code · 51 blank · 0 comment · 0 complexity · 9e33342f3acb0ee92df51d68b80b315a MD5 · raw file

  1. DocBlock Templates
  2. ====================
  3. TODO:
  4. - [ ] Add annotations to DocBlock Templates
  5. ****************************************
  6. #### Single Line Comments
  7. Not a DocBlock:
  8. ```php
  9. // Allow plugins to filter an array.
  10. ```
  11. DocBlock:
  12. ```php
  13. /** Allow plugins to filter an array. */
  14. ```
  15. ****************************************
  16. #### Multi-line Comments
  17. Not a DocBlock:
  18. ```php
  19. /*
  20. * This is a comment that is long enough to warrant being stretched over
  21. * the span of multiple lines. You'll notice this follows basically
  22. * the same format as the PHPDoc wrapping and comment block style.
  23. */
  24. ```
  25. DocBlock:
  26. ```php
  27. /**
  28. * This is a comment that is long enough to warrant being stretched over
  29. * the span of multiple lines. You'll notice this follows basically
  30. * the same format as the PHPDoc wrapping and comment block style.
  31. */
  32. ```
  33. ****************************************
  34. #### Markers
  35. Mark code for improvements:
  36. ```php
  37. /** TODO: Description. */
  38. ```
  39. Mark code for bugs:
  40. ```php
  41. /** FIXME: Description. */
  42. ```
  43. ****************************************
  44. #### File
  45. Standard Usage:
  46. ```php
  47. /**
  48. * Code All The Things!
  49. *
  50. * Project jumpstarter based on the Sprint & CodeIgnitor frameworks.
  51. *
  52. * @package DigitalPoetry\FnF
  53. * @author Jesse LaReaux <jlareaux@gmail.com>
  54. * @copyright Copyright (c) 2016, DigitalPoetry http://codeallthethings.xyz
  55. * @license MIT License http://opensource.org/licenses/MIT
  56. * @link <link>
  57. * @version <version> [<releasename>] [<checksum>]
  58. * @filesource
  59. */
  60. ```
  61. Complete Usage:
  62. ```php
  63. /**
  64. * Summary (no period for file headers)
  65. *
  66. * Description.
  67. *
  68. * @package DigitalPoetry\FnF
  69. * @author Jesse LaReaux <jlareaux@gmail.com>
  70. * @copyright Copyright (c) 2016, DigitalPoetry http://codeallthethings.xyz
  71. * @license MIT License http://opensource.org/licenses/MIT
  72. * @version <version> [<releasename>] [<checksum>]
  73. * @since <version> [<releasename>] [<checksum>]
  74. * @link <link>
  75. * @filesource
  76. *
  77. * @todo Description.
  78. */
  79. ```
  80. ****************************************
  81. #### Require(_once), Include(_once)
  82. Standard Usage:
  83. ```php
  84. /**
  85. * Summary.
  86. *
  87. * @since <version> [<releasename>] [<checksum>]
  88. * @see <uri>|<fqsen> [Description.]
  89. * @link <link>
  90. */
  91. ```
  92. Complete Usage:
  93. ```php
  94. /**
  95. * Summary.
  96. *
  97. * @since <version> [<releasename>] [<checksum>]
  98. * @see <uri>|<fqsen> [Description.]
  99. * @link <link>
  100. * @todo Description.
  101. */
  102. ```
  103. ****************************************
  104. #### Class
  105. Standard Usage:
  106. ```php
  107. /**
  108. * Summary.
  109. *
  110. * Description, {@inheritdoc}.
  111. *
  112. * @inheritdoc
  113. * @since <version> [<releasename>] [<checksum>]
  114. */
  115. ```
  116. Complete Usage:
  117. ```php
  118. /**
  119. * Summary.
  120. *
  121. * Description, {@inheritdoc}.
  122. *
  123. * @inheritdoc
  124. * @author Jesse LaReaux <jlareaux@gmail.com>
  125. * @copyright Copyright (c) 2016, DigitalPoetry http://codeallthethings.xyz
  126. * @license MIT License http://opensource.org/licenses/MIT
  127. *
  128. * @package CATT
  129. * @version <version> [<releasename>] [<checksum>]
  130. * @since <version> [<releasename>] [<checksum>]
  131. * @deprecated <version> [Description.]
  132. * @see <fqsen>.
  133. *
  134. * @uses <fqsen> [Description.]
  135. * @see <url>|<fqsen> [Description.]
  136. * @example <location> <start> <length> [Description.]
  137. * @link <link>
  138. * @source <start> <length> [Description.]
  139. * @todo Description.
  140. */
  141. ```
  142. ****************************************
  143. #### Function
  144. Standard Usage:
  145. ```php
  146. /**
  147. * Summary.
  148. *
  149. * Description.
  150. *
  151. * @version <version> [<releasename>] [<checksum>]
  152. * @since <version> [<releasename>] [<checksum>]
  153. *
  154. * @global <type> $var [Description.]
  155. * @uses <fqsen> [Description.]
  156. * @see <url>|<fqsen> [Description.]
  157. * @link <link>
  158. *
  159. * @param <type> $var [Description.]
  160. * @return <type> Description.
  161. * @throws <type> Description.
  162. */
  163. ```
  164. Complete Usage:
  165. ```php
  166. /**
  167. * Summary.
  168. *
  169. * Description.
  170. *
  171. * @version <vector> Description
  172. * @since <version> [<releasename>] [<checksum>]
  173. * @deprecated <version> [Description.]
  174. * @see [Description.]
  175. *
  176. * @global <type> $var [Description.]
  177. * @uses <fqsen> [Description.]
  178. * @see <url>|<fqsen> [Description.]
  179. * @example <location> <start> <length> [Description.]
  180. * @link <link>
  181. * @source <start> <length>
  182. * @todo Description.
  183. *
  184. * @param <type> $var [Description.]
  185. * @return <type> Description.
  186. * @throws <type> Description.
  187. */
  188. ```
  189. ****************************************
  190. #### Method
  191. Standard Usage:
  192. ```php
  193. /**
  194. * Summary.
  195. *
  196. * Description, {@inheritdoc}.
  197. *
  198. * @inheritdoc
  199. * @api
  200. * @since <version> [<releasename>] [<checksum>]
  201. *
  202. * @global <type> $var [Description.]
  203. * @uses <fqsen> [Description.]
  204. * @see <url>|<fqsen> [Description.]
  205. * @link <link>
  206. *
  207. * @param <type> $var [Description.]
  208. * @return <type> Description.
  209. * @throws <type> Description.
  210. */
  211. ```
  212. Complete Usage:
  213. ```php
  214. /**
  215. * Summary.
  216. *
  217. * Description, {@inheritdoc}.
  218. *
  219. * @inheritdoc
  220. * @api
  221. * @since <version> [<releasename>] [<checksum>]
  222. * @deprecated <version> [Description.]
  223. * @see [Description.]
  224. *
  225. * @global <type> $var [Description.]
  226. * @uses <fqsen> [Description.]
  227. * @see <url>|<fqsen> [Description.]
  228. * @example <location> <start> <length> [Description.]
  229. * @link <link>
  230. * @source <start> <length>
  231. * @todo Description.
  232. *
  233. * @param <type> $var [Description.]
  234. * @return <type> Description.
  235. * @throws <type> Description.
  236. */
  237. ```
  238. ****************************************
  239. #### Property
  240. Standard Usage:
  241. ```php
  242. /**
  243. * Summary, {@inheritdoc}.
  244. *
  245. * @inheritdoc
  246. * @version <version> [<releasename>] [<checksum>]
  247. * @since <version> [<releasename>] [<checksum>]
  248. * @var <type> $var [Description.]
  249. */
  250. ```
  251. Complete Usage:
  252. ```php
  253. /**
  254. * Summary, {@inheritdoc}.
  255. *
  256. * @inheritdoc
  257. * @version <version> [<releasename>] [<checksum>]
  258. * @since <version> [<releasename>] [<checksum>]
  259. * @deprecated <version> [Description.]
  260. * @see <fqsen> [Description.]
  261. *
  262. * @see <url>|<fqsen> [Description.]
  263. * @example <location> <start> <length> [Description.]
  264. * @link <link>
  265. * @source <start> <length> [Description.]
  266. * @todo Description.
  267. *
  268. * @var <type> $var [Description.]
  269. */
  270. ```
  271. ****************************************
  272. #### [class] Constant:
  273. Standard Usage:
  274. ```php
  275. /**
  276. * Summary.
  277. *
  278. * @version <version> [<releasename>] [<checksum>]
  279. * @since <version> [<releasename>] [<checksum>]
  280. * @var <type> $var [Description.]
  281. */
  282. ```
  283. Complete Usage:
  284. ```php
  285. /**
  286. * Summary.
  287. *
  288. * @inheritdoc
  289. * @version <version> [<releasename>] [<checksum>]
  290. * @since <version> [<releasename>] [<checksum>]
  291. * @deprecated <version> [Description.]
  292. * @see <fqsen> [Description.]
  293. *
  294. * @see <url>|<fqsen> [Description.]
  295. * @example <location> <start> <length> [Description.]
  296. * @link <link>
  297. * @source <start> <length> [Description.]
  298. * @todo Description.
  299. *
  300. * @var <type> $var [Description.]
  301. */
  302. ```
  303. ****************************************
  304. #### Global Variable
  305. Standard Usage:
  306. ```php
  307. /**
  308. * Summary.
  309. *
  310. * @version <version> [<releasename>] [<checksum>]
  311. * @since <version> [<releasename>] [<checksum>]
  312. * @global <type> Description.
  313. */
  314. ```
  315. Complete Usage:
  316. ```php
  317. /**
  318. * Summary.
  319. *
  320. * @version <version> [<releasename>] [<checksum>]
  321. * @since <version> [<releasename>] [<checksum>]
  322. * @deprecated <version> Use new_global_name().
  323. * @see <fqsen> [Description.]
  324. *
  325. * @global <type> Description.
  326. * @see <url>|<fqsen> [Description.]
  327. * @example <location> <start> <length> [Description.]
  328. * @link <link>
  329. * @source <start> <length> [Description.]
  330. * @todo Description.
  331. */
  332. ```
  333. ****************************************
  334. #### Param, <type>, Property, Etc
  335. ```php
  336. /**
  337. * @param string $var Optional. The _ string. Default _.
  338. * @param integer $var Optional. The number of _. Default _.
  339. * @param float $var Optional. The value of _. Default _.
  340. * @param number $var Optional. The _ number. Default _.
  341. * @param boolean $var Optional. _ if set to true, _ if false. Default _.
  342. * @param array $var Optional. An array of _. Default _.
  343. * @param object $var Optional. The _ object. Default _.
  344. * @param static $var Optional. The _ instance. Default _.
  345. * @param mixed $var Optional. The value of _. Default _.
  346. * @param null $var Optional. An empty value. Default _.
  347. * @param resource $var Optional. The _ file handler. Default _.
  348. * @param callable $var Optional. The _ handler. Default _.
  349. * @param int|str $var Optional. Description. Default _.
  350. * @param string[] $var Optional. An array of _ strings. Default _.
  351. * @param array[] $var Optional. An array of _ arrays. Default _.
  352. * @param object[] $var Optional. An array of _ objects. Default _.
  353. * @param mixed[] $var Optional. An array of _ values. Default _.
  354. * @param array args {
  355. * Optional. An array of _. Default _.
  356. * @<type> <type> $key Optional. Accepts 'value', 'value'. (align with
  357. * Description if wraps to a new line) Default _.
  358. * @<type> string $key Optional. The _ string. Default _.
  359. * @<type> integer $key Optional. he number of _. Default _.
  360. * @<type> object $key Optional. The _ object. Default _.
  361. * @<type> boolean $key Optional. _ if set to true, _ if false. Default _.
  362. * }
  363. */
  364. ```
  365. ****************************************
  366. References:
  367. - [phpDoc Documentation](https://www.phpdoc.org/docs/latest/index.html)
  368. - [PSR-5: PHPDoc Standard](https://github.com/phpDocumentor/fig-standards/tree/master/proposed)
  369. - [PSR-?: PHPDoc Standard Revision](https://github.com/mvriel/phpDocumentor2/blob/b803b549189926ae6880cabd699675f22d8aade1/docs/PSR.md)
  370. - [PhpDoc2Cheatsheet](http://phpdoc2cheatsheet.com/)
  371. - [WordPress PHP Documentation Standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#resources)