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