1 # =======================================================================
2 # Created on: 2014-03-21
4 # Copyright (c) 1996-1999 Matra Datavision
5 # Copyright (c) 1999-2014 OPEN CASCADE SAS
7 # This file is part of Open CASCADE Technology software library.
9 # This library is free software; you can redistribute it and/or modify it under
10 # the terms of the GNU Lesser General Public License version 2.1 as published
11 # by the Free Software Foundation, with special exception defined in the file
12 # OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
13 # distribution for complete text of the license and disclaimer of any warranty.
15 # Alternatively, this file may be used under the terms of Open CASCADE
16 # commercial license or contractual agreement.
18 # =======================================================================
19 # This script contains auxilary functions which can be used
20 # in documentation generation process
21 # =======================================================================
23 # ==============================================
24 # Commonly used functions
25 # ==============================================
27 # Parses arguments line like "-arg1=val1 -arg2=val2 ..." to array args_names and map args_values
28 proc OCCDoc_ParseArguments {arguments} {
32 array set args_values {}
34 foreach arg $arguments {
35 if {[regexp {^(-)[a-z_]+$} $arg] == 1} {
36 set name [string range $arg 1 [string length $arg]-1]
37 lappend args_names $name
38 set args_values($name) "NULL"
40 } elseif {[regexp {^(-)[a-z_]+=.+$} $arg] == 1} {
41 set equal_symbol_position [string first "=" $arg]
42 set name [string range $arg 1 $equal_symbol_position-1]
43 lappend args_names $name
44 set value [string range $arg $equal_symbol_position+1 [string length $arguments]-1]
46 # To parse a list of values for -m parameter
47 if { [string first "," $value] != -1 } {
48 set value [split $value ","];
51 set args_values($name) $value
54 puts "Error in argument $arg."
61 # Returns script parent folder
62 proc OCCDoc_GetDoxDir { {theProductsPath ""} } {
63 if { $theProductsPath == "" } {
64 return [file normalize [file dirname [info script]]/../dox]
66 return [file normalize $theProductsPath]/dox
70 # Returns products root folder
71 proc OCCDoc_GetProdRootDir {} {
72 if {[info exists ::env(PRODROOT)]} {
73 return [file normalize $::env(PRODROOT)]
77 # Returns OCCT root dir
78 proc OCCDoc_GetOCCTRootDir {} {
79 set path [OCCDoc_GetDoxDir]
80 return [file normalize $path/..]
84 proc OCCDoc_GetRootDir { {theProductsPath ""} } {
85 if { $theProductsPath == "" } {
86 return [OCCDoc_GetOCCTRootDir]
88 return [file normalize $theProductsPath]
92 # Returns OCCT include dir
93 proc OCCDoc_GetIncDir { {theProductsPath ""} } {
94 set path [OCCDoc_GetRootDir $theProductsPath]
98 # Returns OCCT source dir
99 proc OCCDoc_GetSourceDir { {theProductsPath ""} } {
100 set path [OCCDoc_GetRootDir $theProductsPath]
104 # Returns name of the package from the current toolkit
105 proc OCCDoc_GetNameFromPath { thePath } {
107 set splitted_path [split $thePath "/" ]
108 set package_name [lindex $splitted_path end]
113 # Returns the relative path between two folders
114 proc OCCDoc_GetRelPath {thePathFrom thePathTo} {
115 if { [file isdirectory "$thePathFrom"] == 0 } {
119 set aPathFrom [file normalize "$thePathFrom"]
120 set aPathTo [file normalize "$thePathTo"]
122 set aCutedPathFrom "${aPathFrom}/dummy"
123 set aRelatedDeepPath ""
125 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
126 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
127 # does aPathTo contain aCutedPathFrom?
128 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
129 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
130 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
131 set aPathTo ".${aPathTo}"
132 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
133 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
135 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
136 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
137 return $aPathToAfterCut
139 set aRelatedDeepPath "$aRelatedDeepPath../"
145 # Returns OCCT version string from file Standard_Version.hxx (if available)
146 proc OCCDoc_DetectCasVersion {} {
149 set filename "[OCCDoc_GetSourceDir]/Standard/Standard_Version.hxx"
150 if { [file exists $filename] } {
151 set fh [open $filename "r"]
152 set fh_loaded [read $fh]
154 regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver
155 regexp {[^/]\s*#\s*define\s+OCC_VERSION_DEVELOPMENT\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver_add
156 if { "$occt_ver_add" != "" } { set occt_ver ${occt_ver}.$occt_ver_add }
161 # Checks if the necessary tools exist
162 proc OCCDoc_DetectNecessarySoftware { DOXYGEN_PATH GRAPHVIZ_PATH INKSCAPE_PATH HHC_PATH PDFLATEX_PATH } {
164 upvar 1 DOXYGEN_PATH doxy_path
165 upvar 1 GRAPHVIZ_PATH graph_path
166 upvar 1 INKSCAPE_PATH inkscape_path
167 upvar 1 HHC_PATH hhc_path
168 upvar 1 PDFLATEX_PATH latex_path
177 if { "$::tcl_platform(platform)" == "windows" } {
180 if {"$is_win" == "yes"} {
193 set envPath $::env(PATH)
194 if { $is_win == "yes" } {
195 set searchPathsList [split $envPath ";"]
197 set searchPathsList [split $envPath ":"]
200 foreach path $searchPathsList {
201 if { ($is_win == "no") &&
202 (($path == "/usr/bin") || ($path == "/usr/local/bin")) } {
203 # Avoid searching in default bin location
206 if {$d_flag == "no"} {
207 if { [file exists $path/doxygen$exe] } {
208 catch { exec $path/doxygen -V } version_string
209 set version [lindex [split $version_string "\n"] 0]
210 puts "Info: $version "
211 puts " found in $path."
212 set doxy_path "$path/doxygen$exe"
216 if {$g_flag == "no"} {
217 if { [file exists $path/dot$exe] } {
218 catch { exec $path/dot -V } version
220 puts "Info: $version "
221 puts " found in $path."
222 set graph_path "$path/dot$exe"
226 if {$i_flag == "no"} {
227 if { [file exists $path/inkscape$exe] } {
228 catch { exec $path/inkscape -V } version
229 puts "Info: $version "
230 puts " found in $path."
231 set inkscape_path "$path/inkscape$exe"
235 if {$l_flag == "no"} {
236 if { [file exists $path/pdflatex$exe] } {
237 catch { exec $path/pdflatex -version } version
238 set version [lindex [split $version "\n"] 0]
239 puts "Info: $version "
240 puts " found in $path."
241 set latex_path "$path/pdflatex$exe"
245 if { ("$is_win" == "yes") && ($h_flag == "no") } {
246 if { [file exists $path/hhc.exe] } {
248 puts " found in $path."
249 set hhc_path "hhc$exe"
253 if { ($d_flag == "yes") &&
254 ($i_flag == "yes") &&
255 ($g_flag == "yes") &&
256 ($l_flag == "yes") &&
257 (($is_win == "yes") &&
258 ($h_flag == "yes")) } {
263 # On Windows search for hhc.exe in the default location
264 # if it has not been found yet
265 if { ("$is_win" == "yes") && ($h_flag == "no") } {
266 if { [info exists ::env(ProgramFiles\(x86\))] } {
268 set path "$::env(ProgramFiles\(x86\))\\HTML Help Workshop"
269 set hhc_path "$path\\hhc.exe"
271 puts " found in $path."
273 if { [info exists ::env(ProgramFiles)] } {
275 set path "$::env(ProgramFiles)\\HTML Help Workshop"
276 set hhc_path "$path\\hhc.exe"
278 puts " found in $path."
283 # On *nix-like platforms,
284 # check the default binary locations if the tools had not been found yet
285 if { $is_win == "no" &&
286 (($d_flag == "no") ||
289 ($l_flag == "no")) } {
291 set default_path { "/usr/bin" "/usr/local/bin" }
292 foreach path $default_path {
293 if {$d_flag == "no"} {
294 if { [file exists $path/doxygen$exe] } {
295 catch { exec $path/doxygen -V } version_string
296 set version [lindex [split $version_string "\n"] 0]
297 puts "Info: $version "
298 puts " found in $path."
299 set doxy_path "$path/doxygen$exe"
303 if {$g_flag == "no"} {
304 if { [file exists $path/dot$exe] } {
305 catch { exec $path/dot -V } version
307 puts "Info: $version "
308 puts " found in $path."
309 set graph_path "$path/dot$exe"
313 if {$i_flag == "no"} {
314 if { [file exists $path/inkscape$exe] } {
315 catch { exec $path/inkscape -V } version
316 puts "Info: $version "
317 puts " found in $path."
318 set inkscape_path "$path/inkscape$exe"
322 if {$l_flag == "no"} {
323 if { [file exists $path/pdflatex$exe] } {
324 catch { exec $path/pdflatex -version } version
325 set version [lindex [split $version "\n"] 0]
326 puts "Info: $version "
327 puts " found in $path."
328 set latex_path "$path/pdflatex$exe"
335 # Check if tools have been found
336 if { $d_flag == "no" } {
337 puts "Warning: Could not find doxygen installed."
340 if { $g_flag == "no" } {
341 puts "Warning: Could not find graphviz installed."
343 if { $i_flag == "no" } {
344 puts "Warning: Could not find inkscape installed."
346 if { $l_flag == "no" } {
347 puts "Warning: Could not find pdflatex installed."
349 if { ("$::tcl_platform(platform)" == "windows") && ($h_flag == "no") } {
350 puts "Warning: Could not find hhc installed."
356 # Convert SVG files to PDF format to allow including them to PDF
357 # (requires InkScape to be in PATH)
358 proc OCCDoc_ProcessSvg {latexDir verboseMode} {
360 foreach file [glob -nocomplain $latexDir/*.svg] {
361 if {$verboseMode == "YES"} {
362 puts "Info: Converting file $file..."
364 set pdffile "[file rootname $file].pdf"
365 if { [catch {exec inkscape -z -D --file=$file --export-pdf=$pdffile} res] } {
372 # ==============================================
373 # Reference Manual-specific functions
374 # ==============================================
376 # Finds dependencies between all modules
377 proc OCCDoc_CreateModulesDependencyGraph {dir filename modules mpageprefix} {
378 global module_dependency
380 if {![catch {open $dir/$filename.dot "w"} file]} {
381 puts $file "digraph $filename"
384 foreach mod $modules {
388 puts $file "\t$mod \[ URL = \"[string tolower $mpageprefix$mod.html]\" \]"
389 foreach mod_depend $module_dependency($mod) {
390 puts $file "\t$mod_depend -> $mod \[ dir = \"back\", color = \"midnightblue\", style = \"solid\" \]"
401 # Finds dependencies between all toolkits in module
402 proc OCCDoc_CreateModuleToolkitsDependencyGraph {dir filename modulename tpageprefix} {
403 global toolkits_in_module
404 global toolkit_dependency
405 global toolkit_parent_module
407 if {![catch {open $dir/$filename.dot "w"} file]} {
408 puts $file "digraph $filename"
411 foreach tk $toolkits_in_module($modulename) {
412 puts $file "\t$tk \[ URL = \"[string tolower $tpageprefix$tk.html]\"\ ]"
413 foreach tkd $toolkit_dependency($tk) {
414 if { [info exists toolkit_parent_module($tkd)] } {
415 if {$toolkit_parent_module($tkd) == $modulename} {
416 puts $file "\t$tkd -> $tk \[ dir = \"back\", color = \"midnightblue\", style = \"solid\" \]"
429 # Finds dependencies between the current toolkit and other toolkits
430 proc OCCDoc_CreateToolkitDependencyGraph {dir filename toolkitname tpageprefix} {
431 global toolkit_dependency
433 if {![catch {open $dir/$filename.dot "w"} file]} {
434 puts $file "digraph $filename"
437 puts $file "\t$toolkitname \[ URL = \"[string tolower $tpageprefix$toolkitname.html]\"\, shape = box ]"
438 foreach tkd $toolkit_dependency($toolkitname) {
439 puts $file "\t$tkd \[ URL = \"[string tolower $tpageprefix$tkd.html]\"\ , shape = box ]"
440 puts $file "\t$toolkitname -> $tkd \[ color = \"midnightblue\", style = \"solid\" \]"
443 if {[llength $toolkit_dependency($toolkitname)] > 1} {
444 puts $file "\taspect = 1"
454 # Fills arrays of modules, toolkits, dependency of modules/toolkits etc
455 proc OCCDoc_LoadData { {theProductsDir ""} } {
456 global toolkits_in_module
457 global toolkit_dependency
458 global toolkit_parent_module
459 global module_dependency
461 if { $theProductsDir == ""} {
462 set modules_files [glob -nocomplain -type f -directory "[OCCDoc_GetSourceDir $theProductsDir]/OS/" *.tcl]
464 set modules_files [glob -nocomplain -type f -directory "[OCCDoc_GetSourceDir $theProductsDir]/VAS/" *.tcl]
467 foreach module_file $modules_files {
471 set modules [OCCDoc_GetModulesList $theProductsDir]
472 foreach mod $modules {
477 # Get toolkits of current module
478 set toolkits_in_module($mod) [$mod:toolkits]
479 # Get all dependence of current toolkit
480 foreach tk $toolkits_in_module($mod) {
481 # set parent module of current toolkit
482 set toolkit_parent_module($tk) $mod
483 set exlibfile [open "[OCCDoc_GetSourceDir $theProductsDir]/$tk/EXTERNLIB" r]
484 set exlibfile_data [read $exlibfile]
485 set exlibfile_data [split $exlibfile_data "\n"]
487 set toolkit_dependency($tk) {}
488 foreach dtk $exlibfile_data {
489 if { ([string first "TK" $dtk 0] == 0) ||
490 ([string first "P" $dtk 0] == 0) } {
491 lappend toolkit_dependency($tk) $dtk
498 # Get modules dependency
499 foreach mod $modules {
500 set module_dependency($mod) {}
501 foreach tk $toolkits_in_module($mod) {
502 foreach tkd $toolkit_dependency($tk) {
503 if { [info exists toolkit_parent_module($tkd)] } {
504 if { $toolkit_parent_module($tkd) != $mod &&
505 [lsearch $module_dependency($mod) $toolkit_parent_module($tkd)] == -1} {
506 lappend module_dependency($mod) $toolkit_parent_module($tkd)
514 # Returns list of packages of the given toolkit
515 proc OCCDoc_GetPackagesList { theToolKitPath } {
519 # Open file with list of packages of the given toolkit
520 set fileid [open "$theToolKitPath/PACKAGES" "r"]
522 while { [eof $fileid] == 0 } {
523 set str [gets $fileid]
525 lappend packages_list $str
531 return $packages_list
534 # Returns list of modules from UDLIST
535 proc OCCDoc_GetModulesList { {theProductsDir ""} } {
537 if { $theProductsDir == "" } {
538 source "[OCCDoc_GetSourceDir $theProductsDir]/OS/Modules.tcl"
539 # load a command from this file
540 set modules [OS:Modules]
542 source "[OCCDoc_GetSourceDir $theProductsDir]/VAS/Products.tcl"
543 # load a command from this file
544 set modules [VAS:Products]
545 set modules [lsearch -not -all -inline $modules "VAS"]
551 # Returns list of desired files in the specified location
552 proc OCCDoc_GetHeadersList { theDesiredContent thePackageName {theProductsDir ""} } {
554 # Get list of header files with path
555 set files_list [split [glob -nocomplain -type f -directory "[OCCDoc_GetSourceDir $theProductsDir]/$thePackageName" "${thePackageName}.hxx" "${thePackageName}_*.hxx"]]
557 # Get content according to desired type ('p' for path and 'f' for filenames only)
558 if { $theDesiredContent == "p" } {
560 } elseif { $theDesiredContent == "f" } {
562 # Cut paths from filenames
563 foreach file $files_list {
564 set elem_index [lsearch $files_list $file]
565 lset files_list $elem_index [OCCDoc_GetNameFromPath [lindex $files_list $elem_index]]
571 # Returns location of the toolkit
572 proc OCCDoc_Locate { theToolKitName {theProductsDir ""} } {
573 set tk_dir "[OCCDoc_GetSourceDir $theProductsDir]/[OCCDoc_GetNameFromPath $theToolKitName]"
577 # Gets contents of the given html node (for Post-processing)
578 proc OCCDoc_GetNodeContents {node props html} {
579 set openTag "<$node$props>"
580 set closingTag "</$node>"
581 set start [string first $openTag $html]
585 set start [expr $start + [string length $openTag]]
586 set end [string length $html]
587 set html [string range $html $start $end]
588 set start [string first $closingTag $html]
589 set end [string length $html]
593 set start [expr $start - 1]
594 return [string range $html 0 $start]
597 # Generates main page file describing module structure
598 proc OCCDoc_MakeMainPage {outDir outFile modules {theProductsDir ""} } {
601 set one_module [expr [llength $modules] == 1]
602 set fd [open $outFile "w"]
604 set module_prefix "module_"
605 set toolkit_prefix "toolkit_"
606 set package_prefix "package_"
608 if { ! [file exists "$outDir/html"] } {
609 file mkdir "$outDir/html"
612 OCCDoc_LoadData $theProductsDir
614 # Main page: list of modules
615 if { ! $one_module } {
617 puts $fd "\\mainpage Open CASCADE Technology"
619 foreach mod $modules {
620 puts $fd "\\li \\subpage [string tolower $module_prefix$mod]"
622 # insert modules relationship diagramm
623 puts $fd "\\dotfile [OCCDoc_CreateModulesDependencyGraph $outDir/html schema_all_modules $modules $module_prefix]"
627 # One page per module: list of toolkits
629 foreach mod $modules {
635 puts $fd "\\mainpage OCCT Module [$mod:name]"
637 puts $fd "\\page [string tolower module_$mod] Module [$mod:name]"
639 foreach tk [lsort [$mod:toolkits]] {
641 puts $fd "\\li \\subpage [string tolower $toolkit_prefix$tk]"
643 puts $fd "\\dotfile [OCCDoc_CreateModuleToolkitsDependencyGraph $outDir/html schema_$mod $mod $toolkit_prefix]"
647 # One page per toolkit: list of packages
649 foreach tk $toolkits {
651 puts $fd "\\page [string tolower toolkit_$tk] Toolkit $tk"
652 foreach pk [lsort [OCCDoc_GetPackagesList [OCCDoc_Locate $tk $theProductsDir]]] {
654 set u [OCCDoc_GetNameFromPath $pk]
655 puts $fd "\\li \\subpage [string tolower $package_prefix$u]"
657 puts $fd "\\dotfile [OCCDoc_CreateToolkitDependencyGraph $outDir/html schema_$tk $tk $toolkit_prefix]"
661 # One page per package: list of classes
662 foreach pk $packages {
663 set u [OCCDoc_GetNameFromPath $pk]
665 puts $fd "\\page [string tolower $package_prefix$u] Package $u"
666 foreach hdr [lsort [OCCDoc_GetHeadersList "f" "$pk" "$theProductsDir"]] {
667 if { ! [regexp {^Handle_} $hdr] && [regexp {(.*)[.]hxx} $hdr str obj] } {
668 puts $fd "\\li \\subpage $obj"
679 # Parses generated files to add a navigation path
680 proc OCCDoc_PostProcessor {outDir} {
681 puts "[clock format [clock seconds] -format {%Y.%m.%d %H:%M}] Post-process is started ..."
682 append outDir "/html"
683 set files [glob -nocomplain -type f $outDir/package_*]
684 if { $files != {} } {
685 foreach f [lsort $files] {
686 set packageFilePnt [open $f r]
687 set packageFile [read $packageFilePnt]
688 set navPath [OCCDoc_GetNodeContents "div" " id=\"nav-path\" class=\"navpath\"" $packageFile]
689 set packageName [OCCDoc_GetNodeContents "div" " class=\"title\"" $packageFile]
690 regsub -all {<[^<>]*>} $packageName "" packageName
692 # add package link to nav path
693 set first [expr 1 + [string last "/" $f]]
694 set last [expr [string length $f] - 1]
695 set packageFileName [string range $f $first $last]
696 set end [string first "</ul>" $navPath]
697 set end [expr $end - 1]
698 set navPath [string range $navPath 0 $end]
699 append navPath " <li class=\"navelem\"><a class=\"el\" href=\"$packageFileName\">$packageName</a> </li>\n </ul>"
701 # get list of files to update
702 set listContents [OCCDoc_GetNodeContents "div" " class=\"textblock\"" $packageFile]
703 set listContents [OCCDoc_GetNodeContents "ul" "" $listContents]
704 set lines [split $listContents "\n"]
705 foreach line $lines {
706 if {[regexp {href=\"([^\"]*)\"} $line tmpLine classFileName]} {
707 # check if anchor is there
708 set anchorPos [string first "#" $classFileName]
709 if {$anchorPos != -1} {
710 set classFileName [string range $classFileName 0 [expr $anchorPos - 1]]
714 set classFilePnt [open $outDir/$classFileName r+]
715 set classFile [read $classFilePnt]
717 # find position of content block
718 set contentPos [string first "<div class=\"header\">" $classFile]
719 set navPart [string range $classFile 0 [expr $contentPos - 1]]
721 # position where to insert nav path
722 set posToInsert [string last "</div>" $navPart]
723 set prePart [string range $classFile 0 [expr $posToInsert - 1]]
724 set postPart [string range $classFile $posToInsert [string length $classFile]]
726 append newClassFile $prePart " <div id=\"nav-path\" class=\"navpath\">" $navPath \n " </div>" \n $postPart
728 # write updated content
730 puts $classFilePnt $newClassFile
734 close $packageFilePnt
738 puts "no files found"
743 # ======================================
744 # User Guides-specific functions
745 # ======================================
747 # Loads a list of docfiles from file FILES.txt
748 proc OCCDoc_LoadFilesList {} {
749 set INPUTDIR [OCCDoc_GetDoxDir [OCCDoc_GetProdRootDir]]
751 global available_docfiles
752 set available_docfiles {}
754 # Read data from file
755 if { [file exists "$INPUTDIR/FILES_HTML.txt"] == 1 } {
756 set FILE [open "$INPUTDIR/FILES_HTML.txt" r]
758 set line [string trim [gets $FILE]]
760 # trim possible comments starting with '#'
761 set line [regsub {\#.*} $line {}]
763 lappend available_docfiles $line
777 # Read data from file
778 if { [file exists "$INPUTDIR/FILES_PDF.txt"] } {
779 set FILE [open "$INPUTDIR/FILES_PDF.txt" r]
781 set line [string trim [gets $FILE]]
783 # Trim possible comments starting with '#'
784 set line [regsub {\#.*} $line {}]
786 lappend available_pdf $line
799 # Writes new TeX file for conversion from tex to pdf for a specific doc
800 proc OCCDoc_MakeRefmanTex {fileName latexDir verboseMode latexFilesList} {
802 if { $verboseMode == "YES" } {
803 puts "Info: Making refman.tex file for $fileName..."
805 set DOCNAME "$latexDir/refman.tex"
806 if {[file exists $DOCNAME] == 1} {
807 file delete -force $DOCNAME
810 # Copy template file to latex folder
811 if { "[OCCDoc_GetProdRootDir]" != "" } {
812 file copy "[OCCDoc_GetDoxDir [OCCDoc_GetProdRootDir]]/resources/prod_pdf_template.tex" $DOCNAME
814 file copy "[OCCDoc_GetDoxDir]/resources/occt_pdf_template.tex" $DOCNAME
817 # Get templatized data
818 set texfile [open $DOCNAME "r"]
819 set texfile_loaded [read $texfile]
822 # Replace dummy values
823 set year [clock format [clock seconds] -format {%Y}]
824 set month [clock format [clock seconds] -format {%B}]
825 set texfile [open $DOCNAME "w"]
826 set casVersion [OCCDoc_DetectCasVersion]
828 # Get name of the document
830 foreach aFileName $latexFilesList {
831 # Find the file in FILES_PDF.txt
832 set parsedFileName [file rootname [lindex [split $aFileName "/" ] end]]
833 if { [regexp "${parsedFileName}$" $fileName] } {
834 set filepath "[OCCDoc_GetDoxDir [OCCDoc_GetProdRootDir]]/$aFileName"
835 if { [file exists $filepath] } {
836 set MDFile [open $filepath "r"]
837 set label [split [gets $MDFile] "\{"]
838 set docLabel [lindex $label 0]
845 set occtlogo_path "[OCCDoc_GetDoxDir]/resources/occt_logo.png"
846 set occlogo_path "[OCCDoc_GetDoxDir]/resources/occ_logo.png"
847 set copyright_path "[OCCDoc_GetDoxDir [OCCDoc_GetProdRootDir]]/resources/prod_pdf_template.tex"
848 set texfile_loaded [string map [list DEFDOCLABEL "$docLabel" DEFCASVERSION "$casVersion" DEFFILENAME "$fileName" DEFYEAR "$year" DEFMONTH "$month" DEFCOPYRIGHT "$copyright_path" DEFLOGO "$occtlogo_path" DEFOCCLOGO "$occlogo_path" DEFTITLE ""] $texfile_loaded]
851 puts $texfile $texfile_loaded
856 # Postprocesses generated TeX files
857 proc OCCDoc_ProcessTex {{texFiles {}} {latexDir} verboseMode} {
859 foreach TEX $texFiles {
860 if {$verboseMode == "YES"} {
861 puts "Info: Preprocessing file $TEX..."
864 if {![file exists $TEX]} {
865 puts "Error: file $TEX does not exist."
869 set IN_F [open "$TEX" "r"]
870 set TMPFILENAME "$latexDir/temp.tex"
871 set OUT_F [open $TMPFILENAME w]
874 set line [gets $IN_F]
875 if { [string first "\\includegraphics" $line] != -1 } {
876 # replace svg extension by pdf
877 set line [regsub {[.]svg} $line ".pdf"]
878 # Center images in TeX files
879 set line "\\begin{center}\n $line\n\\end{center}"
880 } elseif { [string first "\\subsection" $line] != -1 } {
881 # Replace \subsection with \section tag
882 regsub -all "\\\\subsection" $line "\\\\section" line
883 } elseif { [string first "\\subsubsection" $line] != -1 } {
884 # Replace \subsubsection with \subsection tag
885 regsub -all "\\\\subsubsection" $line "\\\\subsection" line
886 } elseif { [string first "\\paragraph" $line] != -1 } {
887 # Replace \paragraph with \subsubsection tag
888 regsub -all "\\\\paragraph" $line "\\\\subsubsection" line
899 file delete -force $TEX
900 file rename $TMPFILENAME $TEX