bfcfffdc06582c505159822d92518b1074302c1c
[occt.git] / dox / dev_guides / documentation / documentation.md
1  Documentation System {#dev_guides__documentation}
2 ======================
3
4 @tableofcontents
5
6 @section  OCCT_DM_SECTION_1 Introduction
7
8 This document provides practical guidenes for generation and editing of OCCT user documentation.
9
10 @section  OCCT_DM_SECTION_2 Prerequisites
11
12 <b>Tcl/Tk</b>
13 Version 8.5 or 8.6: http://www.tcl.tk/software/tcltk/download.html
14
15 <b>Doxygen</b> 
16 Version 1.8.4 or above: http://www.stack.nl/~dimitri/doxygen/download.html
17
18 <b>MathJax</b> (used for rendering math formulas in browser). 
19 See \ref OCCT_DM_SECTION_A_9 paragraph for more detailed description. 
20 The latest version: http://www.mathjax.org/download/
21
22 <b>MiKTeX</b> or equivalent tool (used for PDF document creation)
23
24 Latest version: http://miktex.org/download
25
26 **Note**: to generate pdf documentation with MiKTeX you should execute gendoc.bat within MiKTeX environment 
27 (run gendoc.bat in MiKTeX command promt or update PATH for MiKTeX bin folder). Also in process of pdf generation
28 MiKTeX can request you to download missing packages if MiKTeX was installed with option below:
29
30 @image html /dev_guides/documentation/images/documentation_image002.png
31 @image latex /dev_guides/documentation/images/documentation_image002.png
32
33 If this option is set to "Yes", MiKTeX will download missing packages automatically.
34
35 @section OCCT_DM_SECTION_2_1 Documentation Generation
36
37 Run gendoc.bat from OCCT directory to generate all articles are defined in FILES.txt:
38
39 gendoc.bat options:
40
41   * -html                : To generate HTML files (cannot be used with -pdf);
42   * -pdf                 : To generate PDF files (cannot be used with -html);
43   * -m=\<modules_list\>    : Specifies list of articles to generate. If it is not specified, all files, mentioned in FILES.txt are processed;
44   * -l=\<document_name\>   : Specifies the article caption for a single document;
45   * -h                   : Prints help message;
46   * -v                   : Specifies the Verbose mode (info on all script actions is shown).
47
48 If you run the command without arguments (like example above) it will generate HTML documentation 
49 for all articles are defined into FILES.txt.
50
51 **Note**: the generation process generates PDF files for each article, 
52 but in html case it generates common Html page with references to the ones.
53
54 For generation of specific article you need:
55   * have it's name with relative path (from \%OCCDIR\%/dox/ to the file) contained in FILES.txt 
56   (is located into \%OCCDIR\%/dox/ directory).
57
58 @verbatim
59 devs_guid/documentation/documentation.md
60 @endverbatim
61
62 where documentation .md is name of article and devs_guid/documentation/ is relative path of it
63
64   * use this name with -m option in the generation process:
65
66 @verbatim
67 % gendoc.bat -html -m=devs_guid/documentation/documentation.md
68 @endverbatim
69
70 Multiple files are separated with comma:
71
72 @verbatim
73 % gendoc.bat -html -m=MD_FILE_1,MD_FILE_2
74 @endverbatim
75
76 To sepcify a article name with -l option, use quotes to prevent incorrect interpretation of whitespaces:
77
78 @verbatim
79 % gendoc.bat -pdf -m=MD_FILE_1 -l="Label of MD_FILE_1 document"
80 @endverbatim
81
82 @section  OCCT_DM_SECTION_3 Documentation Conventions
83
84 This section contains information about conventions in the field of OCCT documentation file format, 
85 structure of documentation directories, etc.
86
87 @subsection  OCCT_DM_SECTION_3_1 File Format
88
89 It is proposed to use MarkDown file format for easy maintainance of generic text documents. 
90 The MarkDown files have a "*.md" extension and are based on rules desribed in 
91 @htmlonly <a href="#OCCT_DM_SECTION_A">Document Syntax</a> @endhtmlonly section.
92
93 @subsection  OCCT_DM_SECTION_3_2 Directory Structure
94
95 @image html /dev_guides/documentation/images/documentation_image001.png
96 @image latex /dev_guides/documentation/images/documentation_image001.png
97
98 Every separate article has own folder if images are used in it. These images 
99 are stored into "images" subfolder.
100
101 If you want to use the same image for several articles, you can place the one into "dox/resources" folder.
102
103 **Note**: Every article can use any image that is used by others articles. To avoid incorrect image
104 displaying, use relative path to the image (starting from dox folder). For instance
105 @verbatim
106 @image html /dev_guides/snv/images/snv_image001.svg
107 @endverbatim
108
109 Result of generation of the documentation is:
110
111 %OCCT_DIR% / doc         - a folder for generated articles;
112             * html/             - a directory for generated HTML pages;
113             * pdf/              - a directory for generated PDF files.
114
115 @section  OCCT_DM_SECTION_4 Adding a New Article
116
117  - Place a new article into folder that is chosen taking into account the place of the article 
118 at the hierarchy of the documentation. For instance the article about "using SVN working with OCCT 
119 source code" (svn.md - the file of the article) might be placed into /dox/dev_guides/ . If the article has images then you may create
120 the own folder of the article and subfolder in it for images. For instance
121 */dox/dev_guides/svn/ - for svn.md file
122 */dox/dev_guides/svn/images/ - for images
123
124  - Update dox/FILES.txt to add relative path to svn.md. For instance
125 @verbatim
126 dev_guides/snv/svn.md
127 @endverbatim
128
129 **Note**: the place of the relative path to an article is connected with the place
130 into treeview of html version.
131
132
133 Note, that you should specify a file tag, not the document name. 
134 See <a href="#OCCT_DM_SECTION_A_1">Header section</a> for details.
135
136 @section  OCCT_DOC_SECTION_5 Additional Resources
137
138 More information about OCCT can be found at http://www.opencascade.org
139
140 The information on formula syntax can be found at: 
141 http://en.wikipedia.org/wiki/Help:Displaying_a_formula
142
143 More information on MarkDown and Doxygen syntax can be found at:
144 http://www.stack.nl/~dimitri/doxygen/manual
145
146 @section  OCCT_DM_SECTION_A Appendix 1: Document Syntax
147
148 Each OCCT document file in *.md format has a simple structure.
149 It can contain: 
150
151 | Content type      | Obligation            |
152 | :---------------- | :-------------------: |
153 | Header            | M                     |
154 | Footer            | M                     |
155 | Plain text        | O                     |
156 | List              | O                     |
157 | Table             | O                     |
158 | Code              | O                     |
159 | Formula           | O                     |
160 | Image             | O                     |
161 | Page numbers      | M (auto generation)   |
162 | Table of contents | M (auto generation)   |
163
164 The legend:
165
166   * M is for Mandatory
167   * O is for Optional
168
169 @subsection  OCCT_DM_SECTION_A_1 Text Caption (a header)
170
171 headings of different levels can be specified with the following code:
172
173 @verbatim
174 Header 1  {#header1}
175 =======
176 @endverbatim
177
178   to get
179
180  Header 1
181 =========
182
183   and with the following code:
184
185 @verbatim
186 Header 2 {#header2}
187 --------
188 @endverbatim
189
190 to get 
191
192 Header 2
193 ---------
194
195 Where a word in curly braces is a MarkDown-style reference, which can be used in table of contents.
196 If you would like to have the table of contents, it is recommended to use \@section, 
197 \@subsection and \@subsubsection pages instead of MarkDown headers as follows:
198
199 @verbatim
200   @section Section_Name Section Header
201   @subsection SubSection_Name SubSection Header
202   @subsubsection SubSubSection_Name SubSubSection Header
203 @endverbatim
204
205 @subsection OCCT_DM_SECTION_A_2 Plain Text
206
207 Plain text is a text in a notepad-like format. To insert special symbols, 
208 like \< , \> or \\, prepend them with \\ character: \\\<, \\\>, \\\\ 
209 To emphasize some words, write one pair of asterisks ( * ) or underscores ( _ ) across the word 
210 to make it *italic* and two pairs of these symbols to make a word **Bold**.
211
212 @subsection OCCT_DM_SECTION_A_3 Lists
213
214 To create a bulleted list, start each line with a hyphen or an asterisk, 
215 followed by a space. List items can be nested. This code:
216
217 @verbatim
218   * Bullet 1
219   * Bullet 2
220     * Bullet 2a
221     * Bullet 2b
222   * Bullet 3
223 @endverbatim
224
225   produces this list:
226
227   * Bullet 1
228   * Bullet 2
229     * Bullet 2a
230     * Bullet 2b
231   * Bullet 3  
232
233 To create a numbered list, start each line with number and a period, then a space. Thus this code 
234
235 @verbatim
236   1. ListItem_1
237   2. ListItem_2
238   3. ListItem_3
239 @endverbatim
240
241   produces this list:
242
243   1. ListItem_1
244   2. ListItem_2
245   3. ListItem_3
246
247 It is recommended to indent lists with 2 spaces.
248
249 @subsection  OCCT_DM_SECTION_A_4 Tables
250
251 A table consists of a header line, a separator line, and at least one row line. 
252 Table columns are separated by the pipe (|) character. The following example: 
253
254 @verbatim
255 First Header  | Second Header
256 ------------- | -------------
257 Content Cell  | Content Cell 
258 Content Cell  | Content Cell 
259 @endverbatim
260
261   will produce the following table:
262
263 First Header | Second Header
264 ------------ | -------------
265 Content Cell | Content Cell 
266 Content Cell | Content Cell 
267
268 Column alignment can be controlled via one or two colons at the header separator line: 
269
270 @verbatim
271 | Right | Center | Left  |
272 | ----: | :----: | :---- |
273 | 10    | 10     | 10    |
274 | 1000  | 1000   | 1000  |
275 @endverbatim
276
277 which will looks as follows:
278
279 | Right | Center | Left  |
280 | ----: | :----: | :---- |
281 | 10    | 10     | 10    |
282 | 1000  | 1000   | 1000  |
283
284 @subsection  OCCT_DM_SECTION_A_5 Code Blocks
285
286 It is recommended to indent a code lines with 4 spaces.
287 A fenced code block does not require indentation, and is defined by a pair of "fence lines". 
288 Such line consists of 3 or more tilde (~) characters on a line. 
289 The end of the block should have the same number of tildes. Here is an example:
290
291 ~~~~~~~~~~~~~~~~~~~~~~~
292   a one-line code block
293 ~~~~~~~~~~~~~~~~~~~~~~~
294
295 By default the output is the same as for a normal code block.
296 To highlight the code, the developer has to indicate the typical file extension, 
297 which corresponds to the programming language, after the opening fence. 
298 For highlighting according to the C++ language, for instance,  write the following code (the curly braces and dot are optional): 
299
300 @verbatim
301 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
302     int func(int a,int b) { return a*b; }
303 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
304 @endverbatim
305
306 which will produce:
307 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp} 
308     int func(int a,int b) { return a*b; }
309 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310
311 Verbatim content can be written by using framing \@verbatim \@endverbatim . For instance
312
313 @verbatim
314   verbatim text
315 @endverbatim
316
317 @subsection  OCCT_DM_SECTION_A_6 References
318
319 To insert a reference to a website, it is proposed to write a URL. For example: http://en.wikipedia.org
320 To insert a reference to another part of the same document, the developer can write:
321
322 @verbatim
323   @htmlonly 
324     <a href="#OCCT_DOC_SECTION_5">Doxygen Configuration file</a>
325   @endhtmlonly 
326 @endverbatim
327
328 to get a link to paragraph : @htmlonly <a href="#OCCT_DOC_SECTION_5">Doxygen configuration</a> @endhtmlonly 
329
330 @subsection  OCCT_DM_SECTION_A_7 Images
331
332 To insert image into document the developer can write the following code(in Doxygen-style):
333 @verbatim
334 ![alt-caption](relative/path/to/image/image001.svg "Image Caption")
335 @endverbatim
336
337 This code tells Doxygen to insert a picture right in the place this code was written. Like this:
338 @verbatim
339 ![](/resources/occ_logo.png "OCCT logo")
340 @endverbatim
341
342 ![](/resources/occ_logo.png "OCCT logo")
343  
344 @subsection  OCCT_DM_SECTION_A_8 Table Of Contents
345
346 To get the table of contents at the beginning of the document, write \@tableofcontents tag. 
347 But it is not needed now because TreeView option for HTML is used.
348 The TOC in the PDF document will be generated automatically.
349
350 @subsection  OCCT_DM_SECTION_A_9 Formulas
351
352 Formulas within documents will be generated using MathJax tool.
353
354 A developer has to specify these parameters in Doxyfile to enable support of MathJax in Doxygen:
355
356     USE_MATHJAX         = YES
357     MATHJAX_FORMAT      = HTML-CSS
358     MATHJAX_RELPATH     = http://cdn.mathjax.org/mathjax/latest
359     MATHJAX_EXTENSIONS  = TeX/AMSmath TeX/AMSsymbols
360
361 To use MathJax tool with the HTML page, it's \<head\> block has to contain 
362
363 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.html}
364     <script type="text/x-mathjax-config">
365       MathJax.Hub.Config({
366         tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]},
367         displayAlign: "left"
368       });
369     </script>
370
371     <script type="text/javascript"
372       src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
373     </script>
374 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
375
376 First script configures MathJax to understand separator types and to left allign formulas. 
377 The second script inserts reference to MathJax tool. 
378 This tool will always be used when the HTML output will be shown.
379
380 Equations can be written by several ways:
381
382 1.Unnumbered displayed formulas that are centered on a separate line. 
383 These formulas should be put between \@f\[ and \@f\] tags. An example: 
384
385 @verbatim
386 @f$[
387     |I_2|=\left| \int_{0}^T \psi(t)
388             \left\{ 
389                 u(a,t)-
390                 \int_{\gamma(t)}^a 
391                 \frac{d\theta}{k(\theta,t)}
392                 \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
393             \right\} dt
394         \right|
395 @f$]
396 @endverbatim
397
398 gives the following result:
399
400    @f$
401        |I_2|=\left| \int_{0}^T \psi(t)
402                \left\{ 
403                    u(a,t)-
404                    \int_{\gamma(t)}^a 
405                    \frac{d\theta}{k(\theta,t)}
406                    \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
407                \right\} dt
408            \right|
409    @f$
410    
411 2.Formulas can also be put between @verbatim \begin{align} @endverbatim and @verbatim \end{align} @endverbatim tags. An example: 
412
413 @verbatim
414   \begin{align}
415   \dot{x} & = \sigma(y-x) \\
416   \dot{y} & = \rho x - y - xz \\
417   \dot{z} & = -\beta z + xy
418   \end{align}
419 @endverbatim
420
421   gives the following result:
422 @latexonly
423   \begin{align}
424   \dot{x} & = \sigma(y-x) \\
425   \dot{y} & = \rho x - y - xz \\
426   \dot{z} & = -\beta z + xy
427   \end{align}
428 @endlatexonly
429
430 @htmlonly
431   \begin{align}
432   \dot{x} & = \sigma(y-x) \\
433   \dot{y} & = \rho x - y - xz \\
434   \dot{z} & = -\beta z + xy
435   \end{align}
436 @endhtmlonly
437
438 3.Inline formulas can be specified using this syntax:
439
440 @verbatim
441   @f$ \sqrt{3x-1}+(1+x)^2 @f$
442 @endverbatim
443
444   that leads to the following result: @f$ \sqrt{3x-1}+(1+x)^2 @f$
445