| 1 | # ----------------------------------------------------------------------- |
| 2 | # Script name: CompileDocs.tcl |
| 3 | # This script compiles OCCT documents from *.md files to HTML pages |
| 4 | # Author: omy |
| 5 | # ----------------------------------------------------------------------- |
| 6 | |
| 7 | # get OCCT version from file Standard_Version.hxx (if available) |
| 8 | proc OverviewDoc_DetectCasVersion {theCasRoot} { |
| 9 | set occt_ver 6.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*#\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 | } |
| 21 | |
| 22 | # Generates Doxygen configuration file for Overview documentation |
| 23 | proc OverviewDoc_MakeDoxyfile {casDir outDir tagFileDir {doxyFileName} {generatorMode ""} DocFilesList verboseMode searchMode hhcPath} { |
| 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\"" |
| 32 | puts $doxyFile "PROJECT_NUMBER = [OverviewDoc_DetectCasVersion $casDir]" |
| 33 | puts $doxyFile "PROJECT_BRIEF = " |
| 34 | puts $doxyFile "PROJECT_LOGO = $inputDir/resources/occ_logo.png" |
| 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_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" |
| 82 | |
| 83 | # Keep doxygen comments within code blocks |
| 84 | puts $doxyFile "STRIP_CODE_COMMENTS = NO" |
| 85 | |
| 86 | set PARAM_INPUT "INPUT =" |
| 87 | set PARAM_IMAGEPATH "IMAGE_PATH = $inputDir/resources/ " |
| 88 | |
| 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" |
| 94 | } |
| 95 | } |
| 96 | append PARAM_INPUT " " $inputDir/$docFile |
| 97 | } |
| 98 | puts $doxyFile $PARAM_INPUT |
| 99 | puts $doxyFile $PARAM_IMAGEPATH |
| 100 | |
| 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" |
| 107 | } |
| 108 | } |
| 109 | # HTML Output |
| 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" |
| 129 | } else { |
| 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" |
| 140 | } else { |
| 141 | puts "ERROR: Wrong search engine type" |
| 142 | close $doxyFile |
| 143 | return |
| 144 | } |
| 145 | } |
| 146 | puts $doxyFile "SEARCHDATA_FILE = searchdata.xml" |
| 147 | puts $doxyFile "SKIP_FUNCTION_MACROS = YES" |
| 148 | # Formula options |
| 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 = http://cdn.mathjax.org/mathjax/latest" |
| 154 | |
| 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" |
| 160 | # Formula options |
| 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 = http://cdn.mathjax.org/mathjax/latest" |
| 166 | |
| 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" |
| 181 | } |
| 182 | |
| 183 | close $doxyFile |
| 184 | } |
| 185 | |
| 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]] |
| 190 | |
| 191 | if {![string equal [lindex $cc 0] [lindex $tt 0]]} { |
| 192 | # not on *n*x then |
| 193 | return -code error "$targetFile not on same volume as $currentpath" |
| 194 | } |
| 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] |
| 199 | } |
| 200 | set prefix "" |
| 201 | if {[llength $cc] == 0} { |
| 202 | # just the file name, so targetFile is lower down (or in same place) |
| 203 | set prefix "." |
| 204 | } |
| 205 | # step up the tree |
| 206 | for {set i 0} {$i < [llength $cc]} {incr i} { |
| 207 | append prefix " .." |
| 208 | } |
| 209 | # stick it all together (the eval is to flatten the targetFile list) |
| 210 | return [eval file join $prefix $tt] |
| 211 | } |
| 212 | |
| 213 | # Prints Help message |
| 214 | proc OverviewDoc_PrintHelpMessage {} { |
| 215 | puts "\nUsage : occdoc \[-h\] \[-html\] \[-pdf\] \[-m=<list of files>\] \[-l=<document name>\] \[-v\] \[-s\]" |
| 216 | puts "" |
| 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 | } |
| 238 | |
| 239 | # Parses command line arguments |
| 240 | proc OverviewDoc_ParseArguments {arguments} { |
| 241 | global args_names |
| 242 | global args_values |
| 243 | set args_names {} |
| 244 | array set args_values {} |
| 245 | |
| 246 | foreach arg $arguments { |
| 247 | if {[regexp {^(-)[a-z]+$} $arg] == 1} { |
| 248 | set name [string range $arg 1 [string length $arg]-1] |
| 249 | lappend args_names $name |
| 250 | set args_values($name) "NULL" |
| 251 | continue |
| 252 | } elseif {[regexp {^(-)[a-z]+=.+$} $arg] == 1} { |
| 253 | set equal_symbol_position [string first "=" $arg] |
| 254 | set name [string range $arg 1 $equal_symbol_position-1] |
| 255 | lappend args_names $name |
| 256 | set value [string range $arg $equal_symbol_position+1 [string length $arguments]-1] |
| 257 | |
| 258 | # To parse a list of values for -m parameter |
| 259 | if { [string first "," $value] != -1 } { |
| 260 | set value [split $value ","]; |
| 261 | } |
| 262 | set args_values($name) $value |
| 263 | } else { |
| 264 | puts "Error in argument $arg" |
| 265 | return 1 |
| 266 | } |
| 267 | } |
| 268 | return 0 |
| 269 | } |
| 270 | |
| 271 | # Loads a list of docfiles from file FILES.txt |
| 272 | proc OverviewDoc_LoadFilesList {} { |
| 273 | |
| 274 | set INPUTDIR [file normalize [file dirname [info script]]] |
| 275 | |
| 276 | global available_docfiles |
| 277 | set available_docfiles {} |
| 278 | |
| 279 | # Read data from file |
| 280 | if { [file exists "$INPUTDIR/FILES.txt"] == 1 } { |
| 281 | set FILE [open "$INPUTDIR/FILES.txt" r] |
| 282 | while {1} { |
| 283 | set line [string trim [gets $FILE]] |
| 284 | |
| 285 | # trim possible comments starting with '#' |
| 286 | set line [regsub {\#.*} $line {}] |
| 287 | |
| 288 | if {$line != ""} { |
| 289 | lappend available_docfiles $line |
| 290 | } |
| 291 | |
| 292 | if {[eof $FILE]} { |
| 293 | close $FILE |
| 294 | break |
| 295 | } |
| 296 | } |
| 297 | } else { |
| 298 | return -1 |
| 299 | } |
| 300 | return 0 |
| 301 | } |
| 302 | |
| 303 | # Writes new tex file for conversion from tex to pdf for a specific doc |
| 304 | proc OverviewDoc_MakeRefmanTex {fileName latexDir docLabel verboseMode} { |
| 305 | |
| 306 | if {$verboseMode == "YES"} { |
| 307 | puts "INFO: Making refman.tex file for $fileName" |
| 308 | } |
| 309 | set DOCNAME "$latexDir/refman.tex" |
| 310 | if {[file exists $DOCNAME] == 1} { |
| 311 | file delete -force $DOCNAME |
| 312 | } |
| 313 | set texfile [open $DOCNAME w] |
| 314 | |
| 315 | puts $texfile "\\batchmode" |
| 316 | puts $texfile "\\nonstopmode" |
| 317 | puts $texfile "\\documentclass\[oneside\]{article}" |
| 318 | puts $texfile "\n% Packages required by doxygen" |
| 319 | puts $texfile "\\usepackage{calc}" |
| 320 | puts $texfile "\\usepackage{doxygen}" |
| 321 | puts $texfile "\\usepackage{graphicx}" |
| 322 | puts $texfile "\\usepackage\[utf8\]{inputenc}" |
| 323 | puts $texfile "\\usepackage{makeidx}" |
| 324 | puts $texfile "\\usepackage{multicol}" |
| 325 | puts $texfile "\\usepackage{multirow}" |
| 326 | puts $texfile "\\usepackage{textcomp}" |
| 327 | puts $texfile "\\usepackage{amsmath}" |
| 328 | puts $texfile "\\usepackage\[table\]{xcolor}" |
| 329 | puts $texfile "\\usepackage{indentfirst}" |
| 330 | puts $texfile "" |
| 331 | puts $texfile "% Font selection" |
| 332 | puts $texfile "\\usepackage\[T1\]{fontenc}" |
| 333 | puts $texfile "\\usepackage{mathptmx}" |
| 334 | puts $texfile "\\usepackage\[scaled=.90\]{helvet}" |
| 335 | puts $texfile "\\usepackage{courier}" |
| 336 | puts $texfile "\\usepackage{amssymb}" |
| 337 | puts $texfile "\\usepackage{sectsty}" |
| 338 | puts $texfile "\\renewcommand{\\familydefault}{\\sfdefault}" |
| 339 | puts $texfile "\\allsectionsfont{%" |
| 340 | puts $texfile " \\fontseries{bc}\\selectfont%" |
| 341 | puts $texfile " \\color{darkgray}%" |
| 342 | puts $texfile "}" |
| 343 | puts $texfile "\\renewcommand{\\DoxyLabelFont}{%" |
| 344 | puts $texfile " \\fontseries{bc}\\selectfont%" |
| 345 | puts $texfile " \\color{darkgray}%" |
| 346 | puts $texfile "}" |
| 347 | puts $texfile "" |
| 348 | puts $texfile "% Page & text layout" |
| 349 | puts $texfile "\\usepackage{geometry}" |
| 350 | puts $texfile "\\geometry{%" |
| 351 | puts $texfile " a4paper,%" |
| 352 | puts $texfile " top=2.5cm,%" |
| 353 | puts $texfile " bottom=2.5cm,%" |
| 354 | puts $texfile " left=2.5cm,%" |
| 355 | puts $texfile " right=2.5cm%" |
| 356 | puts $texfile "}" |
| 357 | puts $texfile "\\tolerance=750" |
| 358 | puts $texfile "\\hfuzz=15pt" |
| 359 | puts $texfile "\\hbadness=750" |
| 360 | puts $texfile "\\setlength{\\emergencystretch}{15pt}" |
| 361 | puts $texfile "\\setlength{\\parindent}{0cm}";#0.75cm |
| 362 | puts $texfile "\\setlength{\\parskip}{0.2cm}"; #0.2 |
| 363 | puts $texfile "\\makeatletter" |
| 364 | puts $texfile "\\renewcommand{\\paragraph}{%" |
| 365 | puts $texfile " \@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{%" |
| 366 | puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@parafont%" |
| 367 | puts $texfile " }%" |
| 368 | puts $texfile "}" |
| 369 | puts $texfile "\\renewcommand{\\subparagraph}{%" |
| 370 | puts $texfile " \\@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{%" |
| 371 | puts $texfile "\\normalfont\\normalsize\\bfseries\\SS@subparafont%" |
| 372 | puts $texfile " }%" |
| 373 | puts $texfile "}" |
| 374 | puts $texfile "\\makeatother" |
| 375 | puts $texfile "" |
| 376 | puts $texfile "% Headers & footers" |
| 377 | puts $texfile "\\usepackage{fancyhdr}" |
| 378 | puts $texfile "\\pagestyle{fancyplain}" |
| 379 | puts $texfile "\\fancyhead\[LE\]{\\fancyplain{}{\\bfseries\\thepage}}" |
| 380 | puts $texfile "\\fancyhead\[CE\]{\\fancyplain{}{}}" |
| 381 | puts $texfile "\\fancyhead\[RE\]{\\fancyplain{}{\\bfseries\\leftmark}}" |
| 382 | puts $texfile "\\fancyhead\[LO\]{\\fancyplain{}{\\bfseries\\rightmark}}" |
| 383 | puts $texfile "\\fancyhead\[CO\]{\\fancyplain{}{}}" |
| 384 | puts $texfile "\\fancyhead\[RO\]{\\fancyplain{}{\\bfseries\\thepage}}" |
| 385 | puts $texfile "\\fancyfoot\[LE\]{\\fancyplain{}{}}" |
| 386 | puts $texfile "\\fancyfoot\[CE\]{\\fancyplain{}{}}" |
| 387 | puts $texfile "\\fancyfoot\[RE\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}" |
| 388 | puts $texfile "\\fancyfoot\[LO\]{\\fancyplain{}{\\bfseries\\scriptsize (c) Open CASCADE 2001\-2013}}" |
| 389 | puts $texfile "\\fancyfoot\[CO\]{\\fancyplain{}{}}" |
| 390 | puts $texfile "\\fancyfoot\[RO\]{\\fancyplain{}{}}" |
| 391 | puts $texfile "\\renewcommand{\\footrulewidth}{0.4pt}" |
| 392 | puts $texfile "\\renewcommand{\\sectionmark}\[1\]{%" |
| 393 | puts $texfile " \\markright{\\thesection\\ #1}%" |
| 394 | puts $texfile "}" |
| 395 | puts $texfile "" |
| 396 | puts $texfile "% Indices & bibliography" |
| 397 | puts $texfile "\\usepackage{natbib}" |
| 398 | puts $texfile "\\usepackage\[titles\]{tocloft}" |
| 399 | puts $texfile "\\renewcommand{\\cftsecleader}{\\cftdotfill{\\cftdotsep}}" |
| 400 | puts $texfile "\\setcounter{tocdepth}{3}" |
| 401 | puts $texfile "\\setcounter{secnumdepth}{5}" |
| 402 | puts $texfile "\\makeindex" |
| 403 | puts $texfile "" |
| 404 | puts $texfile "% Hyperlinks (required, but should be loaded last)" |
| 405 | puts $texfile "\\usepackage{ifpdf}" |
| 406 | puts $texfile "\\ifpdf" |
| 407 | puts $texfile " \\usepackage\[pdftex,pagebackref=true\]{hyperref}" |
| 408 | puts $texfile "\\else" |
| 409 | puts $texfile " \\usepackage\[ps2pdf,pagebackref=true\]{hyperref}" |
| 410 | puts $texfile "\\fi" |
| 411 | puts $texfile "\\hypersetup{%" |
| 412 | puts $texfile " colorlinks=true,%" |
| 413 | puts $texfile " linkcolor=black,%" |
| 414 | puts $texfile " citecolor=black,%" |
| 415 | puts $texfile " urlcolor=blue,%" |
| 416 | puts $texfile " unicode%" |
| 417 | puts $texfile "}" |
| 418 | puts $texfile "" |
| 419 | puts $texfile "% Custom commands" |
| 420 | puts $texfile "\\newcommand{\\clearemptydoublepage}{%" |
| 421 | puts $texfile " \\newpage{\\pagestyle{empty}\\cleardoublepage}%" |
| 422 | puts $texfile "}" |
| 423 | puts $texfile "\n" |
| 424 | puts $texfile "%===== C O N T E N T S =====\n" |
| 425 | puts $texfile "\\begin{document}" |
| 426 | puts $texfile "" |
| 427 | puts $texfile "% Titlepage & ToC" |
| 428 | puts $texfile "\\hypersetup{pageanchor=false}" |
| 429 | puts $texfile "\\pagenumbering{roman}" |
| 430 | puts $texfile "\\begin{titlepage}" |
| 431 | puts $texfile "\\vspace*{7cm}" |
| 432 | puts $texfile "\\begin{center}%" |
| 433 | puts $texfile "\\includegraphics\[width=0.75\\textwidth, height=0.2\\textheight\]{../../../dox/resources/occt_logo.png}\\\\"; #\\\\\\\\ |
| 434 | puts $texfile "{\\Large Open C\\-A\\-S\\-C\\-A\\-D\\-E Technology \\\\\[1ex\]\\Large [OverviewDoc_DetectCasVersion $latexDir/../../../] }\\\\" |
| 435 | puts $texfile "\\vspace*{1cm}" |
| 436 | puts $texfile "{\\Large $docLabel}\\\\" |
| 437 | puts $texfile "\\vspace*{1cm}" |
| 438 | # puts $texfile "{\\large Generated by Doxygen 1.8.4}\\\\" |
| 439 | puts $texfile "\\vspace*{0.5cm}" |
| 440 | puts $texfile "{\\small \\today}\\" |
| 441 | puts $texfile "\\end{center}" |
| 442 | puts $texfile "\\end{titlepage}" |
| 443 | puts $texfile "\\clearpage" |
| 444 | puts $texfile "\\pagenumbering{roman}" |
| 445 | puts $texfile "\\tableofcontents" |
| 446 | puts $texfile "\\newpage" |
| 447 | puts $texfile "\\pagenumbering{arabic}" |
| 448 | puts $texfile "\\hypersetup{pageanchor=true}" |
| 449 | puts $texfile "" |
| 450 | puts $texfile "\\let\\stdsection\\section" |
| 451 | puts $texfile " \\renewcommand\\section{\\pagebreak\\stdsection}" |
| 452 | puts $texfile "\\hypertarget{$fileName}{}" |
| 453 | puts $texfile "\\input{$fileName}" |
| 454 | puts $texfile "" |
| 455 | puts $texfile "% Index" |
| 456 | puts $texfile "\\newpage" |
| 457 | puts $texfile "\\phantomsection" |
| 458 | puts $texfile "\\addcontentsline{toc}{part}{Index}" |
| 459 | puts $texfile "\\printindex\n" |
| 460 | puts $texfile "\\end{document}" |
| 461 | |
| 462 | close $texfile |
| 463 | } |
| 464 | |
| 465 | # Postprocesses generated TeX files |
| 466 | proc OverviewDoc_ProcessTex {{texFiles {}} {latexDir} verboseMode} { |
| 467 | |
| 468 | foreach TEX $texFiles { |
| 469 | if {$verboseMode == "YES"} { |
| 470 | puts "INFO: Preprocessing file $TEX" |
| 471 | } |
| 472 | |
| 473 | if {![file exists $TEX]} { |
| 474 | puts "file $TEX doesn't exist" |
| 475 | return |
| 476 | } |
| 477 | |
| 478 | set IN_F [open "$TEX" r] |
| 479 | set TMPFILENAME "$latexDir/temp.tex" |
| 480 | |
| 481 | set OUT_F [open $TMPFILENAME w] |
| 482 | |
| 483 | while {1} { |
| 484 | set line [gets $IN_F] |
| 485 | if { [string first "\\includegraphics" $line] != -1 } { |
| 486 | # Center images in TeX files |
| 487 | set line "\\begin{center}\n $line\n\\end{center}" |
| 488 | } elseif { [string first "\\subsection" $line] != -1 } { |
| 489 | # Replace \subsection with \section tag |
| 490 | regsub -all "\\\\subsection" $line "\\\\section" line |
| 491 | } elseif { [string first "\\subsubsection" $line] != -1 } { |
| 492 | # Replace \subsubsection with \subsection tag |
| 493 | regsub -all "\\\\subsubsection" $line "\\\\subsection" line |
| 494 | } elseif { [string first "\\paragraph" $line] != -1 } { |
| 495 | # Replace \paragraph with \subsubsection tag |
| 496 | regsub -all "\\\\paragraph" $line "\\\\subsubsection" line |
| 497 | } |
| 498 | puts $OUT_F $line |
| 499 | |
| 500 | if {[eof $IN_F]} { |
| 501 | close $IN_F |
| 502 | close $OUT_F |
| 503 | break |
| 504 | } |
| 505 | } |
| 506 | file delete -force $TEX |
| 507 | file rename $TMPFILENAME $TEX |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | # Main procedure for documents compilation |
| 512 | proc OverviewDoc_Main { {docfiles {}} generatorMode docLabel verboseMode searchMode hhcPath} { |
| 513 | |
| 514 | set INDIR [file normalize [file dirname [info script]]] |
| 515 | set CASROOT [file normalize [file dirname "$INDIR/../../"]] |
| 516 | set OUTDIR $CASROOT/doc |
| 517 | set PDFDIR $OUTDIR/overview/pdf |
| 518 | set HTMLDIR $OUTDIR/overview/html |
| 519 | set LATEXDIR $OUTDIR/overview/latex |
| 520 | set TAGFILEDIR $OUTDIR/refman |
| 521 | set DOXYFILE $OUTDIR/OCCT.cfg |
| 522 | |
| 523 | # Create or clean the output folders |
| 524 | if {[file exists $OUTDIR] == 0} { |
| 525 | file mkdir $OUTDIR |
| 526 | } |
| 527 | if {[file exists $HTMLDIR] == 0} { |
| 528 | file mkdir $HTMLDIR |
| 529 | } |
| 530 | if {[file exists $PDFDIR] == 0} { |
| 531 | file mkdir $PDFDIR |
| 532 | } |
| 533 | |
| 534 | if {[file exists $LATEXDIR]} { |
| 535 | #file delete {*}[glob -nocomplain $LATEXDIR/*.*] |
| 536 | file delete -force $LATEXDIR |
| 537 | } |
| 538 | file mkdir $LATEXDIR |
| 539 | |
| 540 | # Run tools to compile documents |
| 541 | puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating Doxyfile..." |
| 542 | |
| 543 | OverviewDoc_MakeDoxyfile $CASROOT "$OUTDIR/overview" $TAGFILEDIR $DOXYFILE $generatorMode $docfiles $verboseMode $searchMode $hhcPath |
| 544 | |
| 545 | # Run doxygen tool |
| 546 | if { $generatorMode == "HTML_ONLY"} { |
| 547 | puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating HTML files..." |
| 548 | } elseif { $generatorMode == "CHM_ONLY" } { |
| 549 | puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating CHM file..." |
| 550 | } |
| 551 | set RESULT [catch {exec doxygen $DOXYFILE > $OUTDIR/doxygen_out.log} DOX_ERROR] |
| 552 | if {$RESULT != 0} { |
| 553 | if {[llength [split $DOX_ERROR "\n"]] > 1} { |
| 554 | if {$verboseMode == "YES"} { |
| 555 | puts "See Doxygen log in $OUTDIR/doxygen_warnings_and_errors.log" |
| 556 | } |
| 557 | set DOX_ERROR_FILE [open "$OUTDIR/doxygen_warnings_and_errors.log" "w"] |
| 558 | puts $DOX_ERROR_FILE $DOX_ERROR |
| 559 | close $DOX_ERROR_FILE |
| 560 | } else { |
| 561 | puts $DOX_ERROR |
| 562 | } |
| 563 | } |
| 564 | # Close the Doxygen application |
| 565 | after 300 |
| 566 | |
| 567 | # Start PDF generation routine |
| 568 | if { $generatorMode == "PDF_ONLY" } { |
| 569 | puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating PDF files..." |
| 570 | |
| 571 | set OS $::tcl_platform(platform) |
| 572 | if { $OS == "unix" } { |
| 573 | set PREFIX ".sh" |
| 574 | } elseif { $OS == "windows" } { |
| 575 | set PREFIX ".bat" |
| 576 | } |
| 577 | |
| 578 | # Prepare a list of TeX files, generated by Doxygen |
| 579 | cd $LATEXDIR |
| 580 | |
| 581 | set TEXFILES [glob $LATEXDIR -type f -directory $LATEXDIR -tails "*.tex" ] |
| 582 | set REFMAN_IDX [lsearch $TEXFILES "refman.tex"] |
| 583 | set TEXFILES [lreplace $TEXFILES $REFMAN_IDX $REFMAN_IDX] |
| 584 | |
| 585 | |
| 586 | set IDX [lsearch $TEXFILES "$LATEXDIR"] |
| 587 | while { $IDX != -1} { |
| 588 | set TEXFILES [lreplace $TEXFILES $IDX $IDX] |
| 589 | set IDX [lsearch $TEXFILES "$LATEXDIR"] |
| 590 | } |
| 591 | |
| 592 | if {$verboseMode == "YES"} { |
| 593 | puts "Preprocessing generated TeX files..." |
| 594 | } |
| 595 | OverviewDoc_ProcessTex $TEXFILES $LATEXDIR $verboseMode |
| 596 | |
| 597 | if {$verboseMode == "YES"} { |
| 598 | puts "Generating PDF files from TeX files..." |
| 599 | } |
| 600 | foreach TEX $TEXFILES { |
| 601 | # Rewrite existing REFMAN.tex file... |
| 602 | set TEX [string range $TEX 0 [ expr "[string length $TEX] - 5"]] |
| 603 | OverviewDoc_MakeRefmanTex $TEX $LATEXDIR $docLabel $verboseMode |
| 604 | |
| 605 | if {$verboseMode == "YES"} { |
| 606 | puts "INFO: Generating PDF file from $TEX" |
| 607 | # ...and use it to generate PDF from TeX... |
| 608 | puts "Executing $LATEXDIR/make$PREFIX..." |
| 609 | } |
| 610 | set RESULT [catch {eval exec [auto_execok $LATEXDIR/make$PREFIX] > "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR] |
| 611 | if {$RESULT != 0} { |
| 612 | if {[llength [split $LaTeX_ERROR "\n"]] > 1} { |
| 613 | if {$verboseMode == "YES"} { |
| 614 | puts "See Latex log in $OUTDIR/pdflatex_warnings_and_errors.log" |
| 615 | } |
| 616 | set LaTeX_ERROR_FILE [open "$OUTDIR/pdflatex_warnings_and_errors.log" "w"] |
| 617 | puts $LaTeX_ERROR_FILE $LaTeX_ERROR |
| 618 | close $LaTeX_ERROR_FILE |
| 619 | } else { |
| 620 | puts $DOX_ERROR |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | # ...and place it to the specific folder |
| 625 | if { [file exists $PDFDIR/$TEX.pdf] == 1 } { |
| 626 | file delete -force $PDFDIR/$TEX.pdf |
| 627 | } |
| 628 | |
| 629 | if {![file exists "$LATEXDIR/refman.pdf"]} { |
| 630 | puts "Error: file $LATEXDIR/refman.pdf does not exist" |
| 631 | return |
| 632 | } |
| 633 | |
| 634 | file rename $LATEXDIR/refman.pdf "$PDFDIR/$TEX.pdf" |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | cd $INDIR |
| 639 | puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generation completed" |
| 640 | if { $generatorMode == "HTML_ONLY" } { |
| 641 | puts "View generated HTML documentation by opening: " |
| 642 | set RESFILE $OUTDIR/overview/html/index.html |
| 643 | puts "$RESFILE" |
| 644 | } |
| 645 | if { $generatorMode == "PDF_ONLY" } { |
| 646 | puts "PDF files are generated in: " |
| 647 | puts "$OUTDIR/overview/pdf folder" |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | # A command for User Documentation compilation |
| 652 | proc occdoc {args} { |
| 653 | # Programm options |
| 654 | set GEN_MODE "HTML_ONLY" |
| 655 | |
| 656 | set DOCFILES {} |
| 657 | set DOCLABEL "Default OCCT Document" |
| 658 | set VERB_MODE "NO" |
| 659 | set SEARCH_MODE "none" |
| 660 | set hhcPath "" |
| 661 | |
| 662 | global available_docfiles |
| 663 | global tcl_platform |
| 664 | global args_names |
| 665 | global args_values |
| 666 | global env |
| 667 | |
| 668 | # Load list of docfiles |
| 669 | if { [OverviewDoc_LoadFilesList] != 0 } { |
| 670 | puts "ERROR: File FILES.txt was not found" |
| 671 | return |
| 672 | } |
| 673 | |
| 674 | # Parse CL arguments |
| 675 | if {[OverviewDoc_ParseArguments $args] == 1} { |
| 676 | return |
| 677 | } |
| 678 | |
| 679 | foreach arg_n $args_names { |
| 680 | if {$arg_n == "h"} { |
| 681 | OverviewDoc_PrintHelpMessage |
| 682 | return |
| 683 | } elseif {$arg_n == "html"} { |
| 684 | set GEN_MODE "HTML_ONLY" |
| 685 | } elseif {$arg_n == "chm"} { |
| 686 | set GEN_MODE "CHM_ONLY" |
| 687 | |
| 688 | if {"$tcl_platform(platform)" == "windows" && [lsearch $args_names hhc] == -1} { |
| 689 | if { [info exist env(ProgramFiles\(x86\))] } { |
| 690 | set hhcPath "$env(ProgramFiles\(x86\))\\HTML Help Workshop\\hhc.exe" |
| 691 | puts "Info: hhc found: $hhcPath" |
| 692 | } elseif { [info exist env(ProgramFiles)] } { |
| 693 | set hhcPath "$env(ProgramFiles)\\HTML Help Workshop\\hhc.exe" |
| 694 | puts "Info: hhc found: $hhcPath" |
| 695 | } |
| 696 | |
| 697 | if { ! [file exists $hhcPath] } { |
| 698 | puts "Error: HTML Help Compiler is not found in standard location [file dirname $hhcPath]; use option -hhc" |
| 699 | return |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | } elseif {$arg_n == "hhc"} { |
| 704 | global tcl_platform |
| 705 | if { $tcl_platform(platform) != "windows" } { |
| 706 | continue |
| 707 | } |
| 708 | |
| 709 | if {$args_values(hhc) != "NULL"} { |
| 710 | set hhcPath $args_values(hhc) |
| 711 | if { [file isdirectory $hhcPath] } { |
| 712 | set hhcPath [file join ${hhcPath} hhc.exe] |
| 713 | } |
| 714 | if { ! [file exists $hhcPath] } { |
| 715 | puts "Error: HTML Help Compiler is not found in $hhcPath" |
| 716 | return |
| 717 | } |
| 718 | } else { |
| 719 | puts "Error in argument hhc" |
| 720 | return |
| 721 | } |
| 722 | |
| 723 | } elseif {$arg_n == "pdf"} { |
| 724 | set GEN_MODE "PDF_ONLY" |
| 725 | } elseif {$arg_n == "v"} { |
| 726 | set VERB_MODE "YES" |
| 727 | } elseif {$arg_n == "m"} { |
| 728 | if {$args_values(m) != "NULL"} { |
| 729 | set DOCFILES $args_values(m) |
| 730 | } else { |
| 731 | puts "Error in argument m" |
| 732 | return |
| 733 | } |
| 734 | |
| 735 | # Check if all chosen docfiles are correct |
| 736 | foreach docfile $DOCFILES { |
| 737 | if { [lsearch $available_docfiles $docfile] == -1 } { |
| 738 | puts "File \"$docfile\" is not presented in the list of available docfiles" |
| 739 | puts "Please, specify the correct docfile name" |
| 740 | return |
| 741 | } else { |
| 742 | puts "File $docfile is presented in FILES.TXT" |
| 743 | } |
| 744 | } |
| 745 | } elseif {$arg_n == "l"} { |
| 746 | if { [llength $DOCFILES] <= 1 } { |
| 747 | if {$args_values(l) != "NULL"} { |
| 748 | set DOCLABEL $args_values(l) |
| 749 | } else { |
| 750 | puts "Error in argument l" |
| 751 | return |
| 752 | } |
| 753 | } |
| 754 | } elseif {$arg_n == "s"} { |
| 755 | if {$args_values(s) != "NULL"} { |
| 756 | set SEARCH_MODE $args_values(s) |
| 757 | } else { |
| 758 | puts "Error in argument s" |
| 759 | return |
| 760 | } |
| 761 | } else { |
| 762 | puts "\nWrong argument: $arg_n" |
| 763 | OverviewDoc_PrintHelpMessage |
| 764 | return |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | # Specify verbose mode |
| 769 | if { $GEN_MODE != "PDF_ONLY" && [llength $DOCFILES] > 1 } { |
| 770 | set DOCLABEL "" |
| 771 | } |
| 772 | |
| 773 | # If we don't specify list for docfiles with -m argument, |
| 774 | # we assume that we have to generate all docfiles |
| 775 | if { [llength $DOCFILES] == 0 } { |
| 776 | set DOCFILES $available_docfiles |
| 777 | } |
| 778 | |
| 779 | # Start main activities |
| 780 | OverviewDoc_Main $DOCFILES $GEN_MODE $DOCLABEL $VERB_MODE $SEARCH_MODE $hhcPath |
| 781 | } |