1 # -----------------------------------------------------------------------
2 # Script name: CompileDocs.tcl
3 # This script compiles OCCT documents from *.md files to HTML pages
5 # -----------------------------------------------------------------------
7 # get OCCT version from file Standard_Version.hxx (if available)
8 proc OverviewDoc_DetectCasVersion {theCasRoot} {
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]
15 regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver
16 regexp {[^/]\s*#\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 }
22 # Generates Doxygen configuration file for Overview documentation
23 proc OverviewDoc_MakeDoxyfile {casDir outDir tagFileDir {doxyFileName} {generatorMode ""} DocFilesList verboseMode searchMode hhcPath mathjaxLocation} {
25 set doxyFile [open $doxyFileName "w"]
27 set inputDir $casDir/dox
30 puts $doxyFile "DOXYFILE_ENCODING = UTF-8"
31 puts $doxyFile "PROJECT_NAME = \"Open CASCADE Technology\""
32 puts $doxyFile "PROJECT_NUMBER = [OverviewDoc_DetectCasVersion $casDir]"
33 puts $doxyFile "PROJECT_BRIEF = "
34 puts $doxyFile "PROJECT_LOGO = $inputDir/resources/occ_logo.png"
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\" \
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"
72 puts $doxyFile "GENERATE_DOCSET = NO"
73 puts $doxyFile "GENERATE_CHI = NO"
74 puts $doxyFile "GENERATE_QHP = NO"
75 puts $doxyFile "GENERATE_ECLIPSEHELP = NO"
76 puts $doxyFile "GENERATE_RTF = NO"
77 puts $doxyFile "GENERATE_MAN = NO"
78 puts $doxyFile "GENERATE_XML = NO"
79 puts $doxyFile "GENERATE_DOCBOOK = NO"
80 puts $doxyFile "GENERATE_AUTOGEN_DEF = NO"
81 puts $doxyFile "GENERATE_PERLMOD = NO"
83 # Keep doxygen comments within code blocks
84 puts $doxyFile "STRIP_CODE_COMMENTS = NO"
86 set PARAM_INPUT "INPUT ="
87 set PARAM_IMAGEPATH "IMAGE_PATH = $inputDir/resources/ "
89 foreach docFile $DocFilesList {
90 set NEW_IMG_PATH [file normalize [file dirname "$inputDir/$docFile"]]
91 if { [string compare $NEW_IMG_PATH $casroot] != 0 } {
92 if {[file isdirectory "$NEW_IMG_PATH/images"]} {
93 append PARAM_IMAGEPATH " $NEW_IMG_PATH/images"
96 append PARAM_INPUT " " $inputDir/$docFile
98 puts $doxyFile $PARAM_INPUT
99 puts $doxyFile $PARAM_IMAGEPATH
101 if { $generatorMode == "HTML_ONLY"} {
102 # Set a reference to a TAGFILE
103 if { $tagFileDir != "" } {
104 if {[file exists $tagFileDir/OCCT.tag] == 1} {
105 set tagPath [OverviewDoc_GetRelPath $tagFileDir $outDir/html]
106 puts $doxyFile "TAGFILES = $tagFileDir/OCCT.tag=$tagPath/html"
110 puts $doxyFile "GENERATE_LATEX = NO"
111 puts $doxyFile "GENERATE_HTMLHELP = NO"
112 puts $doxyFile "GENERATE_HTML = YES"
113 puts $doxyFile "HTML_COLORSTYLE_HUE = 220"
114 puts $doxyFile "HTML_COLORSTYLE_SAT = 100"
115 puts $doxyFile "HTML_COLORSTYLE_GAMMA = 80"
116 puts $doxyFile "HTML_TIMESTAMP = YES"
117 puts $doxyFile "HTML_DYNAMIC_SECTIONS = YES"
118 puts $doxyFile "HTML_INDEX_NUM_ENTRIES = 100"
119 puts $doxyFile "DISABLE_INDEX = YES"
120 puts $doxyFile "GENERATE_TREEVIEW = YES"
121 puts $doxyFile "ENUM_VALUES_PER_LINE = 8"
122 puts $doxyFile "TREEVIEW_WIDTH = 250"
123 puts $doxyFile "EXTERNAL_PAGES = NO"
124 # HTML Search engine options
125 if { [string tolower $searchMode] == "none" } {
126 puts $doxyFile "SEARCHENGINE = NO"
127 puts $doxyFile "SERVER_BASED_SEARCH = NO"
128 puts $doxyFile "EXTERNAL_SEARCH = NO"
130 puts $doxyFile "SEARCHENGINE = YES"
131 if { [string tolower $searchMode] == "local" } {
132 puts $doxyFile "SERVER_BASED_SEARCH = NO"
133 puts $doxyFile "EXTERNAL_SEARCH = NO"
134 } elseif { [string tolower $searchMode] == "server" } {
135 puts $doxyFile "SERVER_BASED_SEARCH = YES"
136 puts $doxyFile "EXTERNAL_SEARCH = NO"
137 } elseif { [string tolower $searchMode] == "external" } {
138 puts $doxyFile "SERVER_BASED_SEARCH = YES"
139 puts $doxyFile "EXTERNAL_SEARCH = YES"
141 puts "ERROR: Wrong search engine type"
146 puts $doxyFile "SEARCHDATA_FILE = searchdata.xml"
147 puts $doxyFile "SKIP_FUNCTION_MACROS = YES"
149 puts $doxyFile "FORMULA_FONTSIZE = 12"
150 puts $doxyFile "FORMULA_TRANSPARENT = YES"
151 puts $doxyFile "USE_MATHJAX = YES"
152 puts $doxyFile "MATHJAX_FORMAT = HTML-CSS"
153 puts $doxyFile "MATHJAX_RELPATH = ${mathjaxLocation}"
155 } elseif { $generatorMode == "CHM_ONLY"} {
156 puts $doxyFile "GENERATE_HTMLHELP = YES"
157 puts $doxyFile "CHM_FILE = ../../overview.chm"
158 puts $doxyFile "HHC_LOCATION = \"$hhcPath\""
159 puts $doxyFile "DISABLE_INDEX = YES"
161 puts $doxyFile "FORMULA_FONTSIZE = 12"
162 puts $doxyFile "FORMULA_TRANSPARENT = YES"
163 puts $doxyFile "USE_MATHJAX = YES"
164 puts $doxyFile "MATHJAX_FORMAT = HTML-CSS"
165 puts $doxyFile "MATHJAX_RELPATH = ${mathjaxLocation}"
167 } elseif { $generatorMode == "PDF_ONLY"} {
168 puts $doxyFile "GENERATE_HTMLHELP = NO"
169 puts $doxyFile "GENERATE_HTML = NO"
170 puts $doxyFile "DISABLE_INDEX = YES"
171 puts $doxyFile "GENERATE_TREEVIEW = NO"
172 puts $doxyFile "PREDEFINED = PDF_ONLY"
173 puts $doxyFile "GENERATE_LATEX = YES"
174 puts $doxyFile "COMPACT_LATEX = YES"
175 puts $doxyFile "PDF_HYPERLINKS = YES"
176 puts $doxyFile "USE_PDFLATEX = YES"
177 puts $doxyFile "LATEX_BATCHMODE = YES"
178 puts $doxyFile "LATEX_OUTPUT = latex"
179 puts $doxyFile "LATEX_CMD_NAME = latex"
180 puts $doxyFile "MAKEINDEX_CMD_NAME = makeindex"
186 # Returns the relative path between two directories
187 proc OverviewDoc_GetRelPath {targetFile currentpath} {
188 set cc [file split [file normalize $currentpath]]
189 set tt [file split [file normalize $targetFile]]
191 if {![string equal [lindex $cc 0] [lindex $tt 0]]} {
193 return -code error "$targetFile not on same volume as $currentpath"
195 while {[string equal [lindex $cc 0] [lindex $tt 0]] && [llength $cc] > 0} {
196 # discard matching components from the front
197 set cc [lreplace $cc 0 0]
198 set tt [lreplace $tt 0 0]
201 if {[llength $cc] == 0} {
202 # just the file name, so targetFile is lower down (or in same place)
206 for {set i 0} {$i < [llength $cc]} {incr i} {
209 # stick it all together (the eval is to flatten the targetFile list)
210 return [eval file join $prefix $tt]
213 # Prints Help message
214 proc OverviewDoc_PrintHelpMessage {} {
215 puts "\nUsage : occdoc \[-h\] \[-html\] \[-pdf\] \[-m=<list of files>\] \[-l=<document name>\] \[-v\] \[-s\]"
217 puts " Options are : "
218 puts " -html : To generate HTML files"
219 puts " (cannot be used with -pdf or -chm)"
220 puts " -pdf : To generate PDF files"
221 puts " (cannot be used with -html or chm)"
222 puts " -chm : To generate CHM files"
223 puts " (cannot be used with -html or pdf)"
224 puts " -hhc : To define path to hhc - chm generator"
225 puts " : is used with just -chm option"
226 puts " -m=<modules_list> : Specifies list of documents to generate."
227 puts " If it is not specified, all files "
228 puts " mentioned in FILES.txt are processed."
229 puts " -l=<document_name> : Specifies the document caption "
230 puts " for a single document"
231 puts " -h : Prints help message"
232 puts " -v : Specifies the Verbose mode"
233 puts " (info on all script actions is shown)"
234 puts " -s=<search_mode> : Specifies the Search mode of HTML documents."
235 puts " Can be: none | local | server | external"
236 puts " : Can be used only with -html option"
237 puts " -mathjax=<path> : To use local or alternative copy of MathJax"
240 # Parses command line arguments
241 proc OverviewDoc_ParseArguments {arguments} {
245 array set args_values {}
247 foreach arg $arguments {
248 if {[regexp {^(-)[a-z]+$} $arg] == 1} {
249 set name [string range $arg 1 [string length $arg]-1]
250 lappend args_names $name
251 set args_values($name) "NULL"
253 } elseif {[regexp {^(-)[a-z]+=.+$} $arg] == 1} {
254 set equal_symbol_position [string first "=" $arg]
255 set name [string range $arg 1 $equal_symbol_position-1]
256 lappend args_names $name
257 set value [string range $arg $equal_symbol_position+1 [string length $arguments]-1]
259 # To parse a list of values for -m parameter
260 if { [string first "," $value] != -1 } {
261 set value [split $value ","];
263 set args_values($name) $value
265 puts "Error in argument $arg"
272 # Loads a list of docfiles from file FILES.txt
273 proc OverviewDoc_LoadFilesList {} {
275 set INPUTDIR [file normalize [file dirname [info script]]]
277 global available_docfiles
278 set available_docfiles {}
280 # Read data from file
281 if { [file exists "$INPUTDIR/FILES.txt"] == 1 } {
282 set FILE [open "$INPUTDIR/FILES.txt" r]
284 set line [string trim [gets $FILE]]
286 # trim possible comments starting with '#'
287 set line [regsub {\#.*} $line {}]
290 lappend available_docfiles $line
304 # Writes new tex file for conversion from tex to pdf for a specific doc
305 proc OverviewDoc_MakeRefmanTex {fileName latexDir docLabel verboseMode} {
307 if {$verboseMode == "YES"} {
308 puts "INFO: Making refman.tex file for $fileName"
310 set DOCNAME "$latexDir/refman.tex"
311 if {[file exists $DOCNAME] == 1} {
312 file delete -force $DOCNAME
314 set texfile [open $DOCNAME w]
316 puts $texfile "\\batchmode"
317 puts $texfile "\\nonstopmode"
318 puts $texfile "\\documentclass\[oneside\]{article}"
319 puts $texfile "\n% Packages required by doxygen"
320 puts $texfile "\\usepackage{calc}"
321 puts $texfile "\\usepackage{doxygen}"
322 puts $texfile "\\usepackage{graphicx}"
323 puts $texfile "\\usepackage\[utf8\]{inputenc}"
324 puts $texfile "\\usepackage{makeidx}"
325 puts $texfile "\\usepackage{multicol}"
326 puts $texfile "\\usepackage{multirow}"
327 puts $texfile "\\usepackage{textcomp}"
328 puts $texfile "\\usepackage{amsmath}"
329 puts $texfile "\\usepackage\[table\]{xcolor}"
330 puts $texfile "\\usepackage{indentfirst}"
332 puts $texfile "% Font selection"
333 puts $texfile "\\usepackage\[T1\]{fontenc}"
334 puts $texfile "\\usepackage{mathptmx}"
335 puts $texfile "\\usepackage\[scaled=.90\]{helvet}"
336 puts $texfile "\\usepackage{courier}"
337 puts $texfile "\\usepackage{amssymb}"
338 puts $texfile "\\usepackage{sectsty}"
339 puts $texfile "\\renewcommand{\\familydefault}{\\sfdefault}"
340 puts $texfile "\\allsectionsfont{%"
341 puts $texfile " \\fontseries{bc}\\selectfont%"
342 puts $texfile " \\color{darkgray}%"
344 puts $texfile "\\renewcommand{\\DoxyLabelFont}{%"
345 puts $texfile " \\fontseries{bc}\\selectfont%"
346 puts $texfile " \\color{darkgray}%"
349 puts $texfile "% Page & text layout"
350 puts $texfile "\\usepackage{geometry}"
351 puts $texfile "\\geometry{%"
352 puts $texfile " a4paper,%"
353 puts $texfile " top=2.5cm,%"
354 puts $texfile " bottom=2.5cm,%"
355 puts $texfile " left=2.5cm,%"
356 puts $texfile " right=2.5cm%"
358 puts $texfile "\\tolerance=750"
359 puts $texfile "\\hfuzz=15pt"
360 puts $texfile "\\hbadness=750"
361 puts $texfile "\\setlength{\\emergencystretch}{15pt}"
362 puts $texfile "\\setlength{\\parindent}{0cm}";#0.75cm
363 puts $texfile "\\setlength{\\parskip}{0.2cm}"; #0.2
364 puts $texfile "\\makeatletter"
365 puts $texfile "\\renewcommand{\\paragraph}{%"
366 puts $texfile " \@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{%"
367 puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@parafont%"
370 puts $texfile "\\renewcommand{\\subparagraph}{%"
371 puts $texfile " \\@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{%"
372 puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@subparafont%"
375 puts $texfile "\\makeatother"
377 puts $texfile "% Headers & footers"
378 puts $texfile "\\usepackage{fancyhdr}"
379 puts $texfile "\\pagestyle{fancyplain}"
380 puts $texfile "\\fancyhead\[LE\]{\\fancyplain{}{\\bfseries\\thepage}}"
381 puts $texfile "\\fancyhead\[CE\]{\\fancyplain{}{}}"
382 puts $texfile "\\fancyhead\[RE\]{\\fancyplain{}{\\bfseries\\leftmark}}"
383 puts $texfile "\\fancyhead\[LO\]{\\fancyplain{}{\\bfseries\\rightmark}}"
384 puts $texfile "\\fancyhead\[CO\]{\\fancyplain{}{}}"
385 puts $texfile "\\fancyhead\[RO\]{\\fancyplain{}{\\bfseries\\thepage}}"
386 puts $texfile "\\fancyfoot\[LE\]{\\fancyplain{}{}}"
387 puts $texfile "\\fancyfoot\[CE\]{\\fancyplain{}{}}"
388 puts $texfile "\\fancyfoot\[RE\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}"
389 puts $texfile "\\fancyfoot\[LO\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}"
390 puts $texfile "\\fancyfoot\[CO\]{\\fancyplain{}{}}"
391 puts $texfile "\\fancyfoot\[RO\]{\\fancyplain{}{}}"
392 puts $texfile "\\renewcommand{\\footrulewidth}{0.4pt}"
393 puts $texfile "\\renewcommand{\\sectionmark}\[1\]{%"
394 puts $texfile " \\markright{\\thesection\\ #1}%"
397 puts $texfile "% Indices & bibliography"
398 puts $texfile "\\usepackage{natbib}"
399 puts $texfile "\\usepackage\[titles\]{tocloft}"
400 puts $texfile "\\renewcommand{\\cftsecleader}{\\cftdotfill{\\cftdotsep}}"
401 puts $texfile "\\setcounter{tocdepth}{3}"
402 puts $texfile "\\setcounter{secnumdepth}{5}"
403 puts $texfile "\\makeindex"
405 puts $texfile "% Hyperlinks (required, but should be loaded last)"
406 puts $texfile "\\usepackage{ifpdf}"
407 puts $texfile "\\ifpdf"
408 puts $texfile " \\usepackage\[pdftex,pagebackref=true\]{hyperref}"
409 puts $texfile "\\else"
410 puts $texfile " \\usepackage\[ps2pdf,pagebackref=true\]{hyperref}"
412 puts $texfile "\\hypersetup{%"
413 puts $texfile " colorlinks=true,%"
414 puts $texfile " linkcolor=black,%"
415 puts $texfile " citecolor=black,%"
416 puts $texfile " urlcolor=blue,%"
417 puts $texfile " unicode%"
420 puts $texfile "% Custom commands"
421 puts $texfile "\\newcommand{\\clearemptydoublepage}{%"
422 puts $texfile " \\newpage{\\pagestyle{empty}\\cleardoublepage}%"
425 puts $texfile "%===== C O N T E N T S =====\n"
426 puts $texfile "\\begin{document}"
428 puts $texfile "% Titlepage & ToC"
429 puts $texfile "\\hypersetup{pageanchor=false}"
430 puts $texfile "\\pagenumbering{roman}"
431 puts $texfile "\\begin{titlepage}"
432 puts $texfile "\\vspace*{7cm}"
433 puts $texfile "\\begin{center}%"
434 puts $texfile "\\includegraphics\[width=0.75\\textwidth, height=0.2\\textheight\]{../../../dox/resources/occt_logo.png}\\\\"; #\\\\\\\\
435 puts $texfile "{\\Large Open C\\-A\\-S\\-C\\-A\\-D\\-E Technology \\\\\[1ex\]\\Large [OverviewDoc_DetectCasVersion $latexDir/../../../] }\\\\"
436 puts $texfile "\\vspace*{1cm}"
437 puts $texfile "{\\Large $docLabel}\\\\"
438 puts $texfile "\\vspace*{1cm}"
439 # puts $texfile "{\\large Generated by Doxygen 1.8.4}\\\\"
440 puts $texfile "\\vspace*{0.5cm}"
441 puts $texfile "{\\small \\today}\\"
442 puts $texfile "\\end{center}"
443 puts $texfile "\\end{titlepage}"
444 puts $texfile "\\clearpage"
445 puts $texfile "\\pagenumbering{roman}"
446 puts $texfile "\\tableofcontents"
447 puts $texfile "\\newpage"
448 puts $texfile "\\pagenumbering{arabic}"
449 puts $texfile "\\hypersetup{pageanchor=true}"
451 puts $texfile "\\let\\stdsection\\section"
452 puts $texfile " \\renewcommand\\section{\\pagebreak\\stdsection}"
453 puts $texfile "\\hypertarget{$fileName}{}"
454 puts $texfile "\\input{$fileName}"
456 puts $texfile "% Index"
457 puts $texfile "\\newpage"
458 puts $texfile "\\phantomsection"
459 puts $texfile "\\addcontentsline{toc}{part}{Index}"
460 puts $texfile "\\printindex\n"
461 puts $texfile "\\end{document}"
466 # Postprocesses generated TeX files
467 proc OverviewDoc_ProcessTex {{texFiles {}} {latexDir} verboseMode} {
469 foreach TEX $texFiles {
470 if {$verboseMode == "YES"} {
471 puts "INFO: Preprocessing file $TEX"
474 if {![file exists $TEX]} {
475 puts "file $TEX doesn't exist"
479 set IN_F [open "$TEX" r]
480 set TMPFILENAME "$latexDir/temp.tex"
482 set OUT_F [open $TMPFILENAME w]
485 set line [gets $IN_F]
486 if { [string first "\\includegraphics" $line] != -1 } {
487 # Center images in TeX files
488 set line "\\begin{center}\n $line\n\\end{center}"
489 } elseif { [string first "\\subsection" $line] != -1 } {
490 # Replace \subsection with \section tag
491 regsub -all "\\\\subsection" $line "\\\\section" line
492 } elseif { [string first "\\subsubsection" $line] != -1 } {
493 # Replace \subsubsection with \subsection tag
494 regsub -all "\\\\subsubsection" $line "\\\\subsection" line
495 } elseif { [string first "\\paragraph" $line] != -1 } {
496 # Replace \paragraph with \subsubsection tag
497 regsub -all "\\\\paragraph" $line "\\\\subsubsection" line
507 file delete -force $TEX
508 file rename $TMPFILENAME $TEX
512 # Main procedure for documents compilation
513 proc OverviewDoc_Main { {docfiles {}} generatorMode docLabel verboseMode searchMode hhcPath mathjaxLocation} {
515 set INDIR [file normalize [file dirname [info script]]]
516 set CASROOT [file normalize [file dirname "$INDIR/../../"]]
517 set OUTDIR $CASROOT/doc
518 set PDFDIR $OUTDIR/overview/pdf
519 set HTMLDIR $OUTDIR/overview/html
520 set LATEXDIR $OUTDIR/overview/latex
521 set TAGFILEDIR $OUTDIR/refman
522 set DOXYFILE $OUTDIR/OCCT.cfg
524 # Create or clean the output folders
525 if {[file exists $OUTDIR] == 0} {
528 if {[file exists $HTMLDIR] == 0} {
531 if {[file exists $PDFDIR] == 0} {
535 if {[file exists $LATEXDIR]} {
536 #file delete {*}[glob -nocomplain $LATEXDIR/*.*]
537 file delete -force $LATEXDIR
542 set mathjax_relative_location $mathjaxLocation
543 if { [file isdirectory "$mathjaxLocation"] == 1 } {
544 if { $generatorMode == "HTML_ONLY"} {
546 set mathjax_relative_location [relativePath $HTMLDIR $mathjaxLocation]
547 } elseif { $generatorMode == "CHM_ONLY"} {
549 set mathjax_relative_location [file normalize $mathjaxLocation]
553 # Run tools to compile documents
554 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating Doxyfile..."
556 OverviewDoc_MakeDoxyfile $CASROOT "$OUTDIR/overview" $TAGFILEDIR $DOXYFILE $generatorMode $docfiles $verboseMode $searchMode $hhcPath $mathjax_relative_location
559 if { $generatorMode == "HTML_ONLY"} {
560 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating HTML files..."
561 } elseif { $generatorMode == "CHM_ONLY" } {
562 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating CHM file..."
564 set RESULT [catch {exec doxygen $DOXYFILE > $OUTDIR/doxygen_out.log} DOX_ERROR]
566 if {[llength [split $DOX_ERROR "\n"]] > 1} {
567 if {$verboseMode == "YES"} {
568 puts "See Doxygen log in $OUTDIR/doxygen_warnings_and_errors.log"
570 set DOX_ERROR_FILE [open "$OUTDIR/doxygen_warnings_and_errors.log" "w"]
571 puts $DOX_ERROR_FILE $DOX_ERROR
572 close $DOX_ERROR_FILE
577 # Close the Doxygen application
580 # Start PDF generation routine
581 if { $generatorMode == "PDF_ONLY" } {
582 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating PDF files..."
584 set OS $::tcl_platform(platform)
585 if { $OS == "unix" } {
587 } elseif { $OS == "windows" } {
591 # Prepare a list of TeX files, generated by Doxygen
594 set TEXFILES [glob $LATEXDIR -type f -directory $LATEXDIR -tails "*.tex" ]
595 set REFMAN_IDX [lsearch $TEXFILES "refman.tex"]
596 set TEXFILES [lreplace $TEXFILES $REFMAN_IDX $REFMAN_IDX]
599 set IDX [lsearch $TEXFILES "$LATEXDIR"]
600 while { $IDX != -1} {
601 set TEXFILES [lreplace $TEXFILES $IDX $IDX]
602 set IDX [lsearch $TEXFILES "$LATEXDIR"]
605 if {$verboseMode == "YES"} {
606 puts "Preprocessing generated TeX files..."
608 OverviewDoc_ProcessTex $TEXFILES $LATEXDIR $verboseMode
610 if {$verboseMode == "YES"} {
611 puts "Generating PDF files from TeX files..."
613 foreach TEX $TEXFILES {
614 # Rewrite existing REFMAN.tex file...
615 set TEX [string range $TEX 0 [ expr "[string length $TEX] - 5"]]
616 OverviewDoc_MakeRefmanTex $TEX $LATEXDIR $docLabel $verboseMode
618 if {$verboseMode == "YES"} {
619 puts "INFO: Generating PDF file from $TEX"
620 # ...and use it to generate PDF from TeX...
621 puts "Executing $LATEXDIR/make$PREFIX..."
623 set RESULT [catch {eval exec [auto_execok $LATEXDIR/make$PREFIX] > "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR]
625 if {[llength [split $LaTeX_ERROR "\n"]] > 1} {
626 if {$verboseMode == "YES"} {
627 puts "See Latex log in $OUTDIR/pdflatex_warnings_and_errors.log"
629 set LaTeX_ERROR_FILE [open "$OUTDIR/pdflatex_warnings_and_errors.log" "w"]
630 puts $LaTeX_ERROR_FILE $LaTeX_ERROR
631 close $LaTeX_ERROR_FILE
637 # ...and place it to the specific folder
638 if { [file exists $PDFDIR/$TEX.pdf] == 1 } {
639 file delete -force $PDFDIR/$TEX.pdf
642 if {![file exists "$LATEXDIR/refman.pdf"]} {
643 puts "Error: file $LATEXDIR/refman.pdf does not exist"
647 file rename $LATEXDIR/refman.pdf "$PDFDIR/$TEX.pdf"
652 puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generation completed"
653 if { $generatorMode == "HTML_ONLY" } {
654 puts "View generated HTML documentation by opening: "
655 set RESFILE $OUTDIR/overview/html/index.html
658 if { $generatorMode == "PDF_ONLY" } {
659 puts "PDF files are generated in: "
660 puts "$OUTDIR/overview/pdf folder"
664 proc relativePath {thePathFrom thePathTo} {
665 if { [file isdirectory "$thePathFrom"] == 0 } {
669 set aPathFrom [file normalize "$thePathFrom"]
670 set aPathTo [file normalize "$thePathTo"]
672 set aCutedPathFrom "${aPathFrom}/dummy"
673 set aRelatedDeepPath ""
675 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
676 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
677 # does aPathTo contain aCutedPathFrom?
678 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
679 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
680 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
681 set aPathTo ".${aPathTo}"
682 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
683 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
685 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
686 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
687 return $aPathToAfterCut
689 set aRelatedDeepPath "$aRelatedDeepPath../"
696 # A command for User Documentation compilation
699 set GEN_MODE "HTML_ONLY"
702 set DOCLABEL "Default OCCT Document"
704 set SEARCH_MODE "none"
707 set mathjax_location "http://cdn.mathjax.org/mathjax/latest"
708 set mathjax_js_name "MathJax.js"
710 global available_docfiles
716 # Load list of docfiles
717 if { [OverviewDoc_LoadFilesList] != 0 } {
718 puts "ERROR: File FILES.txt was not found"
723 if {[OverviewDoc_ParseArguments $args] == 1} {
727 foreach arg_n $args_names {
729 OverviewDoc_PrintHelpMessage
731 } elseif {$arg_n == "html"} {
732 set GEN_MODE "HTML_ONLY"
733 } elseif {$arg_n == "chm"} {
734 set GEN_MODE "CHM_ONLY"
736 if {"$tcl_platform(platform)" == "windows" && [lsearch $args_names hhc] == -1} {
737 if { [info exist env(ProgramFiles\(x86\))] } {
738 set hhcPath "$env(ProgramFiles\(x86\))\\HTML Help Workshop\\hhc.exe"
739 puts "Info: hhc found: $hhcPath"
740 } elseif { [info exist env(ProgramFiles)] } {
741 set hhcPath "$env(ProgramFiles)\\HTML Help Workshop\\hhc.exe"
742 puts "Info: hhc found: $hhcPath"
745 if { ! [file exists $hhcPath] } {
746 puts "Error: HTML Help Compiler is not found in standard location [file dirname $hhcPath]; use option -hhc"
751 } elseif {$arg_n == "hhc"} {
753 if { $tcl_platform(platform) != "windows" } {
757 if {$args_values(hhc) != "NULL"} {
758 set hhcPath $args_values(hhc)
759 if { [file isdirectory $hhcPath] } {
760 set hhcPath [file join ${hhcPath} hhc.exe]
762 if { ! [file exists $hhcPath] } {
763 puts "Error: HTML Help Compiler is not found in $hhcPath"
767 puts "Error in argument hhc"
771 } elseif {$arg_n == "pdf"} {
772 set GEN_MODE "PDF_ONLY"
773 } elseif {$arg_n == "v"} {
775 } elseif {$arg_n == "m"} {
776 if {$args_values(m) != "NULL"} {
777 set DOCFILES $args_values(m)
779 puts "Error in argument m"
783 # Check if all chosen docfiles are correct
784 foreach docfile $DOCFILES {
785 if { [lsearch $available_docfiles $docfile] == -1 } {
786 puts "File \"$docfile\" is not presented in the list of available docfiles"
787 puts "Please, specify the correct docfile name"
790 puts "File $docfile is presented in FILES.TXT"
793 } elseif {$arg_n == "l"} {
794 if { [llength $DOCFILES] <= 1 } {
795 if {$args_values(l) != "NULL"} {
796 set DOCLABEL $args_values(l)
798 puts "Error in argument l"
802 } elseif {$arg_n == "s"} {
803 if {$args_values(s) != "NULL"} {
804 set SEARCH_MODE $args_values(s)
806 puts "Error in argument s"
809 } elseif {$arg_n == "mathjax"} {
810 if {![info exists args_values(pdf)]} {
811 set possible_mathjax_loc $args_values(mathjax)
812 if {[file exist [file join $possible_mathjax_loc $mathjax_js_name]]} {
813 set mathjax_location $args_values(mathjax)
814 puts "$mathjax_location"
816 puts "Warning: $mathjax_js_name isn't found in $possible_mathjax_loc."
817 puts " MathJax will be used from $mathjax_location"
820 puts "Info: MathJax is not used with pdf and will be ignored"
823 puts "\nWrong argument: $arg_n"
824 OverviewDoc_PrintHelpMessage
829 # Specify verbose mode
830 if { $GEN_MODE != "PDF_ONLY" && [llength $DOCFILES] > 1 } {
834 # If we don't specify list for docfiles with -m argument,
835 # we assume that we have to generate all docfiles
836 if { [llength $DOCFILES] == 0 } {
837 set DOCFILES $available_docfiles
840 # Start main activities
841 OverviewDoc_Main $DOCFILES $GEN_MODE $DOCLABEL $VERB_MODE $SEARCH_MODE $hhcPath $mathjax_location