0024275: Cppcheck warnings on uninitialized class members
[occt.git] / dox / occdoc.tcl
CommitLineData
72b7576f 1# -----------------------------------------------------------------------
2# Script name: CompileDocs.tcl
3# This script compiles OCCT documents from *.md files to HTML pages
4# Author: omy
5# -----------------------------------------------------------------------
6
e5bd0d98 7# get OCCT version from file Standard_Version.hxx (if available)
8proc OverviewDoc_DetectCasVersion {theCasRoot} {
9 set occt_ver 16.7.0
10 set occt_ver_add ""
11 if { [file exist $theCasRoot/src/Standard/Standard_Version.hxx] } {
12 set fh [open $theCasRoot/src/Standard/Standard_Version.hxx]
13 set fh_loaded [read $fh]
14 close $fh
15 regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver
16 regexp {#\s*define\s+OCC_VERSION_DEVELOPMENT\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver_add
17 if { "$occt_ver_add" != "" } { set occt_ver ${occt_ver}.$occt_ver_add }
18 }
19 return $occt_ver
20}
72b7576f 21
e5bd0d98 22# Generates Doxygen configuration file for Overview documentation
23proc OverviewDoc_MakeDoxyfile {casDir outDir tagFileDir {doxyFileName} {generatorMode ""} DocFilesList verboseMode searchMode} {
72b7576f 24
25 set doxyFile [open $doxyFileName "w"]
26 set casroot $casDir
27 set inputDir $casDir/dox
28
29 # Common configs
30 puts $doxyFile "DOXYFILE_ENCODING = UTF-8"
31 puts $doxyFile "PROJECT_NAME = \"Open CASCADE Technology\""
e5bd0d98 32 puts $doxyFile "PROJECT_NUMBER = [OverviewDoc_DetectCasVersion $casDir]"
72b7576f 33 puts $doxyFile "PROJECT_BRIEF = "
e5bd0d98 34 puts $doxyFile "PROJECT_LOGO = $inputDir/resources/occ_logo.png"
72b7576f 35
36 puts $doxyFile "OUTPUT_DIRECTORY = $outDir"
37 puts $doxyFile "CREATE_SUBDIRS = NO"
38 puts $doxyFile "OUTPUT_LANGUAGE = English"
39 puts $doxyFile "ABBREVIATE_BRIEF = \"The \$name class\" \
40 \"The \$name widget\" \
41 \"The \$name file\" \
42 is \
43 provides \
44 specifies \
45 contains \
46 represents \
47 a \
48 an \
49 the"
50
51 puts $doxyFile "FULL_PATH_NAMES = YES"
52 puts $doxyFile "INHERIT_DOCS = YES"
53 puts $doxyFile "TAB_SIZE = 4"
54 puts $doxyFile "MARKDOWN_SUPPORT = YES"
55 puts $doxyFile "EXTRACT_ALL = YES"
56 puts $doxyFile "CASE_SENSE_NAMES = NO"
57 puts $doxyFile "INLINE_INFO = YES"
58 puts $doxyFile "SORT_MEMBER_DOCS = YES"
59 puts $doxyFile "WARNINGS = YES"
60 puts $doxyFile "WARN_IF_UNDOCUMENTED = YES"
61 puts $doxyFile "WARN_IF_DOC_ERROR = YES"
62 puts $doxyFile "WARN_NO_PARAMDOC = NO"
63 puts $doxyFile "WARN_FORMAT = \"\$file:\$line: \$text\""
64 puts $doxyFile "INPUT_ENCODING = UTF-8"
65 puts $doxyFile "FILE_PATTERNS = *.md *.dox "
66 puts $doxyFile "RECURSIVE = YES"
67 puts $doxyFile "SOURCE_BROWSER = NO"
68 puts $doxyFile "INLINE_SOURCES = YES"
69 puts $doxyFile "COLS_IN_ALPHA_INDEX = 5"
70
71 # Generation options
72 puts $doxyFile "GENERATE_DOCSET = NO"
73 puts $doxyFile "GENERATE_HTMLHELP = NO"
74 puts $doxyFile "GENERATE_CHI = NO"
75 puts $doxyFile "GENERATE_QHP = NO"
76 puts $doxyFile "GENERATE_ECLIPSEHELP = NO"
77 puts $doxyFile "GENERATE_RTF = NO"
78 puts $doxyFile "GENERATE_MAN = NO"
79 puts $doxyFile "GENERATE_XML = NO"
80 puts $doxyFile "GENERATE_DOCBOOK = NO"
81 puts $doxyFile "GENERATE_AUTOGEN_DEF = NO"
82 puts $doxyFile "GENERATE_PERLMOD = NO"
83
e5bd0d98 84 set PARAM_INPUT "INPUT ="
85 set PARAM_IMAGEPATH "IMAGE_PATH = $inputDir/resources/ "
72b7576f 86
87 foreach docFile $DocFilesList {
88 set NEW_IMG_PATH [file normalize [file dirname "$inputDir/$docFile"]]
89 if { [string compare $NEW_IMG_PATH $casroot] != 0 } {
90 if {[file isdirectory "$NEW_IMG_PATH/images"]} {
e5bd0d98 91 append PARAM_IMAGEPATH " $NEW_IMG_PATH/images"
72b7576f 92 }
93 }
94 append PARAM_INPUT " " $inputDir/$docFile
95 }
96 puts $doxyFile $PARAM_INPUT
97 puts $doxyFile $PARAM_IMAGEPATH
72b7576f 98
99 if { $generatorMode == "HTML_ONLY"} {
100 # Set a reference to a TAGFILE
101 if { $tagFileDir != "" } {
102 if {[file exists $tagFileDir/OCCT.tag] == 1} {
103 set tagPath [OverviewDoc_GetRelPath $tagFileDir $outDir/html]
104 puts $doxyFile "TAGFILES = $tagFileDir/OCCT.tag=$tagPath/html"
105 }
106 }
72b7576f 107 # HTML Output
108 puts $doxyFile "GENERATE_LATEX = NO"
109 puts $doxyFile "GENERATE_HTML = YES"
110 puts $doxyFile "HTML_COLORSTYLE_HUE = 220"
111 puts $doxyFile "HTML_COLORSTYLE_SAT = 100"
112 puts $doxyFile "HTML_COLORSTYLE_GAMMA = 80"
113 puts $doxyFile "HTML_TIMESTAMP = YES"
114 puts $doxyFile "HTML_DYNAMIC_SECTIONS = YES"
115 puts $doxyFile "HTML_INDEX_NUM_ENTRIES = 100"
116 puts $doxyFile "DISABLE_INDEX = YES"
117 puts $doxyFile "GENERATE_TREEVIEW = YES"
118 puts $doxyFile "ENUM_VALUES_PER_LINE = 8"
119 puts $doxyFile "TREEVIEW_WIDTH = 250"
120 puts $doxyFile "EXTERNAL_PAGES = NO"
e5bd0d98 121 # HTML Search engine options
122 if { [string tolower $searchMode] == "none" } {
123 puts $doxyFile "SEARCHENGINE = NO"
124 puts $doxyFile "SERVER_BASED_SEARCH = NO"
125 puts $doxyFile "EXTERNAL_SEARCH = NO"
126 } else {
127 puts $doxyFile "SEARCHENGINE = YES"
128 if { [string tolower $searchMode] == "local" } {
129 puts $doxyFile "SERVER_BASED_SEARCH = NO"
130 puts $doxyFile "EXTERNAL_SEARCH = NO"
131 } elseif { [string tolower $searchMode] == "server" } {
132 puts $doxyFile "SERVER_BASED_SEARCH = YES"
133 puts $doxyFile "EXTERNAL_SEARCH = NO"
134 } elseif { [string tolower $searchMode] == "external" } {
135 puts $doxyFile "SERVER_BASED_SEARCH = YES"
136 puts $doxyFile "EXTERNAL_SEARCH = YES"
137 } else {
138 puts "ERROR: Wrong search engine type"
139 close $doxyFile
140 return
141 }
142 }
72b7576f 143 puts $doxyFile "SEARCHDATA_FILE = searchdata.xml"
144 puts $doxyFile "SKIP_FUNCTION_MACROS = YES"
145 # Formula options
146 puts $doxyFile "FORMULA_FONTSIZE = 12"
147 puts $doxyFile "FORMULA_TRANSPARENT = YES"
148 puts $doxyFile "USE_MATHJAX = YES"
149 puts $doxyFile "MATHJAX_FORMAT = HTML-CSS"
150 puts $doxyFile "MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest"
151
152 } elseif { $generatorMode == "PDF_ONLY"} {
153
154 puts $doxyFile "GENERATE_HTML = NO"
155 puts $doxyFile "DISABLE_INDEX = YES"
156 puts $doxyFile "GENERATE_TREEVIEW = NO"
157 puts $doxyFile "PREDEFINED = PDF_ONLY"
158 puts $doxyFile "GENERATE_LATEX = YES"
159 puts $doxyFile "COMPACT_LATEX = YES"
160 puts $doxyFile "PDF_HYPERLINKS = YES"
161 puts $doxyFile "USE_PDFLATEX = YES"
162 puts $doxyFile "LATEX_BATCHMODE = YES"
163 puts $doxyFile "LATEX_OUTPUT = latex"
164 puts $doxyFile "LATEX_CMD_NAME = latex"
165 puts $doxyFile "MAKEINDEX_CMD_NAME = makeindex"
166 }
167
168 close $doxyFile
169}
170
171# Returns the relative path between two directories
172proc OverviewDoc_GetRelPath {targetFile currentpath} {
173 set cc [file split [file normalize $currentpath]]
174 set tt [file split [file normalize $targetFile]]
175
176 if {![string equal [lindex $cc 0] [lindex $tt 0]]} {
177 # not on *n*x then
178 return -code error "$targetFile not on same volume as $currentpath"
179 }
180 while {[string equal [lindex $cc 0] [lindex $tt 0]] && [llength $cc] > 0} {
181 # discard matching components from the front
182 set cc [lreplace $cc 0 0]
183 set tt [lreplace $tt 0 0]
184 }
185 set prefix ""
186 if {[llength $cc] == 0} {
187 # just the file name, so targetFile is lower down (or in same place)
188 set prefix "."
189 }
190 # step up the tree
191 for {set i 0} {$i < [llength $cc]} {incr i} {
192 append prefix " .."
193 }
194 # stick it all together (the eval is to flatten the targetFile list)
195 return [eval file join $prefix $tt]
196}
197
198# Prints Help message
199proc OverviewDoc_PrintHelpMessage {} {
e5bd0d98 200 puts "\nUsage : occdoc \[-h\] \[-html\] \[-pdf\] \[-m=<list of files>\] \[-l=<document name>\] \[-v\] \[-s\]"
72b7576f 201 puts ""
202 puts " Options are : "
203 puts " -html : To generate HTML files"
204 puts " (cannot be used with -pdf)"
205 puts " -pdf : To generate PDF files"
206 puts " (cannot be used with -html)"
207 puts " -m=<modules_list> : Specifies list of documents to generate."
208 puts " If it is not specified, all files, "
209 puts " mentioned in FILES.txt are processed."
210 puts " -l=<document_name> : Specifies the document caption "
211 puts " for a single document"
212 puts " -h : Prints help message"
213 puts " -v : Specifies the Verbose mode"
214 puts " (info on all script actions is shown)"
e5bd0d98 215 puts " -s=<search_mode> : Specifies the Search mode of HTML documents."
216 puts " Can be: none | local | server | external | "
217 puts " : Can be used only with -html option"
72b7576f 218}
219
220# Parses command line arguments
221proc OverviewDoc_ParseArguments {arguments} {
222 global args_names
223 global args_values
224 set args_names {}
225 array set args_values {}
226
227 foreach arg $arguments {
228 if {[regexp {^(-)[a-z]+$} $arg] == 1} {
229 set name [string range $arg 1 [string length $arg]-1]
230 lappend args_names $name
231 set args_values($name) "NULL"
232 continue
233 } elseif {[regexp {^(-)[a-z]+=.+$} $arg] == 1} {
234 set equal_symbol_position [string first "=" $arg]
235 set name [string range $arg 1 $equal_symbol_position-1]
236 lappend args_names $name
237 set value [string range $arg $equal_symbol_position+1 [string length $arguments]-1]
238
239 # To parse a list of values for -m parameter
240 if { [string first "," $value] != -1 } {
241 set value [split $value ","];
242 }
243 set args_values($name) $value
244 } else {
245 puts "Error in argument $arg"
246 return 1
247 }
248 }
249 return 0
250}
251
252# Loads a list of docfiles from file FILES.txt
253proc OverviewDoc_LoadFilesList {} {
254
255 set INPUTDIR [file normalize [file dirname [info script]]]
256
257 global available_docfiles
258 set available_docfiles {}
259
260 # Read data from file
261 if { [file exists "$INPUTDIR/FILES.txt"] == 1 } {
262 set FILE [open "$INPUTDIR/FILES.txt" r]
263 while {1} {
e5bd0d98 264 set line [string trim [gets $FILE]]
265
266 # trim possible comments starting with '#'
267 set line [regsub {\#.*} $line {}]
268
72b7576f 269 if {$line != ""} {
270 lappend available_docfiles $line
271 }
272
273 if {[eof $FILE]} {
274 close $FILE
275 break
276 }
277 }
278 } else {
279 return -1
280 }
281 return 0
282}
283
284# Writes new tex file for conversion from tex to pdf for a specific doc
285proc OverviewDoc_MakeRefmanTex {fileName latexDir docLabel verboseMode} {
286
287 if {$verboseMode == "YES"} {
288 puts "INFO: Making refman.tex file for $fileName"
289 }
290 set DOCNAME "$latexDir/refman.tex"
291 if {[file exists $DOCNAME] == 1} {
292 file delete -force $DOCNAME
293 }
294 set texfile [open $DOCNAME w]
295
296 puts $texfile "\\batchmode"
297 puts $texfile "\\nonstopmode"
298 puts $texfile "\\documentclass\[oneside\]{article}"
299 puts $texfile "\n% Packages required by doxygen"
300 puts $texfile "\\usepackage{calc}"
301 puts $texfile "\\usepackage{doxygen}"
302 puts $texfile "\\usepackage{graphicx}"
303 puts $texfile "\\usepackage\[utf8\]{inputenc}"
304 puts $texfile "\\usepackage{makeidx}"
305 puts $texfile "\\usepackage{multicol}"
306 puts $texfile "\\usepackage{multirow}"
307 puts $texfile "\\usepackage{textcomp}"
308 puts $texfile "\\usepackage{amsmath}"
309 puts $texfile "\\usepackage\[table\]{xcolor}"
310 puts $texfile "\\usepackage{indentfirst}"
311 puts $texfile ""
312 puts $texfile "% Font selection"
313 puts $texfile "\\usepackage\[T1\]{fontenc}"
314 puts $texfile "\\usepackage{mathptmx}"
315 puts $texfile "\\usepackage\[scaled=.90\]{helvet}"
316 puts $texfile "\\usepackage{courier}"
317 puts $texfile "\\usepackage{amssymb}"
318 puts $texfile "\\usepackage{sectsty}"
319 puts $texfile "\\renewcommand{\\familydefault}{\\sfdefault}"
320 puts $texfile "\\allsectionsfont{%"
321 puts $texfile " \\fontseries{bc}\\selectfont%"
322 puts $texfile " \\color{darkgray}%"
323 puts $texfile "}"
324 puts $texfile "\\renewcommand{\\DoxyLabelFont}{%"
325 puts $texfile " \\fontseries{bc}\\selectfont%"
326 puts $texfile " \\color{darkgray}%"
327 puts $texfile "}"
328 puts $texfile ""
329 puts $texfile "% Page & text layout"
330 puts $texfile "\\usepackage{geometry}"
331 puts $texfile "\\geometry{%"
332 puts $texfile " a4paper,%"
333 puts $texfile " top=2.5cm,%"
334 puts $texfile " bottom=2.5cm,%"
335 puts $texfile " left=2.5cm,%"
336 puts $texfile " right=2.5cm%"
337 puts $texfile "}"
338 puts $texfile "\\tolerance=750"
339 puts $texfile "\\hfuzz=15pt"
340 puts $texfile "\\hbadness=750"
341 puts $texfile "\\setlength{\\emergencystretch}{15pt}"
e5bd0d98 342 puts $texfile "\\setlength{\\parindent}{0cm}";#0.75cm
343 puts $texfile "\\setlength{\\parskip}{0.2cm}"; #0.2
72b7576f 344 puts $texfile "\\makeatletter"
345 puts $texfile "\\renewcommand{\\paragraph}{%"
346 puts $texfile " \@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{%"
347 puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@parafont%"
348 puts $texfile " }%"
349 puts $texfile "}"
350 puts $texfile "\\renewcommand{\\subparagraph}{%"
351 puts $texfile " \\@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{%"
352 puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@subparafont%"
353 puts $texfile " }%"
354 puts $texfile "}"
355 puts $texfile "\\makeatother"
356 puts $texfile ""
357 puts $texfile "% Headers & footers"
358 puts $texfile "\\usepackage{fancyhdr}"
359 puts $texfile "\\pagestyle{fancyplain}"
360 puts $texfile "\\fancyhead\[LE\]{\\fancyplain{}{\\bfseries\\thepage}}"
361 puts $texfile "\\fancyhead\[CE\]{\\fancyplain{}{}}"
362 puts $texfile "\\fancyhead\[RE\]{\\fancyplain{}{\\bfseries\\leftmark}}"
363 puts $texfile "\\fancyhead\[LO\]{\\fancyplain{}{\\bfseries\\rightmark}}"
364 puts $texfile "\\fancyhead\[CO\]{\\fancyplain{}{}}"
365 puts $texfile "\\fancyhead\[RO\]{\\fancyplain{}{\\bfseries\\thepage}}"
366 puts $texfile "\\fancyfoot\[LE\]{\\fancyplain{}{}}"
367 puts $texfile "\\fancyfoot\[CE\]{\\fancyplain{}{}}"
e5bd0d98 368 puts $texfile "\\fancyfoot\[RE\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}"
369 puts $texfile "\\fancyfoot\[LO\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}"
72b7576f 370 puts $texfile "\\fancyfoot\[CO\]{\\fancyplain{}{}}"
371 puts $texfile "\\fancyfoot\[RO\]{\\fancyplain{}{}}"
372 puts $texfile "\\renewcommand{\\footrulewidth}{0.4pt}"
373 puts $texfile "\\renewcommand{\\sectionmark}\[1\]{%"
374 puts $texfile " \\markright{\\thesection\\ #1}%"
375 puts $texfile "}"
376 puts $texfile ""
377 puts $texfile "% Indices & bibliography"
378 puts $texfile "\\usepackage{natbib}"
379 puts $texfile "\\usepackage\[titles\]{tocloft}"
380 puts $texfile "\\renewcommand{\\cftsecleader}{\\cftdotfill{\\cftdotsep}}"
381 puts $texfile "\\setcounter{tocdepth}{3}"
382 puts $texfile "\\setcounter{secnumdepth}{5}"
383 puts $texfile "\\makeindex"
384 puts $texfile ""
385 puts $texfile "% Hyperlinks (required, but should be loaded last)"
386 puts $texfile "\\usepackage{ifpdf}"
387 puts $texfile "\\ifpdf"
388 puts $texfile " \\usepackage\[pdftex,pagebackref=true\]{hyperref}"
389 puts $texfile "\\else"
390 puts $texfile " \\usepackage\[ps2pdf,pagebackref=true\]{hyperref}"
391 puts $texfile "\\fi"
392 puts $texfile "\\hypersetup{%"
393 puts $texfile " colorlinks=true,%"
394 puts $texfile " linkcolor=black,%"
395 puts $texfile " citecolor=black,%"
396 puts $texfile " urlcolor=blue,%"
397 puts $texfile " unicode%"
398 puts $texfile "}"
399 puts $texfile ""
400 puts $texfile "% Custom commands"
401 puts $texfile "\\newcommand{\\clearemptydoublepage}{%"
402 puts $texfile " \\newpage{\\pagestyle{empty}\\cleardoublepage}%"
403 puts $texfile "}"
404 puts $texfile "\n"
405 puts $texfile "%===== C O N T E N T S =====\n"
406 puts $texfile "\\begin{document}"
407 puts $texfile ""
408 puts $texfile "% Titlepage & ToC"
409 puts $texfile "\\hypersetup{pageanchor=false}"
410 puts $texfile "\\pagenumbering{roman}"
411 puts $texfile "\\begin{titlepage}"
412 puts $texfile "\\vspace*{7cm}"
413 puts $texfile "\\begin{center}%"
e5bd0d98 414 puts $texfile "\\includegraphics\[width=0.75\\textwidth, height=0.2\\textheight\]{../../../dox/resources/occt_logo.png}\\\\"; #\\\\\\\\
415 puts $texfile "{\\Large Open C\\-A\\-S\\-C\\-A\\-D\\-E Technology \\\\\[1ex\]\\Large [OverviewDoc_DetectCasVersion $latexDir/../../../] }\\\\"
72b7576f 416 puts $texfile "\\vspace*{1cm}"
417 puts $texfile "{\\Large $docLabel}\\\\"
418 puts $texfile "\\vspace*{1cm}"
419 puts $texfile "{\\large Generated by Doxygen 1.8.4}\\\\"
420 puts $texfile "\\vspace*{0.5cm}"
421 puts $texfile "{\\small \\today}\\"
422 puts $texfile "\\end{center}"
423 puts $texfile "\\end{titlepage}"
424 puts $texfile "\\clearpage"
425 puts $texfile "\\pagenumbering{roman}"
426 puts $texfile "\\tableofcontents"
427 puts $texfile "\\newpage"
428 puts $texfile "\\pagenumbering{arabic}"
429 puts $texfile "\\hypersetup{pageanchor=true}"
430 puts $texfile ""
e5bd0d98 431 puts $texfile "\\let\\stdsection\\section"
432 puts $texfile " \\renewcommand\\section{\\pagebreak\\stdsection}"
72b7576f 433 puts $texfile "\\hypertarget{$fileName}{}"
434 puts $texfile "\\input{$fileName}"
435 puts $texfile ""
436 puts $texfile "% Index"
437 puts $texfile "\\newpage"
438 puts $texfile "\\phantomsection"
439 puts $texfile "\\addcontentsline{toc}{part}{Index}"
440 puts $texfile "\\printindex\n"
441 puts $texfile "\\end{document}"
442
443 close $texfile
444}
445
446# Postprocesses generated TeX files
447proc OverviewDoc_ProcessTex {{texFiles {}} {latexDir} verboseMode} {
448
449 foreach TEX $texFiles {
450 if {$verboseMode == "YES"} {
451 puts "INFO: Preprocessing file $TEX"
452 }
dba69de2 453
454 if {![file exists $TEX]} {
455 puts "file $TEX doesn't exist"
456 return
457 }
458
72b7576f 459 set IN_F [open "$TEX" r]
460 set TMPFILENAME "$latexDir/temp.tex"
dba69de2 461
72b7576f 462 set OUT_F [open $TMPFILENAME w]
463
464 while {1} {
465 set line [gets $IN_F]
466 if { [string first "\\includegraphics" $line] != -1 } {
467 # Center images in TeX files
468 set line "\\begin{center}\n $line\n\\end{center}"
469 } elseif { [string first "\\subsection" $line] != -1 } {
470 # Replace \subsection with \section tag
471 regsub -all "\\\\subsection" $line "\\\\section" line
472 } elseif { [string first "\\subsubsection" $line] != -1 } {
473 # Replace \subsubsection with \subsection tag
474 regsub -all "\\\\subsubsection" $line "\\\\subsection" line
475 } elseif { [string first "\\paragraph" $line] != -1 } {
476 # Replace \paragraph with \subsubsection tag
477 regsub -all "\\\\paragraph" $line "\\\\subsubsection" line
478 }
479 puts $OUT_F $line
480
481 if {[eof $IN_F]} {
482 close $IN_F
483 close $OUT_F
484 break
485 }
486 }
487 file delete -force $TEX
488 file rename $TMPFILENAME $TEX
489 }
490}
491
492# Main procedure for documents compilation
e5bd0d98 493proc OverviewDoc_Main { {docfiles {}} generatorMode docLabel verboseMode searchMode} {
72b7576f 494
495 set INDIR [file normalize [file dirname [info script]]]
496 set CASROOT [file normalize [file dirname "$INDIR/../../"]]
497 set OUTDIR $CASROOT/doc
498 set PDFDIR $OUTDIR/overview/pdf
499 set HTMLDIR $OUTDIR/overview/html
500 set LATEXDIR $OUTDIR/overview/latex
501 set TAGFILEDIR $OUTDIR/refman
502 set DOXYFILE $OUTDIR/OCCT.cfg
503
504 # Create or clean the output folders
505 if {[file exists $OUTDIR] == 0} {
506 file mkdir $OUTDIR
507 }
508 if {[file exists $HTMLDIR] == 0} {
509 file mkdir $HTMLDIR
510 }
72b7576f 511 if {[file exists $PDFDIR] == 0} {
512 file mkdir $PDFDIR
513 }
e5bd0d98 514
515 if {[file exists $LATEXDIR]} {
516 #file delete {*}[glob -nocomplain $LATEXDIR/*.*]
517 file delete -force $LATEXDIR
518 }
519 file mkdir $LATEXDIR
72b7576f 520
521 # Run tools to compile documents
e5bd0d98 522 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating Doxyfile..."
523
524 OverviewDoc_MakeDoxyfile $CASROOT "$OUTDIR/overview" $TAGFILEDIR $DOXYFILE $generatorMode $docfiles $verboseMode $searchMode
72b7576f 525
526 # Run doxygen tool
527 if { $generatorMode == "HTML_ONLY"} {
e5bd0d98 528 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating HTML files..."
72b7576f 529 }
530 set RESULT [catch {exec doxygen $DOXYFILE > $OUTDIR/doxygen_out.log} DOX_ERROR]
531 if {$RESULT != 0} {
532 if {[llength [split $DOX_ERROR "\n"]] > 1} {
533 if {$verboseMode == "YES"} {
e5bd0d98 534 puts "See Doxygen log in $OUTDIR/doxygen_warnings_and_errors.log"
72b7576f 535 }
536 set DOX_ERROR_FILE [open "$OUTDIR/doxygen_warnings_and_errors.log" "w"]
537 puts $DOX_ERROR_FILE $DOX_ERROR
538 close $DOX_ERROR_FILE
539 } else {
540 puts $DOX_ERROR
541 }
542 }
543 # Close the Doxygen application
544 after 300
545
546 # Start PDF generation routine
547 if { $generatorMode == "PDF_ONLY" } {
e5bd0d98 548 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating PDF files..."
72b7576f 549
550 set OS $::tcl_platform(platform)
551 if { $OS == "unix" } {
552 set PREFIX ".sh"
553 } elseif { $OS == "windows" } {
554 set PREFIX ".bat"
555 }
556
557 # Prepare a list of TeX files, generated by Doxygen
558 cd $LATEXDIR
559
560 set TEXFILES [glob $LATEXDIR -type f -directory $LATEXDIR -tails "*.tex" ]
561 set REFMAN_IDX [lsearch $TEXFILES "refman.tex"]
562 set TEXFILES [lreplace $TEXFILES $REFMAN_IDX $REFMAN_IDX]
dba69de2 563
72b7576f 564
565 set IDX [lsearch $TEXFILES "$LATEXDIR"]
566 while { $IDX != -1} {
567 set TEXFILES [lreplace $TEXFILES $IDX $IDX]
568 set IDX [lsearch $TEXFILES "$LATEXDIR"]
569 }
570
e5bd0d98 571 if {$verboseMode == "YES"} {
572 puts "Preprocessing generated TeX files..."
573 }
72b7576f 574 OverviewDoc_ProcessTex $TEXFILES $LATEXDIR $verboseMode
e5bd0d98 575
576 if {$verboseMode == "YES"} {
577 puts "Generating PDF files from TeX files..."
578 }
72b7576f 579 foreach TEX $TEXFILES {
580 # Rewrite existing REFMAN.tex file...
581 set TEX [string range $TEX 0 [ expr "[string length $TEX] - 5"]]
582 OverviewDoc_MakeRefmanTex $TEX $LATEXDIR $docLabel $verboseMode
583
584 if {$verboseMode == "YES"} {
585 puts "INFO: Generating PDF file from $TEX"
e5bd0d98 586 # ...and use it to generate PDF from TeX...
587 puts "Executing $LATEXDIR/make$PREFIX..."
72b7576f 588 }
72b7576f 589 set RESULT [catch {eval exec [auto_execok $LATEXDIR/make$PREFIX] > "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR]
590 if {$RESULT != 0} {
591 if {[llength [split $LaTeX_ERROR "\n"]] > 1} {
e5bd0d98 592 if {$verboseMode == "YES"} {
593 puts "See Latex log in $OUTDIR/pdflatex_warnings_and_errors.log"
594 }
72b7576f 595 set LaTeX_ERROR_FILE [open "$OUTDIR/pdflatex_warnings_and_errors.log" "w"]
596 puts $LaTeX_ERROR_FILE $LaTeX_ERROR
597 close $LaTeX_ERROR_FILE
598 } else {
599 puts $DOX_ERROR
600 }
601 }
602
603 # ...and place it to the specific folder
604 if { [file exists $PDFDIR/$TEX.pdf] == 1 } {
605 file delete -force $PDFDIR/$TEX.pdf
606 }
dba69de2 607
608 if {![file exists "$LATEXDIR/refman.pdf"]} {
e5bd0d98 609 puts "Error: file $LATEXDIR/refman.pdf does not exist"
dba69de2 610 return
611 }
612
72b7576f 613 file rename $LATEXDIR/refman.pdf "$PDFDIR/$TEX.pdf"
614 }
72b7576f 615 }
616
617 cd $INDIR
e5bd0d98 618 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generation completed"
72b7576f 619 if { $generatorMode == "HTML_ONLY" } {
e5bd0d98 620 puts "View generated HTML documentation by opening: "
72b7576f 621 set RESFILE $OUTDIR/overview/html/index.html
e5bd0d98 622 puts "$RESFILE"
72b7576f 623 }
624 if { $generatorMode == "PDF_ONLY" } {
e5bd0d98 625 puts "PDF files are generated in: "
626 puts "$OUTDIR/overview/pdf folder"
72b7576f 627 }
72b7576f 628}
629
630# A command for User Documentation compilation
631proc occdoc {args} {
632 # Programm options
e5bd0d98 633 set GEN_MODE "HTML_ONLY"
634
72b7576f 635 set DOCFILES {}
e5bd0d98 636 set DOCLABEL "Default OCCT Document"
637 set VERB_MODE "NO"
638 set SEARCH_MODE "none"
639
72b7576f 640 global available_docfiles
641 global args_names
642 global args_values
643
644 # Load list of docfiles
645 if { [OverviewDoc_LoadFilesList] != 0 } {
646 puts "ERROR: File FILES.txt was not found"
647 return
648 }
649
650 # Parse CL arguments
651 if {[OverviewDoc_ParseArguments $args] == 1} {
652 return
653 }
e5bd0d98 654
655 foreach arg_n $args_names {
656 if {$arg_n == "h"} {
657 OverviewDoc_PrintHelpMessage
658 return
659 } elseif {$arg_n == "html"} {
72b7576f 660 set GEN_MODE "HTML_ONLY"
e5bd0d98 661 } elseif {$arg_n == "pdf"} {
72b7576f 662 set GEN_MODE "PDF_ONLY"
e5bd0d98 663 } elseif {$arg_n == "v"} {
664 set VERB_MODE "YES"
665 } elseif {$arg_n == "m"} {
666 if {$args_values(m) != "NULL"} {
667 set DOCFILES $args_values(m)
668 } else {
669 puts "Error in argument m"
670 return
671 }
672
673 # Check if all chosen docfiles are correct
674 foreach docfile $DOCFILES {
675 if { [lsearch $available_docfiles $docfile] == -1 } {
676 puts "File \"$docfile\" is not presented in the list of available docfiles"
677 puts "Please, specify the correct docfile name"
678 return
679 } else {
680 puts "File $docfile is presented in FILES.TXT"
681 }
682 }
683 } elseif {$arg_n == "l"} {
684 if { [llength $DOCFILES] <= 1 } {
685 if {$args_values(l) != "NULL"} {
686 set DOCLABEL $args_values(l)
687 } else {
688 puts "Error in argument l"
689 return
72b7576f 690 }
e5bd0d98 691 }
692 } elseif {$arg_n == "s"} {
693 if {$args_values(s) != "NULL"} {
694 set SEARCH_MODE $args_values(s)
695 } else {
696 puts "Error in argument s"
72b7576f 697 return
e5bd0d98 698 }
699 } else {
700 puts "\nWrong argument: $arg_n"
701 OverviewDoc_PrintHelpMessage
702 return
72b7576f 703 }
e5bd0d98 704 }
705
706 # Specify verbose mode
707 if { $GEN_MODE != "PDF_ONLY" && [llength $DOCFILES] > 1 } {
708 set DOCLABEL ""
709 }
72b7576f 710
e5bd0d98 711 # If we don't specify list for docfiles with -m argument,
712 # we assume that we have to generate all docfiles
713 if { [llength $DOCFILES] == 0 } {
714 set DOCFILES $available_docfiles
715 }
72b7576f 716
e5bd0d98 717 # Start main activities
718 OverviewDoc_Main $DOCFILES $GEN_MODE $DOCLABEL $VERB_MODE $SEARCH_MODE
72b7576f 719}