PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/manual/Configuration.rst

https://github.com/studioskylab/Docblox
ReStructuredText | 386 lines | 297 code | 89 blank | 0 comment | 0 complexity | e2b24f01add3e66630d08d23f9f10202 MD5 | raw file
  1. Configuration
  2. =============
  3. DocBlox is meant as a highly configurable and extensible
  4. application. As such there are a lot of things that can be
  5. configured by the user.
  6. An overview will be given in this chapter where you could place the
  7. configuration file and what it needs to look like.
  8. Location
  9. --------
  10. The easiest solution would be to place the configuration file in
  11. the root of your project with the name: ``docblox.dist.xml``. This
  12. file can be committed to a Revision Control System and thus will
  13. the settings always be available.
  14. When you have added a configuration file then you do not need to
  15. provide its location to DocBlox; the following command suffices to
  16. build your documentation:
  17. ::
  18. $ docblox
  19. An additional benefit is that it is possible for each developer to
  20. place a file called ``docblox.xml`` in their project, in addition
  21. to the ``docblox.dist.xml``. This configuration file will be used
  22. instead of the ``docblox.dist.xml`` and when added as an ignore
  23. rule in your VCS it will give developers the ability to have
  24. settings other than the project defaults.
  25. **Note:**
  26. *the file ``docblox.xml`` is used instead of ``docblox.dist.xml`` and thus does not supplement it*
  27. Another option is to use the ``-c`` or ``--configuration``
  28. arguments to tell DocBlox the location of your configuration file.
  29. This can be convenient for centralized configuration management or
  30. using different settings per environment.
  31. **Note:** ``none`` is a reserved word and providing ``-c none`` as
  32. option will result in any configuration file being ignored.
  33. Basic configuration
  34. -------------------
  35. DocBlox follows the *convention over configuration* style and as
  36. such it is only necessary to specify the options which you want to
  37. change with regard to the defaults.
  38. The easiest way to find out what the defaults are is to look in the
  39. configuration template, which is located in
  40. *[DOCBLOX FOLDER]/data/docblox.tpl.xml* or to examine the
  41. specifications in this document.
  42. Usually the following configuration suffices for your project:
  43. ::
  44. <?xml version="1.0" encoding="UTF-8" ?>
  45. <docblox>
  46. <parser>
  47. <target>data/output</target>
  48. </parser>
  49. <transformer>
  50. <target>data/output</target>
  51. </transformer>
  52. <files>
  53. <directory>.</directory>
  54. </files>
  55. </docblox>
  56. *Remember when we told you about there being a parser and transformer in the previous chapter?*
  57. The configuration expects you to specify for both what their output
  58. (target) folder should be.
  59. This way it is possible to provide a staging location where you
  60. indefinitely store your structure file and benefit from the
  61. increased speed when doing multiple runs. This is called
  62. **Incremental Processing** or **Incremental Parsing**.
  63. The transformer expects the source file to be at the target
  64. location of the parser so you need not specify that explicitly.
  65. The files section allows you to specify where the source code for
  66. your project is and what files to ignore.
  67. ::
  68. <files>
  69. <file>test.php</php>
  70. <file>bin/*</php>
  71. <directory>src</directory>
  72. <directory>tes??</directory>
  73. <ignore>test/*</ignore>
  74. </files>
  75. It is allowed to use relative paths here; just remember that these
  76. are relative from the working directory where you execute DocBlox
  77. in.
  78. It is possible to specify specific files or a specific set of **files**
  79. using the element. As with the -f parameter it supports wildcards.
  80. In addition you can also provide entire **directory** trees using the
  81. element. This also supports the use of wildcards. Please note that
  82. in contrary to the element that the element is recursive and will
  83. tell DocBlox to process all files contained in this folder and
  84. every subfolder.
  85. In some cases you will have to **ignore** certain files in your project; examples
  86. of these can be third party libraries and/or tests. In this case you can use
  87. the *ignore* element and provide a pattern (not a path) to ignore.
  88. This if you provide ``*test*`` it will ignore any file or directory containing
  89. the text *test* in it.
  90. *Note*: the documentation regarding ignore elements is in effect from v0.14.0
  91. previous versions of DocBlox needed to have a element `ignore` in the
  92. document root with child elements called `item`.
  93. The *starting point* or *base directory* for the ignore directive is the *Project
  94. Root*; which is the highest folder that all files share in common.
  95. Thus if you provide a single directory and that does not contain any parseable
  96. files and only on subfolder (which does contain parseable files) then the *Project Root*
  97. if not the given folder but the subfolder.
  98. **Confusing?** We can imagine. This behavior is changed slightly in version
  99. 0.14.0 of DocBlox to the following: when only one directory is provided and no
  100. other files; then the given directory is the *Project Root*. In all other
  101. cases the previously mentioned behaviour is still used.
  102. Reference
  103. ---------
  104. The DocBlox configuration file contains the following top level
  105. elements which are explained in more detail in the sub-chapters.
  106. - Title, the title for this project, *may contain HTML*
  107. - Parser, all settings related to the conversion of the source
  108. code to the intermediate structure file (structure.xml).
  109. - Transformer, all settings related to the process of transforming
  110. the intermediate structure file (structure.xml) to a human readable
  111. format, such as HTML or PDF.
  112. - Logging, all settings related to the generation of logs.
  113. - Transformations, the default template and additional
  114. transformations can be specified in this section.
  115. Parser
  116. ~~~~~~
  117. The parser section contains all settings related to the conversion
  118. of your project's source to the intermediate structure format of
  119. DocBlox (structure.xml).
  120. The following fields are supported:
  121. - *default-package-name*, optional element which defines the name of the
  122. default package. This is the name of the package when none is provided.
  123. - *target*, the target location where to store the structure.xml,
  124. also used as source location for the transformer.
  125. - *markers*, contains a listing of item's. These items identify
  126. which keywords in comments are used to identify additional sets of
  127. information. An example of this is inline comments starting with
  128. the *marker* TODO or FIXME.
  129. - *extensions*, contains a list of extension's which a file
  130. must have to be interpreted. If a file does not have the extension
  131. mentioned in this list then it is not parsed. Examples: php, php3
  132. or phtml.
  133. *Example*
  134. ::
  135. <parser>
  136. <target>output</target>
  137. <markers>
  138. <item>TODO</item>
  139. <item>FIXME</item>
  140. </markers>
  141. <extensions>
  142. <extension>php</extension>
  143. <extension>php3</extension>
  144. <extension>phtml</extension>
  145. </extensions>
  146. </parser>
  147. Transformer
  148. ~~~~~~~~~~~
  149. The transformer section contains most settings related to the
  150. transformation of the intermediate structure format (structure.xml)
  151. to a human-readable set of documentation. The format of this set of
  152. documentation is determined by the template choice which is present
  153. in the ``transformations`` head section.
  154. The transformer determines the location of the intermediate
  155. structure format (structure.xml) by retrieving the ``target``
  156. element in the ``parser`` section.
  157. The following fields are supported:
  158. - *target*, the target location where to store the generated
  159. documentation files.
  160. - *external-class-documentation* (*v0.14.0*), with this element you can link the
  161. documentation generated by DocBlox to the URL of a library based on the
  162. prefix of the class. This element may be used multiple times and each time
  163. has a ``prefix`` and ``uri`` element which specify which class to link where.
  164. The `uri` element supports 2 substitution variables: {CLASS} and
  165. {LOWERCASE_CLASS}.
  166. Please note that if the class is part of a namespace that
  167. the backslashes are also copied; with exception of the 'root' (start of the
  168. class name).
  169. *Example*
  170. ::
  171. <transformer>
  172. <target>output</target>
  173. <external-class-documentation>
  174. <prefix>HTML_QuickForm2</prefix>
  175. <uri>http://pear.php.net/package/HTML_QuickForm2/docs/latest/HTML_QuickForm2/{CLASS}.html</uri>
  176. </external-class-documentation>
  177. </transformer>
  178. Logging
  179. ~~~~~~~
  180. The logging section contains all settings related to the logging of
  181. information in DocBlox.
  182. DocBlox does not 'care' whether the specified logging paths exist;
  183. if they do not then no log files are generated.
  184. The following fields are supported:
  185. - *level*, determines the minimum level of information that is
  186. supplied. Any priority equal to or higher than the given is
  187. included in the log files and is output to the screen. All
  188. priorities lower than the given are not logged. The following
  189. values are allowed (in order from highest to lowest priority):
  190. - emerg
  191. - alert
  192. - crit
  193. - err
  194. - warn
  195. - notice
  196. - info
  197. - debug
  198. - quiet
  199. - *paths*, contains all folders to where DocBlox may log.
  200. - *default*, this is the path of the default logging file, the
  201. name may be augmented with a {DATE} variable to provide a
  202. timestamp and {APP_ROOT} to indicate the root of the DocBlox application.
  203. - *errors*, messages with level *debug* are not added to the
  204. default log but in a separate log file whose path you can declare
  205. here. As with the *default* log file you can augment the path with
  206. the {DATE} variable.
  207. *Example*:
  208. ::
  209. <logging>
  210. <level>warn</level>
  211. <paths>
  212. <default>{APP_ROOT}/data/log/{DATE}.log</default>
  213. <errors>{APP_ROOT}/data/log/{DATE}.errors.log</errors>
  214. </paths>
  215. </logging>
  216. Transformations
  217. ~~~~~~~~~~~~~~~
  218. The transformations section controls the behaviour applied in
  219. transforming the intermediate structure format to the final human-readable
  220. output.
  221. The following fields are supported:
  222. - *template*, the name or path of a template to use. This element may be used
  223. multiple times to combine several templates though usually you only supply one.
  224. Example:
  225. ::
  226. <template name="default"/>
  227. ::
  228. <template name="/home/mvriel/Docblox Templates/myTemplate"/>
  229. - *transformation*, it is also possible to execute additional transformations
  230. specifically for this project by defining your own transformations here.
  231. See the chapter on :doc:`Building your own branding` for a description of the
  232. transformation element and examples.
  233. *Example*:
  234. ::
  235. <transformations>
  236. <template name="default" />
  237. </transformations>
  238. Files
  239. ~~~~~
  240. Please see the previous sub-chapter :ref:`Basic configuration` for a complete
  241. description of the files section.
  242. *Example*:
  243. ::
  244. <files>
  245. <file>test.php</php>
  246. <file>bin/*</php>
  247. <directory>src</directory>
  248. <directory>tes??</directory>
  249. <ignore>test/*</ignore>
  250. </files>
  251. Appendix A: basic configuration example
  252. ---------------------------------------
  253. ::
  254. <?xml version="1.0" encoding="UTF-8" ?>
  255. <docblox>
  256. <parser>
  257. <target>data/output</target>
  258. </parser>
  259. <transformer>
  260. <target>data/output</target>
  261. </transformer>
  262. <files>
  263. <directory>.</directory>
  264. </files>
  265. </docblox>
  266. Appendix B: complete configuration example
  267. ------------------------------------------
  268. ::
  269. <?xml version="1.0" encoding="UTF-8" ?>
  270. <docblox>
  271. <parser>
  272. <target>output</target>
  273. <markers>
  274. <item>TODO</item>
  275. <item>FIXME</item>
  276. </markers>
  277. <extensions>
  278. <extension>php</extension>
  279. <extension>php3</extension>
  280. <extension>phtml</extension>
  281. </extensions>
  282. <visibility></visibility>
  283. </parser>
  284. <transformer>
  285. <target>output</target>
  286. </transformer>
  287. <logging>
  288. <level>warn</level>
  289. <paths>
  290. <default>{APP_ROOT}/data/log/{DATE}.log</default>
  291. <errors>{APP_ROOT}/data/log/{DATE}.errors.log</errors>
  292. </paths>
  293. </logging>
  294. <transformations>
  295. <template name="default" />
  296. </transformations>
  297. </docblox>