#
# Alternatively, this file may be used under the terms of Open CASCADE
# commercial license or contractual agreement.
-#
-# Brief: This script compiles OCCT documents from *.md files to HTML pages
+
# =======================================================================
+# This script defines command gendoc compiling OCCT documents
+# from *.md files to HTML pages
+# =======================================================================
+
+# load auxiliary tools
+source [file join [file dirname [info script]] occaux.tcl]
# ======================================
# Common functions
puts " -s=<search_mode> : Specifies the Search mode of HTML documents"
puts " Can be: none | local | server | external"
puts " -h : Prints this help message"
- puts " -v : Enables more verbose output"
+ puts " -v : Enables more verbose output"
}
# A command for User Documentation compilation
set DOCLABEL ""
set VERB_MODE "NO"
set SEARCH_MODE "none"
- set MATHJAX_LOCATION "http://cdn.mathjax.org/mathjax/latest"
+ set MATHJAX_LOCATION "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1"
set mathjax_js_name "MathJax.js"
set DOCTYPE_COMBO_FLAG 0
set GENMODE_COMBO_FLAG 0
if { $DOCTYPE_COMBO_FLAG != 1 } {
set DOC_TYPE "REFMAN"
set DOCTYPE_COMBO_FLAG 1
- if { [file exists [pwd]/src/VAS/Products.tcl] } {
+ if { [file exists [OCCDoc_GetProdRootDir]/src/VAS/Products.tcl] } {
set GENERATE_PRODUCTS_REFMAN "YES"
}
} else {
puts ""
}
- if { $GENERATE_PRODUCTS_REFMAN == "YES" } {
- if { [ lsearch $args_names "m" ] == -1 } {
- puts "\nError: Cannot generate Reference Manual for the whole set of OCC Products."
- puts "Aborting..."
- return -1
- }
- }
} elseif {$arg_n == "v"} {
set VERB_MODE "YES"
} elseif {$arg_n == "ug"} {
puts ""
- # Clean logfiles
- set OUTDIR [OCCDoc_GetRootDir]/doc/
- set DOXYLOG $OUTDIR/doxygen_warnings_and_errors.log
- set PDFLOG $OUTDIR/pdflatex_warnings_and_errors.log
-
- file delete -force $PDFLOG
- file delete -force $DOXYLOG
-
# Start main activities
if { $GEN_MODE != "PDF_ONLY" } {
- OCCDoc_Main $DOC_TYPE $DOCFILES $MODULES $GEN_MODE $VERB_MODE $SEARCH_MODE $MATHJAX_LOCATION $GENERATE_PRODUCTS_REFMAN $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
+ if { [OCCDoc_GetProdRootDir] == ""} {
+ OCCDoc_Main $DOC_TYPE $DOCFILES $MODULES $GEN_MODE $VERB_MODE $SEARCH_MODE $MATHJAX_LOCATION $GENERATE_PRODUCTS_REFMAN $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
+ } else {
+ if { $DOC_TYPE == "REFMAN" } {
+ if { $MODULES != "" } {
+ foreach module $MODULES {
+ OCCDoc_Main $DOC_TYPE $DOCFILES $module $GEN_MODE $VERB_MODE $SEARCH_MODE $MATHJAX_LOCATION $GENERATE_PRODUCTS_REFMAN $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
+ }
+ } else {
+ OCCDoc_Main $DOC_TYPE $DOCFILES $MODULES $GEN_MODE $VERB_MODE $SEARCH_MODE $MATHJAX_LOCATION $GENERATE_PRODUCTS_REFMAN $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
+ }
+ } else {
+ foreach md $DOCFILES {
+ OCCDoc_Main $DOC_TYPE $md $MODULES $GEN_MODE $VERB_MODE $SEARCH_MODE $MATHJAX_LOCATION $GENERATE_PRODUCTS_REFMAN $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
+ }
+ }
+ }
} else {
- puts "Generating OCCT User Guides in PDF format...\n"
+ puts "Generating OCCT User Guides in PDF format..."
foreach pdf $DOCFILES {
- puts "Info: Processing file $pdf\n"
+ puts "\nInfo: Processing file $pdf"
# Some values are hardcoded because they are related only to PDF generation
OCCDoc_Main "OVERVIEW" [list $pdf] {} "PDF_ONLY" $VERB_MODE "none" $MATHJAX_LOCATION "NO" $DOXYGEN_PATH $GRAPHVIZ_PATH $INKSCAPE_PATH $HHC_PATH
}
- puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generation completed."
- puts "\nPDF files are generated in \n[file normalize [OCCDoc_GetRootDir]/doc/pdf]"
+ puts "\n[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generation completed."
}
}
global available_docfiles
global available_pdf
- set PRODPATH ""
- if { [string compare -nocase $generateProductsRefman "YES"] == 0 } {
- set PRODPATH [pwd]
- }
-
- set ROOTDIR [OCCDoc_GetRootDir $PRODPATH]
+ set ROOTDIR [OCCDoc_GetRootDir [OCCDoc_GetProdRootDir]]
set INDIR [OCCDoc_GetDoxDir]
set OUTDIR $ROOTDIR/doc
set PDFDIR $OUTDIR/pdf
set LATEXDIR $OUTDIR/overview/latex
set DOXYFILE $OUTDIR/OCCT.cfg
+ # OUTDIR for products documentation should be separate directories for each components
+ if { [OCCDoc_GetProdRootDir] != ""} {
+ if { $docType == "REFMAN" } {
+ if { "$modules" != "" } {
+ source "[OCCDoc_GetSourceDir [OCCDoc_GetProdRootDir]]/VAS/${modules}.tcl"
+ set doc_component_name [${modules}:documentation_name]
+ set OUTDIR $OUTDIR/$doc_component_name
+ }
+ } else {
+ if {[regexp {([^/]+)/([^/]+)/([^/]+)} $docfiles dump doc_type doc_component doc_name]} {
+ set PDFNAME [file rootname $doc_name]
+ set OUTDIR $OUTDIR/$doc_component
+ } else {
+ error "Could not parse input path to *.md file: \"${docfiles}\""
+ }
+ }
+ set HTMLDIR $OUTDIR/html
+ set LATEXDIR $OUTDIR/latex
+ set DOXYFILE $OUTDIR/OCCT.cfg
+ set TAGFILEDIR $OUTDIR/refman
+ }
+
# Create or cleanup the output folders
if { [string compare -nocase $generateProductsRefman "YES"] != 0 } {
if { ![file exists $OUTDIR] } {
if { ![file exists $HTMLDIR] } {
file mkdir $HTMLDIR
}
- if { ![file exists $PDFDIR] } {
- file mkdir $PDFDIR
- }
- if { ![file exists $UGDIR] } {
- file mkdir $UGDIR
- }
- if { ![file exists $DGDIR] } {
- file mkdir $DGDIR
+ if { [OCCDoc_GetProdRootDir] == ""} {
+ if { ![file exists $PDFDIR] } {
+ file mkdir $PDFDIR
+ }
+ if { ![file exists $UGDIR] } {
+ file mkdir $UGDIR
+ }
+ if { ![file exists $DGDIR] } {
+ file mkdir $DGDIR
+ }
}
- if { [file exists $LATEXDIR] } {
- file delete -force $LATEXDIR
+
+ if { $generatorMode == "PDF_ONLY" } {
+ if { [file exists $LATEXDIR] } {
+ file delete -force $LATEXDIR
+ }
+ file mkdir $LATEXDIR
}
- file mkdir $LATEXDIR
}
if { $docType == "REFMAN" } {
if { ![file exists $TAGFILEDIR] } {
set DOCDIR "$OUTDIR/refman"
puts "\nGenerating Open CASCADE Reference Manual\n"
} elseif { $docType == "OVERVIEW" } {
- set DOCDIR "$OUTDIR/overview"
+ if { [OCCDoc_GetProdRootDir] == ""} {
+ set DOCDIR "$OUTDIR/overview"
+ } else {
+ set DOCDIR "$OUTDIR"
+ }
set FORMAT ""
if { ($generatorMode == "HTML_ONLY") || ($generatorMode == "CHM_ONLY") } {
if { $generatorMode == "HTML_ONLY" } {
# Generate Doxyfile
puts "[clock format [clock seconds] -format {%Y-%m-%d %H:%M}] Generating Doxyfile..."
- if { [OCCDoc_MakeDoxyfile $docType $DOCDIR $TAGFILEDIR $DOXYFILE $generatorMode $docfiles $modules $verboseMode $searchMode $HHC_PATH $mathjax_relative_location $GRAPHVIZ_PATH $PRODPATH] == -1 } {
+ if { [OCCDoc_MakeDoxyfile $docType $DOCDIR $TAGFILEDIR $DOXYFILE $generatorMode $docfiles $modules $verboseMode $searchMode $HHC_PATH $mathjax_relative_location $GRAPHVIZ_PATH [OCCDoc_GetProdRootDir]] == -1 } {
return -1
}
set starttimestamp [clock format [clock seconds] -format {%Y-%m-%d %H:%M}]
if { ($generatorMode == "HTML_ONLY") || ($docType == "REFMAN") } {
+ set LOGPREFIX "html_"
puts "$starttimestamp Generating HTML files..."
# Copy index file to provide fast access to HTML documentation
file copy -force $INDIR/resources/index.html $DOCDIR/index.html
} elseif { $generatorMode == "CHM_ONLY" } {
+ set LOGPREFIX "chm_"
puts "$starttimestamp Generating CHM file..."
} elseif { $generatorMode == "PDF_ONLY" } {
+ set LOGPREFIX "[file rootname [file tail [lindex $docfiles 0]]]_"
puts "$starttimestamp Generating PDF file..."
}
- set DOXYLOG $OUTDIR/doxygen_warnings_and_errors.log
- set RESULT [catch {exec $DOXYGEN_PATH $DOXYFILE >> $OUTDIR/doxygen_out.log} DOX_ERROR]
+ # Clean logfiles
+ set DOXYLOG $OUTDIR/${LOGPREFIX}doxygen_err.log
+ set DOXYOUT $OUTDIR/${LOGPREFIX}doxygen_out.log
+ file delete -force $DOXYLOG
+ file delete -force $DOXYOUT
+
+ set RESULT [catch {exec $DOXYGEN_PATH $DOXYFILE >> $DOXYOUT} DOX_ERROR]
if {$RESULT != 0} {
set NbErrors [regexp -all -line {^\s*[^\s]+} $DOX_ERROR]
if {$NbErrors > 0} {
- puts "\nWarning: Doxygen reported $NbErrors messages."
- puts "See log in $DOXYLOG\n"
+ puts "Warning: Doxygen reported $NbErrors messages."
+ puts "See log in $DOXYLOG"
set DOX_ERROR_FILE [open $DOXYLOG "a"]
if {$generatorMode == "PDF_ONLY"} {
puts $DOX_ERROR_FILE "\n===================================================="
if {[OCCDoc_PostProcessor $DOCDIR] == 0} {
puts "$curtime Generation completed."
puts "\nInfo: doxygen log file is located in:"
- puts "$OUTDIR/doxygen_out.log."
+ puts "${DOXYOUT}."
puts "\nReference Manual is generated in \n$DOCDIR"
}
} elseif { $docType == "OVERVIEW" } {
puts "Info: Executing $LATEXDIR/Makefile..."
}
}
- set PDFLOG $OUTDIR/pdflatex_warnings_and_errors.log
+
+ set PDFLOG $OUTDIR/${LOGPREFIX}pdflatex_err.log
+ set PDFOUT $OUTDIR/${LOGPREFIX}pdflatex_out.log
+ file delete -force $PDFLOG
+ file delete -force $PDFOUT
if {"$is_win" == "yes"} {
- set RESULT [catch {eval exec [auto_execok $LATEXDIR/make.bat] >> "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR]
+ set RESULT [catch {eval exec [auto_execok $LATEXDIR/make.bat] >> "$PDFOUT"} LaTeX_ERROR]
} else {
- set RESULT [catch {eval exec "make -f $LATEXDIR/Makefile" >> "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR]
+ set RESULT [catch {eval exec "make -f $LATEXDIR/Makefile" >> "$PDFOUT"} LaTeX_ERROR]
# Small workaround for *nix stations
set prev_loc [pwd]
cd $LATEXDIR
- set RESULT [catch {eval exec "pdflatex refman.tex" >> "$OUTDIR/pdflatex_out.log"} LaTeX_ERROR]
+ set RESULT [catch {eval exec "pdflatex refman.tex" >> "$PDFOUT"} LaTeX_ERROR]
cd $prev_loc
}
if {$RESULT != 0} {
set NbErrors [regexp -all -line {^\s*[^\s]+} $LaTeX_ERROR]
if {$NbErrors > 0} {
- puts "\nWarning: PDFLaTeX reported $NbErrors messages.\nSee log in $PDFLOG\n"
- set LaTeX_ERROR_FILE [open $PDFLOG "a"]
+ puts "Warning: PDFLaTeX reported $NbErrors messages.\nSee log in $PDFLOG"
+ set LaTeX_ERROR_FILE [open $PDFLOG "a+"]
puts $LaTeX_ERROR_FILE "\n===================================================="
puts $LaTeX_ERROR_FILE "Logfile of file $TEX:"
puts $LaTeX_ERROR_FILE "====================================================\n"
set destFolder $PDFDIR
set parsed_string [split $TEX "_"]
- if { [lsearch $parsed_string "tutorial"] != -1 } {
- set TEX [string map [list occt__ occt_] $TEX]
- set destFolder $PDFDIR
- } elseif { [lsearch $parsed_string "user"] != -1 } {
- set TEX [string map [list user_guides__ ""] $TEX]
- set destFolder $UGDIR
- } elseif { [lsearch $parsed_string "dev"] != -1 } {
- set TEX [string map [list dev_guides__ ""] $TEX]
- set destFolder $DGDIR
+ if { [OCCDoc_GetProdRootDir] == ""} {
+ if { [lsearch $parsed_string "tutorial"] != -1 } {
+ set TEX [string map [list occt__ occt_] $TEX]
+ set destFolder $PDFDIR
+ } elseif { [lsearch $parsed_string "user"] != -1 } {
+ set TEX [string map [list user_guides__ ""] $TEX]
+ set destFolder $UGDIR
+ } elseif { [lsearch $parsed_string "dev"] != -1 } {
+ set TEX [string map [list dev_guides__ ""] $TEX]
+ set destFolder $DGDIR
+ }
+ } else {
+ set destFolder $OUTDIR
+ set TEX "$PDFNAME"
}
file rename -force $LATEXDIR/refman.pdf "$destFolder/$TEX.pdf"
-
+ puts "Generated $destFolder/$TEX.pdf"
}
} elseif { $generatorMode == "CHM_ONLY" } {
- file rename $OUTDIR/overview.chm $OUTDIR/occt_overview.chm
+ if { [OCCDoc_GetProdRootDir] == ""} {
+ file rename $OUTDIR/overview.chm $OUTDIR/occt_overview.chm
+ } else {
+ file rename -force $ROOTDIR/doc/overview.chm $OUTDIR/occt_overview.chm
+ }
}
cd $INDIR
if { $generatorMode == "HTML_ONLY" } {
- puts "\nHTML documentation is generated in \n$DOCDIR"
- }
- if { $generatorMode == "CHM_ONLY" } {
- puts "\nGenerated CHM documentation is in \n$OUTDIR/overview.chm"
+ puts "HTML documentation is generated in \n$DOCDIR"
+ } elseif { $generatorMode == "CHM_ONLY" } {
+ puts "Generated CHM documentation is in \n$OUTDIR/overview.chm"
}
-
- puts ""
}
# Remove temporary Doxygen files
foreach file $deleteList {
file delete $file
}
+
return 0
}
# Generates Doxygen configuration file for Overview documentation
proc OCCDoc_MakeDoxyfile {docType outDir tagFileDir {doxyFileName} {generatorMode ""} {DocFilesList {}} {ModulesList {}} verboseMode searchMode hhcPath mathjaxLocation graphvizPath productsPath} {
+ global module_dependency
+
+ set inputDir [OCCDoc_GetDoxDir [OCCDoc_GetProdRootDir]]
- set inputDir [OCCDoc_GetDoxDir]
- set TEMPLATES_DIR $inputDir/resources
+ set TEMPLATES_DIR [OCCDoc_GetDoxDir]/resources
set occt_version [OCCDoc_DetectCasVersion]
# Delete existent doxyfile
set name OCCT
}
+ OCCDoc_LoadData "${productsPath}"
+
+ # Add all dependencies of modules to the graph
+ set additional_modules {}
+ foreach module $modules {
+ set additional_modules [list {*}$additional_modules {*}$module_dependency($module)]
+ }
+ set modules [list {*}$modules {*}$additional_modules]
+ set modules [lsort -unique $modules]
+
# Get list of header files in the specified modules
set filelist {}
foreach module $modules {
foreach tk [$module:toolkits] {
foreach pk [split [OCCDoc_GetPackagesList [OCCDoc_Locate $tk $productsPath]]] {
if { [llength $pk] != "{}" } {
- lappend filelist [OCCDoc_GetHeadersList "p" "pubinclude" "$pk" "$productsPath"]
+ lappend filelist [OCCDoc_GetHeadersList "p" "$pk" "$productsPath"]
}
}
}
puts $doxyFile "DOTFILE_DIRS = $outDir/html"
puts $doxyFile "DOT_PATH = $graphvizPath"
- puts $doxyFile "INCLUDE_PATH = [OCCDoc_GetIncDir $productsPath]"
+ puts $doxyFile "INCLUDE_PATH = [OCCDoc_GetSourceDir $productsPath]"
# list of files to generate
set mainpage [OCCDoc_MakeMainPage $outDir $outDir/$name.dox $modules $productsPath]
# Add common options for generation of Overview and User Guides
puts $doxyFile "PROJECT_NUMBER = $occt_version"
puts $doxyFile "OUTPUT_DIRECTORY = $outDir/."
- puts $doxyFile "PROJECT_LOGO = $inputDir/resources/occ_logo.png"
+ puts $doxyFile "PROJECT_LOGO = [OCCDoc_GetDoxDir]/resources/occ_logo.png"
set PARAM_INPUT "INPUT ="
- set PARAM_IMAGEPATH "IMAGE_PATH = $inputDir/resources/ "
+ set PARAM_IMAGEPATH "IMAGE_PATH = [OCCDoc_GetDoxDir]/resources/ "
foreach docFile $DocFilesList {
set NEW_IMG_PATH "$inputDir/$docFile"
if { [string compare $NEW_IMG_PATH [OCCDoc_GetRootDir $productsPath]] != 0 } {