f0749fa35b10de92e5e3136dd4d5e9dbdfba3fdc
[occt.git] / dox / dev_guides / documentation / documentation.md
1  Documentation System {#occt_dev_guides__documentation}
2 ======================
3
4 @tableofcontents
5
6 @section  OCCT_DM_SECTION_1 Introduction
7
8 This document provides practical guidelines for generation and editing of OCCT user documentation.
9
10 @section  OCCT_DM_SECTION_2 Prerequisites
11
12 You need to have the following software installed to generate the documentation.
13
14 **Tcl/Tk**
15 Version 8.5 or 8.6: http://www.tcl.tk/software/tcltk/download.html
16
17 **Doxygen**
18 Version 1.8.4 or above: http://www.stack.nl/~dimitri/doxygen/download.html
19
20 **MiKTeX** or other package providing **pdflatex** command (only needed for generation of PDF documents): http://miktex.org/download
21
22 **Inkscape** (only needed for generation of PDF documents containing SVG images): http://www.inkscape.org/download
23
24 When generating PDF documentation, **pdflatex** and **inkscape** executables should be accessible by PATH variable.
25 You can use *custom.bat* file to add necessary paths to the *PATH* variable. 
26
27 Note that in the process of PDF generation MiKTeX may need some packages not installed by default.
28 We recommend setting option "Install missing packages on-the-fly" to "Ask me first" (default) during MiKTeX installation:
29
30 @figure{/dev_guides/documentation/images/documentation_miktex.png}
31
32 On the first run of **pdflatex** it will open a dialog window prompting for installation of missing packages.
33 Follow the instructions to proceed (define proxy settings if needed, select a mirror site to download from, etc.).
34
35 **MathJax** is used for rendering math formulas in browser (HTML and CHM outputs): http://www.mathjax.org.
36
37 By default MathJAX scripts and fonts are taken from http://cdn.mathjax.org/mathjax/latest and no installation of MathJAX is necessary if Internet is accessible.
38 If you need to use OCCT documentation while off-line, you can install a local copy of MatJAX, see http://www.mathjax.org/download/.
39 See \ref OCCT_DM_SECTION_A_9 for more details on inserting mathematical expressions. 
40
41 @section OCCT_DM_SECTION_2_1 Documentation Generation
42
43 Run command *gendoc* from command prompt (with OCCT directory as current one) to generate OCCT documentation.
44 The synopsis is:
45
46     gendoc \[-h\] {-refman|-overview} \[-html|-pdf|-chm\] \[-m=<list of modules>|-ug=<list of docs>\] \[-v\] \[-s=<search_mode>\] \[-mathjax=<path>\]
47         
48 Here the options are:
49
50 * Choice of documentation to be generated:
51   * <i>-overview</i>: To generate Overview and User Guides (cannot be used with -refman)
52   * <i>-refman</i>: To generate class Reference Manual (cannot be used with -overview)
53
54 * Choice of output format:
55   * <i>-html</i>: To generate HTML files (default, cannot be used with -pdf or -chm)
56   * <i>-pdf</i>: To generate PDF files (cannot be used with -refman, -html, or -chm)
57   * <i>-chm</i>: To generate CHM files (cannot be used with -html or -pdf)
58
59 * Additional options:
60   * <i>-m=\<modules_list\></i>: List of OCCT modules (separated with comma), for generation of Reference Manual
61   * <i>-ug=\<docs_list\></i>: List of MarkDown documents (separated with comma), to use for generation of Overview / User Guides
62   * <i>-mathjax=\<path\></i>: To use local or alternative copy of MathJax
63   * <i>-s=\<search_mode\></i>: Specifies the Search mode of HTML documents; can be: none | local | server | external
64   * <i>-h</i>: Prints this help message
65   * <i>-v</i>: Enables more verbose output
66
67 **Note**
68
69 * In case of PDF output the utility generates a separate PDF file for each document;
70 * In case of HTML output the utility generates a common Table of contents containing references to all documents.
71 * In case of CHM output single CHM file is generated
72
73 **Examples**
74
75 To generate the output for a specific document specify the path to the corresponding MarkDown file (paths relative to *dox* sub-folder can be given), for instance:
76
77 ~~~~
78     > gendoc -overview -ug=dev_guides/documentation/documentation.md
79 ~~~~
80
81 To generate Reference Manual for the whole Open CASCADE Technology library, run: 
82 ~~~~
83     > gendoc -refman
84 ~~~~
85
86 To generate Reference Manual for Foundation Classes and Modeling Data modules only, with search option, run:
87 ~~~~
88     > gendoc -refman -m=FoundationClasses,ModelingData,ModelingAlgorithms -s=local
89 ~~~~
90
91 @section  OCCT_DM_SECTION_3 Documentation Conventions
92
93 This section contains information about file format conventions, directories structure, etc.
94
95 @subsection  OCCT_DM_SECTION_3_1 File Format
96
97 The format used for documentation is MarkDown with Doxygen extensions. 
98 The MarkDown files have a <i>*.md</i> extension and are based on rules described in \ref OCCT_DM_SECTION_A section.
99
100 @subsection  OCCT_DM_SECTION_3_2 Directory Structure
101
102 @figure{/dev_guides/documentation/images/documentation_folders.png}
103
104 Each document has its own folder if there are any images used in it. These images are stored in *images* subfolder.
105
106 If you want to use the same image for several documents, you can place it in *dox/resources* folder.
107
108 **Note**: To avoid incorrect image display, use a relative path to the image (starting from *dox* folder). For instance:
109
110
111 @verbatim
112 @figure{/dev_guides/documentation/images/documentation_test_image.svg}
113 @endverbatim
114
115
116 The documentation is generated in subfolder *doc* :
117 * *html* - a directory for generated HTML pages;
118 * *pdf* - a directory for generated PDF files.
119
120 @section  OCCT_DM_SECTION_4 Adding a New Document
121
122 Place a new document in the folder taking into account its logical position in the documentation hierarchy. For instance, the document *svn.md* about the use of SVN to work with OCCT source code can be placed into <i>/dox/dev_guides/</i>. 
123
124 If there are images in the document, it should be placed in its own folder containing a subfolder for images. For instance:
125 * <i> /dox/dev_guides/svn/ </i> - for *svn.md* file;
126 * <i> /dox/dev_guides/svn/images/ </i> - for images.
127
128 Add a relative path to *svn.md* in file <i>dox/FILES.txt</i>. For instance
129
130 @verbatim
131 dev_guides/svn/svn.md
132 @endverbatim
133
134 **Note** that the order of paths to documents in *FILES.txt* is reproduced in the Table of Contents in the HTML output. Please, place them logically.
135
136 **Note** that you should specify a file tag, not the document name. See <a href="#OCCT_DM_SECTION_A_1">Header section</a> for details.
137
138 @section  OCCT_DOC_SECTION_5 Additional Resources
139
140 More information about OCCT can be found at http://www.opencascade.org
141
142 The information on formula syntax can be found at: 
143 http://en.wikipedia.org/wiki/Help:Displaying_a_formula
144
145 More information on MarkDown and Doxygen syntax can be found at:
146 http://www.stack.nl/~dimitri/doxygen/manual
147
148 @section  OCCT_DM_SECTION_A Appendix 1: Document Syntax
149
150 A document file in *.md format must start with a proper header defining a caption and a unique tag.
151
152 @verbatim
153 Documentation System {#dev_guides__documentation}
154 =====================
155 @endverbatim
156
157 The document structure is formed by sections that must be defined consistently.
158
159 The document can contain plain text, lists, tables, code snippets, images, math, etc.
160 Any specific text elements can be introduced by Markdown language tags or by usual HTML tags. 
161
162 The table of contents, page numbers (in PDF), and figure numbers (in PDF) are generated automatically.  
163
164 @subsection  OCCT_DM_SECTION_A_1 Headers and hierarchic document structure
165
166 Headers of different levels can be specified with the following tags:
167 * <i>\@section</i> - for the first-level headers; 
168 * <i>\@subsection</i> - for the second level headers;
169 * <i>\@subsubsection</i> - for the third level headers.
170
171 For example:
172
173 @verbatim
174   @section occt_ocaf_1 Basic Concepts
175   @subsection occt_ocaf_1_1 Applications and Documents
176   @subsubsection occt_ocaf_1_1_1 The document and the data framework
177 @endverbatim
178
179 Please, note that section names can be used for references within the document and in other documents, so it is necessary to use the common prefix indicative of the document name for all section names in the given document. 
180 For example,  *occt_ocaf* for sections in Open CASCADE Application Framework manual.
181
182 The remaining part of section names in most documents consists only of numbers, for example *1_1*. Actually, the hierarchical structure of the output table of contents is not based on these numbers and is generated automatically. 
183
184 The numbers are only indicative of a section location in the body of the document. However, duplicate section names in a document inevitably cause errors during generation. 
185
186 If you insert a section in the middle of a big document, do not renumber the document to the end (which is inefficient and error prone), but choose an arbitrary number or letter, not yet used in the document section naming, and base the naming in this section on it.
187
188 The section hierarchy is limited to three levels and further levels cannot be presented in the Table of Contents.
189
190 However, the fourth and fifth level headers can be tagged with  <i>####</i> and <i>#####</i> correspondingly.
191
192 It is also possible to use tags <i>##</i> and <i>###</i> for second and third level headers if you do not wish to show them in the table of contents or make references to them. 
193
194 @subsection OCCT_DM_SECTION_A_2 Plain Text
195
196 A plain text is organized in paragraphs, separated by empty lines in MarkDown source.
197 The length of lines is not restricted; it is recommended to put each sentence on a separate line -- this is optimal for easier comparison of different versions of the same document.
198
199 To insert special symbols, like \< , \> or \\, prepend them with \\ character: \\\<, \\\>, \\\\, etc. 
200 To emphasize a word or a group of words, wrap the text with one pair of asterisks (*) or underscores (_) to make it *italic* and two pairs of these symbols to make it **Bold**.
201
202 **Note** that if your emphasized text starts or ends with a special symbol, the asterisks may not work. Use explicit HTML tags \<i\>\</i\>  and \<b\>\</b\>  instead.
203
204
205 @subsection OCCT_DM_SECTION_A_3 Lists
206
207 To create a bulleted list, start each line with a hyphen or an asterisk, 
208 followed by a space. List items can be nested. This code:
209
210 @verbatim
211 * Bullet 1
212 * Bullet 2
213   - Bullet 2a
214   - Bullet 2b
215 * Bullet 3
216 @endverbatim
217
218 produces this list:
219
220 * Bullet 1
221 * Bullet 2
222   * Bullet 2a
223   * Bullet 2b
224 * Bullet 3  
225
226 To create a numbered list, start each line with number and a period, 
227 then a space. Numbered lists can also be nested. Thus this code 
228
229 @verbatim
230 1. List item 1
231    1. Sub-item 1
232    2. Sub-item 2
233 2. List item 2
234 4. List item 3
235 @endverbatim
236
237 produces this list:
238
239 1. List item 1
240    1. Sub-item 1
241    2. Sub-item 2
242 2. List item 2
243 3. List item 3
244
245 **Note** that numbers of list items in the output are generated so they do not necessarily  follow the numbering of source items.
246
247 In some cases automatic generation adversely restarts the numbering, i.e. you get list items 1. 1. 1. instead of 1. 2. 3. in the output. 
248 The use of explicit HTML tags \<ol\>\</ol\> and  \<li\>\</li\> can help in this case. 
249
250 Each list item can contain several paragraphs of text; these paragraphs must 
251 have the same indentation as text after bullet or number in the numbered list 
252 item (otherwise numbering will be broken). 
253
254 Code blocks can be inserted as paragraphs with additional indentation 
255 (4 spaces more). Note that fenced code blocks do not work within numbered lists
256 and their use may cause numeration to be reset.
257
258
259 Example of a complex nested list:
260
261 1. List item 1
262
263    Additional paragraph
264
265        code fragment
266
267    One more paragraph
268
269    1. Sub-item 1
270
271           code fragment for sub-item 1
272
273    2. Sub-item 2
274
275       Paragraph for sub-item 2
276
277    Yet one more paragraph for list item 1
278
279 2. List item 2
280
281
282 @subsection  OCCT_DM_SECTION_A_4 Tables
283
284 A table consists of a header line, a separator line, and at least one row line. 
285 Table columns are separated by the pipe (|) character. The following example: 
286
287 @verbatim
288 First Header  | Second Header
289 ------------- | -------------
290 Content Cell  | Content Cell 
291 Content Cell  | Content Cell 
292 @endverbatim
293
294   will produce the following table:
295
296 First Header | Second Header
297 ------------ | -------------
298 Content Cell | Content Cell 
299 Content Cell | Content Cell 
300
301 Column alignment can be controlled via one or two colons at the header separator line: 
302
303 @verbatim
304 | Right | Center | Left  |
305 | ----: | :----: | :---- |
306 | 10    | 10     | 10    |
307 | 1000  | 1000   | 1000  |
308 @endverbatim
309
310 which will looks as follows:
311
312 | Right | Center | Left  |
313 | ----: | :----: | :---- |
314 | 10    | 10     | 10    |
315 | 1000  | 1000   | 1000  |
316
317 Note that each table row should be contained in one line of text; complex tables can be created using HTML tags.
318
319 @subsection  OCCT_DM_SECTION_A_5 Code Blocks
320
321 Paragraphs indented with 4 or more spaces are considered as code fragments and rendered using Courier font.
322 Example:
323     
324     This line is indented by 4 spaces and rendered as a code block.
325
326 A fenced code block does not require indentation, and is defined by a pair of "fence lines". 
327 Such line consists of 3 or more tilde (~) characters on a line. 
328 The end of the block should have the same number of tildes. 
329 Thus it is strongly advised to use only three or four tildes. 
330
331 By default the output is the same as for a normal code block.
332 To highlight the code, the developer has to indicate the typical file extension, 
333 which corresponds to the programming language, after the opening fence. 
334 For highlighting according to the C++ language, for instance,  write the following code (the curly braces and dot are optional): 
335
336 @verbatim
337 ~~~{.cpp}
338 int func(int a,int b) { return a*b; }
339 ~~~
340 @endverbatim
341
342 which will produce:
343 ~~~{.cpp} 
344 int func(int a,int b) { return a*b; }
345 ~~~
346
347 Smaller code blocks can be inserted by wrapping with tags <i>\@code</i> and <i>\@endcode</i>.
348
349 Verbatim content (same as code but without syntax highlighting) can be inserted by wrapping with tags <i>\@verbatim</i> and <i>\@endverbatim</i>.
350
351 @subsection  OCCT_DM_SECTION_A_6 References
352
353 To insert a reference to a website, it is sufficient to write an URL.
354 For example: http://en.wikipedia.org
355
356 To insert a reference to a document or its subsection, use command <i>\@ref</i> followed by the document or section tag name.
357 For instance, @code @ref OCCT_DM_SECTION_A @endcode will be rendered as @ref OCCT_DM_SECTION_A.
358
359 Note that links between documents will not work in PDF output if each document is generated independently.
360 Hence it is recommended to add a name of the referenced section after the tag name in the <i>\@ref</i> command (in quotes): this will guarantee that the reference is recognizable for the reader even if the cross-link is not instantiated. 
361 For instance: @code @ref occt_modat_1 "Geometry Utilities" @endcode will be rendered as @ref occt_modat_1 "Geometry Utilities".
362
363 @subsection  OCCT_DM_SECTION_A_7 Images
364
365 For inserting images into the document use the command <i>\@figure</i>, as follows:
366
367 @verbatim
368   @figure{/relative/path/to/image/image_file_name.png,"Image caption"}
369 @endverbatim
370
371 The first argument is a path to the image file, relative to the *dox* folder.
372 The supported formats for images are PNG, JPG, and SVG.
373 The file extension must be lowercase and correspond to the file format.
374 The image file name should have no dots except for the one before extension (names with more than one dot confuse **pdflatex**).
375
376 The second argument is optional, it defines the caption for the image to be inserted.
377 The caption argument, if given, should be quoted, even if it is a single word.
378 Captions are included below the image; in PDF output the images with caption are numbered automatically.
379
380 Example:
381
382 @verbatim
383   @figure{/dev_guides/documentation/images/documentation_test_image.svg,"Test SVG image"}
384 @endverbatim
385
386 is rendered as:
387
388 @figure{/dev_guides/documentation/images/documentation_test_image.svg,"Test SVG image"}
389
390 We recommend using **Inkscape** for creation and edition of vector graphics.
391 The graphics created in MS Word Draw and some other vector editors can be copy-pasted to Inkscape and saved as SVG images.
392
393 Note that the image that will be included in documentation is the whole page of the Inkscape document; use option "Resize page to content" in menu **File -> Document properties** of Inkscape to fit page dimensions to the picture (adding margins as necessary).
394
395 Note that the *figure* command is an alias to the standard Doxygen command *image* repeated twice: once for HTML and then for Latex output (used for PDF generation). Thus if HTML and PDF outputs should include different images or captions, command "image" can be used:
396
397 @verbatim
398   @image html /relative/path/to/image/occ_logo.png
399   @image latex /relative/path/to/image/occ_logo.png "OCC logo"
400 @endverbatim
401
402 @image html /resources/occ_logo.png
403 @image latex /resources/occ_logo.png "OCC logo"
404  
405 @subsection  OCCT_DM_SECTION_A_8 Table Of Contents
406
407 Use \@tableofcontents tag to get the table of contents at the beginning of the document. 
408   
409 Actually, it is not strictly necessary now because TreeView option for HTML is used.
410 The TOC in the PDF document will be generated automatically.
411
412 @subsection  OCCT_DM_SECTION_A_9 Formulas
413
414 Formulas within MarkDown documents can be defined using LaTeX syntax.
415
416 Equations can be written by several ways:
417
418 1.Unnumbered displayed formulas that are centered on a separate line. 
419 These formulas should be put between \@f\[ and \@f\] tags. An example: 
420
421 @verbatim
422 @f[
423     |I_2|=\left| \int_{0}^T \psi(t)
424             \left\{ 
425                 u(a,t)-
426                 \int_{\gamma(t)}^a 
427                 \frac{d\theta}{k(\theta,t)}
428                 \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
429             \right\} dt
430         \right|
431 @f]
432 @endverbatim
433
434 gives the following result:
435
436    @f$
437        |I_2|=\left| \int_{0}^T \psi(t)
438                \left\{ 
439                    u(a,t)-
440                    \int_{\gamma(t)}^a 
441                    \frac{d\theta}{k(\theta,t)}
442                    \int_{a}^\theta c(\xi)u_t(\xi,t)\,d\xi
443                \right\} dt
444            \right|
445    @f$
446    
447 2.Formulas can also be put between @verbatim \begin{align} @endverbatim and @verbatim \end{align} @endverbatim tags. 
448
449   For example: 
450   
451 @verbatim
452   \begin{align}
453   \dot{x} & = \sigma(y-x) \\
454   \dot{y} & = \rho x - y - xz \\
455   \dot{z} & = -\beta z + xy
456   \end{align}
457 @endverbatim
458
459   gives the following result:
460 @latexonly
461   \begin{align}
462   \dot{x} & = \sigma(y-x) \\
463   \dot{y} & = \rho x - y - xz \\
464   \dot{z} & = -\beta z + xy
465   \end{align}
466 @endlatexonly
467
468 @htmlonly
469   \begin{align}
470   \dot{x} & = \sigma(y-x) \\
471   \dot{y} & = \rho x - y - xz \\
472   \dot{z} & = -\beta z + xy
473   \end{align}
474 @endhtmlonly
475
476 3.Inline formulas can be specified using this syntax:
477
478 @verbatim
479   @f$ \sqrt{3x-1}+(1+x)^2 @f$
480 @endverbatim
481
482   that leads to the following result: @f$ \sqrt{3x-1}+(1+x)^2 @f$
483