1 # ==========================================================================#
2 # Brief: This script compiles OCCT documents from *.md files to HTML pages #
3 # ==========================================================================#
5 # ======================================
7 # ======================================
9 # Print single line or print the line to the file
10 function(puts theLine)
12 message(STATUS "${theLine}")
13 elseif(${ARGC} EQUAL 2)
14 file(APPEND ${ARGV0} "${ARGV1}\n")
18 # Print CMake Error, stop processing and generation
19 function(error theLine)
20 message(FATAL_ERROR "${theLine}")
24 function (OCCDoc_PrintHelpMessage)
25 puts("Usage: gendoc [-h] {-refman|-overview} [-html|-pdf|-chm] [-m=<list of modules>|-ug=<list of docs>] [-v] [-s=<search_mode>] [-mathjax=<path>]")
29 puts("choice of documentation to be generated:")
30 puts(" -overview : To generate Overview and User Guides")
31 puts(" (cannot be used with -refman)")
32 puts(" -refman : To generate class Reference Manual")
33 puts(" (cannot be used with -overview)")
35 puts("choice of output format:")
36 puts(" -html : To generate HTML files")
37 puts(" (default, cannot be used with -pdf or -chm)")
38 puts(" -pdf : To generate PDF files")
39 puts(" (cannot be used with -refman, -html, or -chm)")
40 puts(" -chm : To generate CHM files")
41 puts(" (cannot be used with -html or -pdf)")
43 puts("additional options:")
44 puts(" -m=<modules_list> : List of OCCT modules (separated with comma),")
45 puts(" for generation of Reference Manual")
46 puts(" -ug=<docs_list> : List of MarkDown documents (separated with comma),")
47 puts(" to use for generation of Overview / User Guides")
48 puts(" -mathjax=<path> : To use local or alternative copy of MathJax")
49 puts(" -s=<search_mode> : Specifies the Search mode of HTML documents")
50 puts(" Can be: none | local | server | external")
51 puts(" -h : Prints this help message")
52 puts(" -v : Enables more verbose output")
55 # A command for User Documentation compilation
58 set (DOC_TYPE "REFMAN")
59 set (GEN_MODE "HTML_ONLY")
64 set (SEARCH_MODE "none")
65 set (MATHJAX_LOCATION "http://cdn.mathjax.org/mathjax/latest")
66 set (mathjax_js_name "MathJax.js")
67 set (DOCTYPE_COMBO_FLAG 0)
68 set (GENMODE_COMBO_FLAG 0)
69 set (GENERATE_PRODUCTS_REFMAN "NO")
71 #available_docfiles; # The full list of md files for HTML or CHM generation
72 #available_pdf; # The full list of md files for PDF generation
76 # Load list of docfiles
77 OCCDoc_LoadFilesList()
80 OCCDoc_ParseArguments(${ARGV})
82 # Print help message if no arguments provided
83 separate_arguments(args_names)
84 list(LENGTH args_names length)
85 if (${length} EQUAL 0)
86 OCCDoc_PrintHelpMessage()
90 list(FIND args_names "pdf" FIND_pdf)
91 list(FIND args_names "chm" FIND_chm)
92 list(FIND args_names "ug" FIND_ug)
93 list(FIND args_names "m" FIND_m)
94 list(FIND args_names "refman" FIND_refman)
95 list(FIND args_names "overview" FIND_overview)
96 foreach (arg_n ${args_names})
97 if ("${arg_n}" STREQUAL "h")
98 OCCDoc_PrintHelpMessage()
100 elseif ("${arg_n}" STREQUAL "html")
101 if(${FIND_refman} EQUAL -1 AND ${FIND_overview} EQUAL -1 )
102 error("Error: Please specify -refman or -overview argument.")
104 if(${FIND_refman} EQUAL -1)
105 if (NOT ${GENMODE_COMBO_FLAG} EQUAL 1)
106 set (GEN_MODE "HTML_ONLY")
107 set (GENMODE_COMBO_FLAG 1)
109 error("Error: Options -html, -pdf and -chm can not be combined.")
112 elseif ("${arg_n}" STREQUAL "chm")
113 if(${FIND_refman} EQUAL -1 AND ${FIND_overview} EQUAL -1 )
114 error("Error: Please specify -refman or -overview argument.")
116 if(${FIND_refman} EQUAL -1)
117 if(NOT ${GENMODE_COMBO_FLAG} EQUAL 1)
118 set (GEN_MODE "CHM_ONLY")
119 set (GENMODE_COMBO_FLAG 1)
121 error("Error: Options -html, -pdf and -chm cannot be combined.")
124 elseif ("${arg_n}" STREQUAL "pdf")
125 if(${FIND_refman} EQUAL -1 AND ${FIND_overview} EQUAL -1 )
126 error("Error: Please specify -refman or -overview argument.")
128 if(${FIND_refman} EQUAL -1)
129 if (NOT ${GENMODE_COMBO_FLAG} EQUAL 1)
130 set (GEN_MODE "PDF_ONLY")
131 set (GENMODE_COMBO_FLAG 1)
133 error("Error: Options -html, -pdf and -chm cannot be combined.")
136 elseif ("${arg_n}" STREQUAL "overview")
137 if (NOT ${DOCTYPE_COMBO_FLAG} EQUAL 1)
138 set (DOC_TYPE "OVERVIEW")
139 set (DOCTYPE_COMBO_FLAG 1)
141 error("Error: Options -refman and -overview cannot be combined.")
143 # Print ignored options
144 if ( NOT ${FIND_m} EQUAL -1 )
145 puts ("Info: The following options will be ignored:")
149 elseif ("${arg_n}" STREQUAL "refman")
150 if (NOT ${DOCTYPE_COMBO_FLAG} EQUAL 1)
151 set (DOC_TYPE "REFMAN")
152 set (DOCTYPE_COMBO_FLAG 1)
153 if ( EXISTS "${PRODUCTS_SOURCE_DIR}/src/VAS/Products.tcl")
154 set (GENERATE_PRODUCTS_REFMAN "YES")
157 error("Error: Options -refman and -overview cannot be combined.")
159 # Print ignored options
160 if (NOT ${FIND_pdf} EQUAL -1 OR NOT ${FIND_chm} EQUAL -1 OR NOT ${FIND_ug} EQUAL -1)
161 puts ("Info: The following options will be ignored:")
162 if (NOT ${FIND_pdf} EQUAL -1)
165 if (NOT ${FIND_chm} EQUAL -1)
168 if (NOT ${FIND_ug} EQUAL -1)
173 if ( "${GENERATE_PRODUCTS_REFMAN}" STREQUAL "YES")
174 if (${FIND_m} EQUAL -1)
175 error("Error: Cannot generate Reference Manual for the whole set of OCC Products.")
178 elseif ("${arg_n}" STREQUAL "v")
179 set (VERB_MODE "YES")
180 elseif ("${arg_n}" STREQUAL "ug")
181 if(${FIND_refman} EQUAL -1)
182 list(FIND args_names "ug" curIndex)
183 list(GET args_values ${curIndex} curValue)
184 if ( NOT "${curValue}" STREQUAL "NULL")
185 string(REPLACE "," " " curValue "${curValue}")
186 separate_arguments(curValue)
187 set (DOCFILES ${curValue})
189 error("Error in argument ug.")
191 # Check if all chosen docfiles are correct
192 foreach (docfile ${DOCFILES})
193 if(${FIND_pdf} EQUAL -1)
194 # Check to generate HTMLs
195 list(FIND available_docfiles "${docfile}" FIND_doc)
196 if (${FIND_doc} EQUAL -1)
197 error("Error: File \"${docfile}\" is not presented in the list of available docfiles.")
200 # Check to generate PDFs
201 list(FIND available_pdf "${docfile}" FIND_doc)
202 if ( ${FIND_doc} EQUAL -1)
203 error("Error: File \"${docfile}\" is not presented in the list of generic PDFs.")
208 elseif ("${arg_n}" STREQUAL "m")
209 if (${FIND_overview} EQUAL -1)
210 list(FIND args_names "m" curIndex)
211 list(GET args_values ${curIndex} curValue)
212 if ( NOT "${curValue}" STREQUAL "NULL")
213 string(REPLACE "," " " curValue "${curValue}")
214 separate_arguments(curValue)
215 set(MODULES ${curValue})
217 error("Error in argument m.")
220 elseif ("${arg_n}" STREQUAL "s")
221 if (${FIND_pdf} EQUAL -1)
222 list(FIND args_names "s" curIndex)
223 list(GET args_values ${curIndex} curValue)
224 if ( NOT "${curValue}" STREQUAL "NULL")
225 string(REPLACE "," " " curValue "${curValue}")
226 separate_arguments(curValue)
227 set (SEARCH_MODE ${curValue})
229 error("Error in argument s.")
232 elseif ("${arg_n}" STREQUAL "mathjax")
233 if (NOT ${FIND_pdf} EQUAL -1)
234 list(FIND args_names "mathjax" curIndex)
235 list(GET args_values ${curIndex} curValue)
236 string(REPLACE "," " " curValue "${curValue}")
237 separate_arguments(curValue)
238 set (possible_mathjax_loc ${curValue})
239 if (EXISTS "${possible_mathjax_loc}/${mathjax_js_name}")
240 set (MATHJAX_LOCATION ${curValue})
241 puts ("${MATHJAX_LOCATION}")
243 puts ("Warning: ${mathjax_js_name} is not found in ${possible_mathjax_loc}.")
244 puts (" MathJax will be used from ${MATHJAX_LOCATION}")
247 puts("Warning: MathJax is not used with pdf and will be ignored.")
250 OCCDoc_PrintHelpMessage()
251 error("Wrong argument: ${arg_n}")
255 # Check the existence of the necessary tools
256 find_program(DOC_DOXYGEN_PATH "doxygen")
257 if ("${DOC_DOXYGEN_PATH}" STREQUAL "DOC_DOXYGEN_PATH-NOTFOUND")
258 error(" Aborting... Could not find Doxygen, check DOC_DOXYGEN_PATH variable")
261 if("${DOC_TYPE}" STREQUAL "REFMAN")
262 find_program(DOC_GRAPHVIZ_PATH "dot")
263 if ("${DOC_GRAPHVIZ_PATH}" STREQUAL "DOC_GRAPHVIZ_PATH-NOTFOUND")
264 puts("Warning: Could not find Dot Part of Graphviz software. Doxygen will skip generation of class diagrams in Reference Manual, check DOC_GRAPHVIZ_PATH variable")
269 if ("${GEN_MODE}" STREQUAL "CHM_ONLY")
270 find_program(DOC_HHC_PATH "hhc")
271 if("${DOC_HHC_PATH}" STREQUAL "DOC_HHC_PATH-NOTFOUND")
272 error(" Aborting... Could not find HHC, check DOC_HHC_PATH variable")
277 if ("${GEN_MODE}" STREQUAL "PDF_ONLY")
278 find_program(DOC_INKSCAPE_PATH "inkscape")
279 if("${DOC_INKSCAPE_PATH}" STREQUAL "DOC_INKSCAPE_PATH-NOTFOUND")
280 puts ("Warning: Could not find Inkscape, check DOC_INKSCAPE_PATH variable.")
281 puts ("\tSVG images will be lost in PDF documents.")
283 find_program(DOC_PDFLATEX_PATH "pdflatex")
284 if("${DOC_PDFLATEX_PATH}" STREQUAL "DOC_PDFLATEX_PATH-NOTFOUND")
285 error(" Aborting... Could not find PDFLATEX, check DOC_PDFLATEX_PATH variable")
289 # If we do not specify list for docfiles with -m argument,
290 # we assume that we have to generate all docfiles
291 list(LENGTH DOCFILES DOCFILES_length)
292 if (${DOCFILES_length} EQUAL 0)
293 if (NOT "${GEN_MODE}" STREQUAL "PDF_ONLY")
294 set (DOCFILES ${available_docfiles})
296 set (DOCFILES ${available_pdf})
300 OCCDoc_GetRootDir(ROOTDIR)
303 set (OUTDIR "${ROOTDIR}/doc")
304 set (DOXYLOG "${OUTDIR}/doxygen_warnings_and_errors.log")
305 set (PDFLOG "${OUTDIR}/pdflatex_warnings_and_errors.log")
307 file(REMOVE "${PDFLOG}")
308 file(REMOVE "${DOXYLOG}")
310 # Start main activities
311 if (NOT "${GEN_MODE}" STREQUAL "PDF_ONLY")
312 OCCDoc_Main(${DOC_TYPE} DOCFILES MODULES ${GEN_MODE} ${VERB_MODE} ${SEARCH_MODE} ${MATHJAX_LOCATION} ${GENERATE_PRODUCTS_REFMAN} available_docfiles available_pdf)
314 puts ("Generating OCCT User Guides in PDF format...")
315 foreach (pdf ${DOCFILES})
316 puts ("Info: Processing file ${pdf}")
317 # Some values are hardcoded because they are related only to PDF generation
318 separate_arguments(pdf)
319 OCCDoc_Main("OVERVIEW" pdf "" "PDF_ONLY" ${VERB_MODE} "none" ${MATHJAX_LOCATION} "NO" available_docfiles available_pdf)
321 string(TIMESTAMP time "%Y-%m-%d %H:%M")
322 puts ("${time} Generation completed.")
323 puts ("PDF files are generated in \n\t${OUTDIR}/pdf")
327 # Main procedure for documents compilation
328 function (OCCDoc_Main docType docfiles modules generatorMode verboseMode searchMode mathjaxLocation generateProductsRefman the_available_docfiles the_available_pdf)
329 set(docfiles ${${docfiles}})
330 set(modules ${${modules}})
331 set(available_docfiles ${${the_available_docfiles}})
332 set(available_pdf ${${the_available_pdf}})
334 if ("${generateProductsRefman}" STREQUAL "YES")
335 set (ROOTDIR "${PRODUCTS_SOURCE_DIR}")
337 set (ROOTDIR "${OCCT_SOURCE_DIR}")
340 OCCDoc_GetDoxDir(INDIR)
341 set (OUTDIR "${ROOTDIR}/doc")
342 set (PDFDIR "${OUTDIR}/pdf")
343 set (UGDIR "${PDFDIR}/user_guides")
344 set (DGDIR "${PDFDIR}/dev_guides")
345 set (TAGFILEDIR "${OUTDIR}/refman")
346 set (HTMLDIR "${OUTDIR}/overview/html")
347 set (LATEXDIR "${OUTDIR}/overview/latex")
348 set (DOXYFILE "${OUTDIR}/OCCT.cfg")
350 # Create or cleanup the output folders
351 if (NOT "${generateProductsRefman}" STREQUAL "YES")
352 foreach(dir ${OUTDIR} ${HTMLDIR} ${PDFDIR} ${UGDIR} ${DGDIR})
353 if (NOT EXISTS "${dir}")
354 file(MAKE_DIRECTORY "${dir}")
357 if (EXISTS "${LATEXDIR}")
358 file(REMOVE_RECURSE "${LATEXDIR}")
360 file(MAKE_DIRECTORY "${LATEXDIR}")
362 if ("${docType}" STREQUAL "REFMAN")
363 if (NOT EXISTS "${TAGFILEDIR}")
364 file(MAKE_DIRECTORY "${TAGFILEDIR}")
369 set (mathjax_relative_location "${mathjaxLocation}")
370 if (IS_DIRECTORY "${mathjaxLocation}")
371 if ( "${generatorMode}" STREQUAL "HTML_ONLY")
373 file(RELATIVE_PATH mathjax_relative_location ${HTMLDIR} ${mathjaxLocation})
374 elseif ("${generatorMode}" STREQUAL "CHM_ONLY")
376 set (mathjax_relative_location ${mathjaxLocation})
380 if ( "${generateProductsRefman}" STREQUAL "YES")
381 set (DOCDIR "${OUTDIR}/refman")
382 puts ("Generating OCC Products Reference Manual")
384 if ( "${docType}" STREQUAL "REFMAN")
385 set (DOCDIR "${OUTDIR}/refman")
386 puts ("Generating Open CASCADE Reference Manual")
387 elseif ("${docType}" STREQUAL "OVERVIEW")
388 set (DOCDIR "${OUTDIR}/overview")
390 if ( "${generatorMode}" STREQUAL "HTML_ONLY" OR "${generatorMode}" STREQUAL "CHM_ONLY")
391 if ( "${generatorMode}" STREQUAL "HTML_ONLY")
392 set (FORMAT " in HTML format...")
393 elseif ( "${generatorMode}" STREQUAL "CHM_ONLY")
394 set (FORMAT " in CHM format...")
396 puts ("Generating OCCT User Guides${FORMAT}")
399 error("Error: Invalid documentation type: ${docType}. Can not process.")
404 string(TIMESTAMP time "%Y-%m-%d %H:%M")
405 puts ("${time} Generating Doxyfile...")
407 OCCDoc_MakeDoxyfile(${docType} ${DOCDIR} ${TAGFILEDIR} ${DOXYFILE} ${generatorMode} docfiles modules ${verboseMode} ${searchMode} ${mathjax_relative_location})
410 string(TIMESTAMP starttimestamp "%Y-%m-%d %H:%M")
411 if ("${generatorMode}" STREQUAL "HTML_ONLY" OR "${docType}" STREQUAL "REFMAN")
412 puts("${starttimestamp} Generating HTML files...")
413 # Copy index file to provide fast access to HTML documentation
414 file(COPY "${INDIR}/resources/index.html" DESTINATION "${DOCDIR}")
415 elseif ("${generatorMode}" STREQUAL "CHM_ONLY")
416 puts ("${starttimestamp} Generating CHM file...")
417 elseif ("${generatorMode}" STREQUAL "PDF_ONLY")
418 puts ("${starttimestamp} Generating PDF file...")
420 execute_process(COMMAND ${DOC_DOXYGEN_PATH} ${DOXYFILE}
421 OUTPUT_FILE ${OUTDIR}/doxygen_out.log
422 ERROR_FILE ${OUTDIR}/doxygen_warnings_and_errors.log
424 # Start Post Processing
425 string(TIMESTAMP curtime "%Y-%m-%d %H:%M")
426 if( "${docType}" STREQUAL "REFMAN")
427 # Post Process generated HTML pages and draw dependency graphs
428 OCCDoc_PostProcessor(${DOCDIR})
430 puts ("${curtime} Generation completed.")
431 puts ("Info: doxygen log file is located in:")
432 puts ("\t${OUTDIR}/doxygen_out.log.")
433 puts ("Reference Manual is generated in \n\t${DOCDIR}")
435 elseif ("${docType}" STREQUAL "OVERVIEW")
436 # Start PDF generation routine
437 if ("${generatorMode}" STREQUAL "PDF_ONLY")
438 # Prepare a list of TeX files, generated by Doxygen
439 file(GLOB TEXFILES RELATIVE "${LATEXDIR}" "${LATEXDIR}/*.tex")
440 list(REMOVE_ITEM TEXFILES "refman.tex")
441 if ("${verboseMode}" STREQUAL "YES")
442 puts ("Info: Preprocessing generated TeX files...")
445 OCCDoc_ProcessTex(TEXFILES ${LATEXDIR} ${verboseMode})
447 if ("${verboseMode}" STREQUAL "YES")
448 puts ("Info: Converting SVG images to PNG format...")
451 if (NOT "${DOC_INKSCAPE_PATH}" STREQUAL "DOC_INKSCAPE_PATH-NOTFOUND")
452 OCCDoc_ProcessSvg(${LATEXDIR} ${verboseMode})
455 if ("${verboseMode}" STREQUAL "YES")
456 puts ("Info: Generating PDF file from TeX files...")
458 foreach (TEX ${TEXFILES})
459 # Rewrite existing REFMAN.tex file...
460 get_filename_component(TEX ${TEX} NAME_WE)
461 if ("${verboseMode}" STREQUAL "YES")
462 puts ("Info: Generating PDF file from ${TEX}...")
465 OCCDoc_MakeRefmanTex(${TEX} ${LATEXDIR} ${verboseMode} available_pdf)
467 if ("${verboseMode}" STREQUAL "YES")
468 # ...and use it to generate PDF from TeX...
470 puts ("Info: Executing ${LATEXDIR}/make.bat...")
472 puts ("Info: Executing ${LATEXDIR}/Makefile...")
475 set (PDFLOG "${OUTDIR}/pdflatex_warnings_and_errors.log")
479 execute_process(COMMAND ${LATEXDIR}/make.bat
480 OUTPUT_FILE ${OUTDIR}/pdflatex_out.log
481 WORKING_DIRECTORY ${LATEXDIR}
482 ERROR_FILE ${OUTDIR}/pdflatex_warnings_and_errors.log
485 execute_process(COMMAND make -f ${LATEXDIR}/Makefile
486 OUTPUT_FILE ${OUTDIR}/pdflatex_out.log
487 WORKING_DIRECTORY ${LATEXDIR}
488 ERROR_FILE ${OUTDIR}/pdflatex_warnings_and_errors.log
490 # Small workaround for *nix stations
491 execute_process(COMMAND ${DOC_PDFLATEX_PATH} ${LATEXDIR}/refman.tex
492 WORKING_DIRECTORY ${LATEXDIR}
493 OUTPUT_FILE ${OUTDIR}/pdflatex_out.log
494 ERROR_FILE ${OUTDIR}/pdflatex_warnings_and_errors.log
498 if (NOT EXISTS "${LATEXDIR}/refman.pdf")
499 error("Fatal: PDFLaTeX failed to create output file, stopping!\n\tCheck \"${OUTDIR}/pdflatex_warnings_and_errors.log\" log file")
502 set (destFolder "${PDFDIR}")
503 string(REGEX MATCHALL "([a-zA-Z]+)" parsed_string ${TEX})
504 list(FIND parsed_string "tutorial" isTUTORIAL)
505 list(FIND parsed_string "user" isUSER)
506 list(FIND parsed_string "dev" isDEV)
508 if (NOT ${isTUTORIAL} EQUAL -1)
509 string(REPLACE "occt__" "occt_" TEX ${TEX})
510 set (destFolder ${PDFDIR})
511 elseif (NOT ${isUSER} EQUAL -1)
512 string(REPLACE "user_guides__" "" TEX ${TEX})
513 set (destFolder ${UGDIR})
514 elseif (NOT ${isDEV} EQUAL -1)
515 string(REPLACE "dev_guides__" "" TEX ${TEX})
516 set (destFolder ${DGDIR})
518 file (RENAME "${LATEXDIR}/refman.pdf" "${destFolder}/${TEX}.pdf")
520 elseif ( "${generatorMode}" STREQUAL "CHM_ONLY" )
521 file (RENAME "${OUTDIR}/overview.chm" "${OUTDIR}/occt_overview.chm")
523 if ( "${generatorMode}" STREQUAL "HTML_ONLY" )
524 puts ("HTML documentation is generated in \n\t${DOCDIR}")
526 if ( "${generatorMode}" STREQUAL "CHM_ONLY" )
527 puts ("Generated CHM documentation is in \n\t${OUTDIR}/overview.chm")
533 file(GLOB_RECURSE deleteList "${OUTDIR}/*.tmp")
534 foreach(file ${deleteList})
535 file (REMOVE ${file})
539 # Generates Doxygen configuration file for Overview documentation
540 function (OCCDoc_MakeDoxyfile docType outDir tagFileDir doxyFileName generatorMode DocFilesList ModulesList verboseMode searchMode mathjaxLocation)
541 set(DocFilesList ${${DocFilesList}})
542 set(ModulesList ${${ModulesList}})
543 OCCDoc_GetDoxDir(inputDir)
544 set (TEMPLATES_DIR ${inputDir}/resources)
545 OCCDoc_DetectCasVersion(occt_version)
546 # Delete existent doxyfile
547 file (REMOVE "${doxyFileName}")
549 # Copy specific template to the target folder
550 if ( "${docType}" STREQUAL "REFMAN")
551 configure_file("${TEMPLATES_DIR}/occt_rm.doxyfile" "${doxyFileName}" COPYONLY)
552 elseif ("${docType}" STREQUAL "OVERVIEW")
553 if ("${generatorMode}" STREQUAL "HTML_ONLY" OR "${generatorMode}" STREQUAL "CHM_ONLY")
554 configure_file("${TEMPLATES_DIR}/occt_ug_html.doxyfile" "${doxyFileName}" COPYONLY)
555 elseif ("${generatorMode}" STREQUAL "PDF_ONLY")
556 configure_file("${TEMPLATES_DIR}/occt_ug_pdf.doxyfile" "${doxyFileName}" COPYONLY)
558 error("Error: Unknown generation mode")
561 error("Error: Cannot generate unknown document type")
564 # Write specific options
565 if ("${docType}" STREQUAL "REFMAN")
566 GET_OCCT_MODULES(modules)
567 if (NOT "${ModulesList}" STREQUAL "")
568 # Detect invalid names of modules
569 foreach (module ${ModulesList})
570 list(FIND modules "${module}" isFound)
571 if (${isFound} EQUAL -1)
572 error("Error: No module ${module} is known. Aborting...")
575 set (modules "${ModulesList}")
579 list(LENGTH modules length)
580 if (${length} EQUAL 1)
581 set (title "OCCT ${modules}")
582 set (name "${modules}")
584 set (title "Open CASCADE Technology")
588 # Get list of header files in the specified modules
590 foreach (module ${modules})
591 foreach (tk ${${module}_TOOLKITS})
592 OCCDoc_GetPackagesList(${tk} ${tk}_PACKAGES)
593 foreach (pk ${${tk}_PACKAGES})
594 OCCDoc_GetRootDir(theRoot)
595 file(GLOB INC_FILES "${theRoot}/src/${pk}/*.[hg]*")
597 foreach (INC_FILE ${INC_FILES})
598 string(FIND "${INC_FILE}" "/Handle_" isFound)
599 if(${isFound} EQUAL -1)
600 list(APPEND TEMP_INC_FILES "${INC_FILE}")
603 list(APPEND filelist "${TEMP_INC_FILES}")
608 puts (${doxyFileName} "PROJECT_NAME = \"${title}\"")
609 puts (${doxyFileName} "PROJECT_NUMBER = ${occt_version}")
610 puts (${doxyFileName} "OUTPUT_DIRECTORY = ${outDir}/.")
611 puts (${doxyFileName} "GENERATE_TAGFILE = ${outDir}/${name}.tag")
613 if ("${searchMode}" STREQUAL "none")
614 puts (${doxyFileName} "SEARCHENGINE = NO")
615 puts (${doxyFileName} "SERVER_BASED_SEARCH = NO")
616 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
618 puts (${doxyFileName} "SEARCHENGINE = YES")
619 if ("${searchMode}" STREQUAL "local")
620 puts (${doxyFileName} "SERVER_BASED_SEARCH = NO")
621 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
622 elseif ("${searchMode}" STREQUAL "server")
623 puts (${doxyFileName} "SERVER_BASED_SEARCH = YES")
624 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
625 elseif ("${searchMode}" STREQUAL "external")
626 puts (${doxyFileName} "SERVER_BASED_SEARCH = YES")
627 puts (${doxyFileName} "EXTERNAL_SEARCH = YES")
629 error("Error: Wrong search engine type: ${searchMode}.")
632 if(EXISTS "${DOC_GRAPHVIZ_PATH}")
633 set(DOT_PATH "${DOC_GRAPHVIZ_PATH}")
635 puts (${doxyFileName} "DOTFILE_DIRS = ${outDir}/html")
636 puts (${doxyFileName} "DOT_PATH = ${DOT_PATH}")
637 puts (${doxyFileName} "INCLUDE_PATH = ${INSTALL_DIR}/inc")
638 # list of files to generate
639 OCCDoc_MakeMainPage(${outDir} "${outDir}/${name}.dox" modules)
640 set (mainpage "${outDir}/${name}.dox")
641 puts (${doxyFileName} "")
642 puts (${doxyFileName} "INPUT = ${mainpage} \\")
643 foreach (header ${filelist})
644 puts (${doxyFileName} " ${header} \\")
647 puts (${doxyFileName} "MATHJAX_FORMAT = HTML-CSS")
648 puts (${doxyFileName} "MATHJAX_RELPATH = ${mathjaxLocation}")
650 puts (${doxyFileName} "")
652 elseif ( "${docType}" STREQUAL "OVERVIEW")
653 # Add common options for generation of Overview and User Guides
654 puts (${doxyFileName} "PROJECT_NUMBER = ${occt_version}")
655 puts (${doxyFileName} "OUTPUT_DIRECTORY = ${outDir}/.")
656 puts (${doxyFileName} "PROJECT_LOGO = ${inputDir}/resources/occ_logo.png")
658 set (PARAM_INPUT "INPUT =")
659 set (PARAM_IMAGEPATH "IMAGE_PATH = ${inputDir}/resources/ ")
660 foreach (docFile ${DocFilesList})
661 set (NEW_IMG_PATH "${inputDir}/${docFile}")
662 OCCDoc_GetRootDir(theRoot)
663 if (NOT "${NEW_IMG_PATH}" STREQUAL "${theRoot}")
664 get_filename_component(img_string ${NEW_IMG_PATH} DIRECTORY)
665 set (img_string "${img_string}/images")
666 if (EXISTS ${img_string})
667 set(PARAM_IMAGEPATH "${PARAM_IMAGEPATH} ${img_string}")
670 set(PARAM_INPUT "${PARAM_INPUT} ${inputDir}/${docFile}")
672 puts (${doxyFileName} ${PARAM_INPUT})
673 puts (${doxyFileName} ${PARAM_IMAGEPATH})
675 # Add document type-specific options
676 if ( "${generatorMode}" STREQUAL "HTML_ONLY")
678 puts (${doxyFileName} "GENERATE_TREEVIEW = YES")
680 # Set a reference to a TAGFILE
681 if (NOT "${tagFileDir}" STREQUAL "")
682 if (EXISTS "${tagFileDir}/OCCT.tag")
683 set (tagPath ${tagFileDir})
684 puts (${doxyFileName} "TAGFILES = ${tagFileDir}/OCCT.tag=../../refman/html")
687 # HTML Search engine options
688 string(TOLOWER "${searchMode}" searchMode)
689 if ("${searchMode}" STREQUAL "none")
690 puts (${doxyFileName} "SEARCHENGINE = NO")
691 puts (${doxyFileName} "SERVER_BASED_SEARCH = NO")
692 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
694 puts (${doxyFileName} "SEARCHENGINE = YES")
695 if ("${searchMode}" STREQUAL "local")
696 puts (${doxyFileName} "SERVER_BASED_SEARCH = NO")
697 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
698 elseif ("${searchMode}" STREQUAL "server")
699 puts (${doxyFileName} "SERVER_BASED_SEARCH = YES")
700 puts (${doxyFileName} "EXTERNAL_SEARCH = NO")
701 elseif ("${searchMode}" STREQUAL "external")
702 puts (${doxyFileName} "SERVER_BASED_SEARCH = YES")
703 puts (${doxyFileName} "EXTERNAL_SEARCH = YES")
705 error("Error: Wrong search engine type: ${searchMode}.")
708 elseif ( "${generatorMode}" STREQUAL "CHM_ONLY")
709 # specific options for CHM file generation
710 if(EXISTS "${DOC_HHC_PATH}")
711 set(HHC_LOCATION "${DOC_HHC_PATH}")
713 puts (${doxyFileName} "GENERATE_TREEVIEW = NO")
714 puts (${doxyFileName} "SEARCHENGINE = NO")
715 puts (${doxyFileName} "GENERATE_HTMLHELP = YES")
716 puts (${doxyFileName} "CHM_FILE = ../../overview.chm")
717 puts (${doxyFileName} "HHC_LOCATION = \"${HHC_LOCATION}\"")
718 puts (${doxyFileName} "DISABLE_INDEX = YES")
722 puts (${doxyFileName} "MATHJAX_RELPATH = ${mathjaxLocation}")
726 # Parses arguments line like "-arg1=val1 -arg2=val2 ..." to array args_names and map args_values
727 function (OCCDoc_ParseArguments)
733 separate_arguments(ARGV)
735 string(REGEX MATCHALL "^[a-zA-Z]+$" single_var "${ARGV}")
736 string(REGEX MATCHALL "^[a-zA-Z]+[=].*$" multi_var "${ARGV}")
738 separate_arguments(ARGV)
739 foreach (arg ${ARGV})
740 STRING(FIND "${arg}" "=" equalChar)
741 STRING(FIND "${arg}" "-" firstChar)
742 if(NOT "${firstChar}" EQUAL 0)
743 error("Error in argument \"${arg}\".")
745 if(NOT "${equalChar}" EQUAL -1)
746 math(EXPR valueChar "${equalChar} + 1")
747 math(EXPR nameChar "${equalChar} - 1")
748 string(SUBSTRING "${arg}" "${valueChar}" -1 aValue)
749 string(SUBSTRING "${arg}" 1 "${nameChar}" aName)
751 string(SUBSTRING "${arg}" 1 -1 aName)
754 list(APPEND args_names "${aName}")
755 list(APPEND args_values "${aValue}")
757 set (args_names ${args_names} PARENT_SCOPE)
758 set (args_values ${args_values} PARENT_SCOPE)
759 set (isOK 0 PARENT_SCOPE)
762 # Returns script parent folder
763 function (OCCDoc_GetDoxDir result)
764 if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}/dox")
765 set (filePATH ${BUILD_PATCH_DIR})
766 elseif (EXISTS "${CMAKE_SOURCE_DIR}/dox")
767 set (filePATH ${CMAKE_SOURCE_DIR})
769 set(${result} "${filePATH}/dox" PARENT_SCOPE)
772 # Returns OCCT root dir
773 function (OCCDoc_GetOCCTRootDir result)
774 OCCDoc_GetDoxDir(path)
775 get_filename_component(path "${path}" DIRECTORY)
776 set(${result} "${path}" PARENT_SCOPE)
780 function (OCCDoc_GetRootDir result)
781 OCCDoc_GetOCCTRootDir(path)
782 set(${result} "${path}" PARENT_SCOPE)
785 # Returns OCCT source dir
786 function (OCCDoc_GetSourceDir result)
787 OCCDoc_GetRootDir(theRoot)
788 set(${result} "${theRoot}/src" PARENT_SCOPE)
791 # Returns OCCT version string from file Standard_Version.hxx (if available)
792 function (OCCDoc_DetectCasVersion theVersion)
794 set (occt_ver_add "")
795 OCCDoc_GetSourceDir(filename)
796 set(filename "${filename}/Standard/Standard_Version.hxx")
797 if(EXISTS "${filename}")
798 foreach (var OCC_VERSION_COMPLETE OCC_VERSION_DEVELOPMENT)
799 file (STRINGS "${filename}" ${var} REGEX "^#define ${var} .*")
800 STRING(REGEX REPLACE ".*${var} .*\"([^ ]+)\".*" "\\1" ${var} "${${var}}" )
802 if(NOT "${OCC_VERSION_DEVELOPMENT}" STREQUAL "")
803 set(${theVersion} "${OCC_VERSION_COMPLETE}.${OCC_VERSION_DEVELOPMENT}" PARENT_SCOPE)
805 set(${theVersion} "${OCC_VERSION_COMPLETE}" PARENT_SCOPE)
810 # Convert SVG files to PDF format to allow including them to PDF
811 # (requires InkScape to be in PATH)
812 function (OCCDoc_ProcessSvg latexDir verboseMode)
813 file(GLOB aFILES "${latexDir}/*.svg")
814 foreach (file ${aFILES})
815 if ("${verboseMode}" STREQUAL "YES")
816 puts ("Info: Converting file ${file}...")
818 get_filename_component(aDir ${file} DIRECTORY )
819 get_filename_component(aName ${file} NAME_WE )
820 set (pdffile "${aDir}/${aName}.pdf")
821 execute_process(COMMAND ${DOC_INKSCAPE_PATH} -z -D --file=${file} --export-pdf=${pdffile}
822 WORKING_DIRECTORY ${LATEXDIR}
823 OUTPUT_FILE ${OUTDIR}/inkscape_out.log
824 ERROR_FILE ${OUTDIR}/inkscape_warnings_and_errors.log
829 # ==============================================
830 # Reference Manual-specific functions
831 # ==============================================
833 # Finds dependencies between all modules
834 function (OCCDoc_CreateModulesDependencyGraph dir filename modules mpageprefix)
835 set(modules ${${modules}})
837 set (file "${dir}/${filename}.dot")
839 puts (${file} "digraph ${filename}")
841 foreach (mod ${modules})
842 if ( NOT "${mod}" STREQUAL "")
843 string(TOLOWER "${mpageprefix}${mod}.html" aLowerString)
844 puts (${file} "\t${mod} [ URL = \"${aLowerString}\" ]")
845 foreach (mod_depend ${${mod}_DEPS})
846 puts (${file} "\t${mod_depend} -> ${mod} [ dir = \"back\", color = \"midnightblue\", style = \"solid\" ]")
853 # Finds dependencies between all toolkits in module
854 function(OCCDoc_CreateModuleToolkitsDependencyGraph dir filename modulename tpageprefix)
857 #toolkit_parent_module
858 set (file "${dir}/${filename}.dot")
860 puts (${file} "digraph ${filename}")
862 foreach (tk ${${modulename}_TOOLKITS})
863 string(TOLOWER "${tpageprefix}${tk}.html" LowerString)
864 OCC_GetUnitType("${tk}" theType)
865 if("${theType}" STREQUAL "t")
866 puts (${file} "\t${tk} [ URL = \"${LowerString}\"]")
867 foreach (tkd ${${tk}_DEPS})
868 IS_OCCT_TOOLKIT(${tkd})
869 OCC_GetUnitType("${tkd}" theType)
870 if("${theType}" STREQUAL "t")
871 if(NOT ${isFOUND} EQUAL -1)
872 if("${isFOUND}" STREQUAL "${modulename}")
873 puts (${file} "\t${tkd} -> ${tk} [ dir = \"back\", color = \"midnightblue\", style = \"solid\" ]")
883 # Finds dependencies between the current toolkit and other toolkits
884 function(OCCDoc_CreateToolkitDependencyGraph dir filename toolkitname tpageprefix)
886 set (file "${dir}/${filename}.dot")
888 puts(${file} "digraph ${filename}")
890 string(TOLOWER "${tpageprefix}${toolkitname}.html" LowerString)
891 puts(${file} "\t${toolkitname} [ URL = \"${LowerString}\", shape = box ]")
892 foreach (tkd ${${toolkitname}_DEPS})
893 string(TOLOWER "${tpageprefix}${tkd}.html" LowerString)
894 puts(${file} "\t${tkd} [ URL = \"${LowerString}\"\ , shape = box ]")
895 puts(${file} "\t${toolkitname} -> ${tkd} [ color = \"midnightblue\", style = \"solid\" ]")
897 list(LENGTH ${toolkitname}_DEPS length)
898 if (${length} GREATER 1)
899 puts(${file} "\taspect = 1")
904 # Fills arrays of modules, toolkits, dependency of modules/toolkits etc
905 function (OCCDoc_LoadData)
908 #toolkit_parent_module
910 GET_OCCT_MODULES(modules)
911 set(MODULES ${modules} PARENT_SCOPE)
912 foreach (mod ${modules})
913 set(${mod}_TOOLKITS "${${mod}_TOOLKITS}" PARENT_SCOPE)
914 foreach (tk ${${mod}_TOOLKITS})
915 OCCT_TOOLKIT_DEP(${tk})
916 foreach (dtk ${${tk}_DEPS})
917 IS_OCCT_TOOLKIT(${dtk})
918 if(${isFOUND} EQUAL -1)
919 list(REMOVE_ITEM ${tk}_DEPS ${dtk})
922 set(${tk}_DEPS ${${tk}_DEPS} PARENT_SCOPE)
926 # Get modules dependency
927 foreach (mod ${modules})
929 foreach (tk ${${mod}_TOOLKITS})
930 foreach(dtk ${${tk}_DEPS})
931 IS_OCCT_TOOLKIT(${dtk})
932 if(NOT ${isFOUND} EQUAL -1)
933 if(NOT "${mod}" STREQUAL "${isFOUND}")
934 list(APPEND ${mod}_DEPS "${isFOUND}")
939 list(LENGTH ${mod}_DEPS length)
940 if(NOT ${length} EQUAL 0)
941 list(REMOVE_DUPLICATES ${mod}_DEPS)
943 set(${mod}_DEPS ${${mod}_DEPS} PARENT_SCOPE)
947 # Returns list of packages of the given toolkit
948 function (OCCDoc_GetExternLibList theToolkit theExternLibs)
949 OCCDoc_GetRootDir(theRoot)
950 # Open file with list of packages of the given toolkit
951 file(READ "${theRoot}/src/${theToolkit}/EXTERNLIB" CONTENT)
952 set(${theExternLibs} ${CONTENT} PARENT_SCOPE)
955 # Returns list of packages of the given toolkit
956 function (OCC_GetUnitType theName theResult)
957 OCCDoc_GetRootDir(theRoot)
958 # Open file with list of packages of the given toolkit
960 if(EXISTS "${theRoot}/adm/UDLIST")
961 file(STRINGS "${theRoot}/adm/UDLIST" CONTENT REGEX ". ${theName}")
963 string(SUBSTRING "${CONTENT}" 0 1 aType)
964 set(${theResult} "${aType}" PARENT_SCOPE)
967 # Returns list of packages of the given toolkit
968 function (OCCDoc_GetPackagesList theToolkit thePackages)
969 OCCDoc_GetRootDir(theRoot)
970 # Open file with list of packages of the given toolkit
972 if(EXISTS "${theRoot}/src/${theToolkit}/PACKAGES")
973 file(STRINGS "${theRoot}/src/${theToolkit}/PACKAGES" CONTENT)
975 set(${thePackages} "${CONTENT}" PARENT_SCOPE)
978 # Function to get toolkits dependencies from file src/TOOLKIT_NAME/EXTERNLIB.
979 # Creates <TOOLKIT_NAME>_DEPS variable to store them.
980 function (OCCT_TOOLKIT_DEP TOOLKIT_NAME)
981 if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}/src/${TOOLKIT_NAME}/EXTERNLIB")
982 set (MODULE_PATH_PREFIX ${BUILD_PATCH_DIR})
983 elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${TOOLKIT_NAME}/EXTERNLIB")
984 set (MODULE_PATH_PREFIX ${CMAKE_SOURCE_DIR})
988 file (STRINGS "${MODULE_PATH_PREFIX}/src/${TOOLKIT_NAME}/EXTERNLIB" CONTENT)
989 set (${TOOLKIT_NAME}_DEPS ${CONTENT} PARENT_SCOPE)
992 # Function to determine if TOOLKIT is OCC toolkit
993 # Creates "isFOUND" variable to store result
994 function (IS_OCCT_TOOLKIT TOOLKIT_NAME)
995 set (isFOUND -1 PARENT_SCOPE)
996 GET_OCCT_MODULES(MODULES)
997 foreach(MODULE ${MODULES})
998 set(TOOLKITS ${${MODULE}_TOOLKITS})
999 list(FIND TOOLKITS ${TOOLKIT_NAME} isOK)
1000 if (NOT ${isOK} EQUAL -1)
1001 set (isFOUND "${MODULE}" PARENT_SCOPE)
1007 # Function to get list of modules and toolkits from file adm/MODULES.
1008 # Creates list <${MODULES_LIST}> to store list of MODULES and
1009 # <NAME_OF_MODULE>_TOOLKITS foreach module to store its toolkits.
1010 function (GET_OCCT_MODULES MODULES_LIST)
1011 set (MODULE_PATH_POSTFIX "/adm/MODULES")
1012 if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}${MODULE_PATH_POSTFIX}")
1013 set (MODULE_PATH_PREFIX "${BUILD_PATCH_DIR}")
1014 elseif (EXISTS "${CMAKE_SOURCE_DIR}${MODULE_PATH_POSTFIX}")
1015 set (MODULE_PATH_PREFIX "${CMAKE_SOURCE_DIR}")
1020 file (STRINGS "${MODULE_PATH_PREFIX}${MODULE_PATH_POSTFIX}" CONTENT)
1022 set (${MODULES_LIST})
1023 foreach (CONTENT_LINE ${CONTENT})
1024 string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE})
1025 list (GET CONTENT_LINE 0 NAME_OF_MODULE)
1026 list (REMOVE_AT CONTENT_LINE 0)
1027 list (APPEND ${MODULES_LIST} ${NAME_OF_MODULE})
1028 set (${NAME_OF_MODULE}_TOOLKITS "${CONTENT_LINE}" PARENT_SCOPE)
1031 set (${MODULES_LIST} ${${MODULES_LIST}} PARENT_SCOPE)
1034 # Gets contents of the given html node (for Post-processing)
1035 function(OCCDoc_GetNodeContents node props html theResult)
1036 set (openTag "<${node}${props}>")
1037 set (closingTag "</${node}>")
1038 string(FIND "${html}" "${openTag}" start)
1039 if (${start} EQUAL -1)
1040 set(theResult "" PARENT_SCOPE)
1043 string(LENGTH "${openTag}" length)
1044 math(EXPR start "${start} + ${length}")
1045 string(SUBSTRING "${html}" ${start} -1 html)
1046 string(FIND "${html}" "${closingTag}" start)
1047 if (${start} EQUAL -1)
1048 set(theResult "" PARENT_SCOPE)
1051 math(EXPR start "${start} - 1")
1052 string(SUBSTRING "${html}" 0 ${start} theResult)
1053 set(theResult "" PARENT_SCOPE)
1056 # Generates main page file describing module structure
1057 function (OCCDoc_MakeMainPage outDir outFile inModules)
1058 set(inModules "${${inModules}}")
1060 set (module_prefix "module_")
1061 set (toolkit_prefix "toolkit_")
1062 set (package_prefix "package_")
1064 if (NOT EXISTS "${outDir}/html")
1065 file(MAKE_DIRECTORY "${outDir}/html")
1069 # Main page: list of modules
1070 separate_arguments(inModules)
1071 list(LENGTH inModules length)
1072 if (NOT ${length} EQUAL 1)
1073 puts (${outFile} "/**")
1074 puts (${outFile} "\\mainpage Open CASCADE Technology")
1075 foreach (mod ${inModules})
1076 string(TOLOWER "${module_prefix}${mod}" LowerString)
1077 puts (${outFile} "\\li \\subpage ${LowerString}")
1079 OCCDoc_CreateModulesDependencyGraph("${outDir}/html" "schema_all_modules" inModules ${module_prefix})
1080 # insert modules relationship diagramm
1081 puts (${outFile} "\\dotfile schema_all_modules")
1082 puts (${outFile} "**/")
1085 # One page per module: list of toolkits
1087 foreach (mod ${inModules})
1088 puts (${outFile} "/**")
1089 if (${length} EQUAL 1)
1090 puts (${outFile} "\\mainpage OCCT Module ${mod}")
1092 string(TOLOWER "module_${mod}" LowerString)
1093 puts (${outFile} "\\page ${LowerString} Module ${mod}")
1095 list(SORT ${mod}_TOOLKITS)
1096 foreach (tk ${${mod}_TOOLKITS})
1097 OCC_GetUnitType("${tk}" theType)
1098 if("${theType}" STREQUAL "t")
1099 list(APPEND toolkits ${tk})
1100 string(TOLOWER "${toolkit_prefix}${tk}" LowerString)
1101 puts (${outFile} "\\li \\subpage ${LowerString}")
1104 OCCDoc_CreateModuleToolkitsDependencyGraph("${outDir}/html" "schema_${mod}" ${mod} ${toolkit_prefix})
1105 puts (${outFile} "\\dotfile schema_${mod}")
1106 puts (${outFile} "**/")
1109 # One page per toolkit: list of packages
1111 foreach (tk ${toolkits})
1112 puts (${outFile} "/**")
1113 string(TOLOWER "toolkit_${tk}" LowerString)
1114 puts (${outFile} "\\page ${LowerString} Toolkit ${tk}")
1115 OCCDoc_GetPackagesList(${tk} ${tk}_PACKAGES)
1116 list(SORT ${tk}_PACKAGES)
1117 foreach (pk ${${tk}_PACKAGES})
1118 list(APPEND packages ${pk})
1119 string(TOLOWER "${package_prefix}${pk}" LowerString)
1120 puts (${outFile} "\\li \\subpage ${LowerString}")
1122 OCCDoc_CreateToolkitDependencyGraph("${outDir}/html" "schema_${tk}" "${tk}" "${toolkit_prefix}")
1123 puts (${outFile} "\\dotfile schema_${tk}")
1124 puts (${outFile} "**/")
1127 # One page per package: list of classes
1128 foreach (pk ${packages})
1129 puts (${outFile} "/**")
1130 string(TOLOWER "${package_prefix}${pk}" LowerString)
1131 puts (${outFile} "\\page ${LowerString} Package ${pk}")
1132 file(GLOB INC_FILES RELATIVE "${theRoot}/src/${pk}" "${theRoot}/src/${pk}/*.hxx")
1133 foreach (hdr ${INC_FILES})
1134 string(FIND "${hdr}" "Handle_" isHandle)
1135 if(NOT ${isHandle} EQUAL 0)
1136 string(LENGTH "${hdr}" length)
1137 math(EXPR length "${length} - 4")
1138 string(SUBSTRING "${hdr}" 0 ${length} aName)
1139 puts (${outFile} "\\li \\subpage ${aName}")
1142 puts (${outFile} "**/")
1146 # Parses generated files to add a navigation path
1147 function(OCCDoc_PostProcessor outDir)
1148 string(TIMESTAMP time "%Y-%m-%d %H:%M")
1149 puts("${time} Post-process is started ...")
1150 set(outDir "${outDir}/html")
1151 file(GLOB files "${outDir}/package_*")
1152 list(LENGTH files length)
1153 if (NOT ${length} EQUAL 0)
1156 file(READ ${f} packageFile)
1157 OCCDoc_GetNodeContents("div" " id=\"nav-path\" class=\"navpath\"" "${packageFile}" navPath)
1158 OCCDoc_GetNodeContents("div" " class=\"title\"" "${packageFile}" packageName)
1159 get_filename_component(packageFileName "${f}" NAME)
1160 # add package link to nav path
1161 string(REPLACE "</ul>" "" navPath "${navPath}")
1162 set (navPath "${navPath} <li class=\"navelem\"><a class=\"el\" href=\"${packageFileName}\">${packageName}</a> </li>\n </ul>")
1163 # get list of files to update
1164 OCCDoc_GetNodeContents("div" " class=\"textblock\"" "${packageFile}" listContents)
1165 OCCDoc_GetNodeContents("ul" "" "${listContents}" listContents)
1166 foreach(line ${listContents})
1167 STRING(REGEX REPLACE ".*href=\"([^\"]+)\".*" "\\1" classFileName "${test}" )
1168 if (NOT "${classFileName}" STREQUAL "${line}")
1169 # check if anchor is there
1170 string(FIND "${classFileName}" "#" anchorPos)
1171 if (NOT ${anchorPos} EQUAL -1)
1172 math(EXPR anchorPos "${anchorPos} - 1")
1173 string(SUBSTRING "${classFileName}" 0 ${anchorPos} classFileName)
1177 set (classFilePnt "${outDir}/${classFileName}")
1178 file(READ ${classFilePnt} classFile)
1180 # find position of content block
1181 string(FIND "${classFile}" "<div class=\"header\">" contentPos)
1182 math(EXPR contentPos "${contentPos} - 1")
1183 string(SUBSTRING "${classFile}" 0 ${contentPos} navPart)
1185 # position where to insert nav path
1186 string(FIND "${navPart}" "</div>" posToInsert REVERSE)
1187 math(EXPR posToInsert "${posToInsert} - 1")
1188 string(SUBSTRING "${classFile}" 0 ${posToInsert} prePart)
1189 string(SUBSTRING "${classFile}" ${posToInsert} -1 postPart)
1190 list(APPEND newClassFile "${prePart}" " <div id=\"nav-path\" class=\"navpath\">" "${navPath}" "\n" " </div>" "\n" "${postPart}")
1192 # write updated content
1193 file(WRITE ${classFilePnt} "${newClassFile}")
1194 file(APPEND ${classFilePnt} "${classFile}")
1199 puts ("no files found")
1203 # ======================================
1204 # User Guides-specific functions
1205 # ======================================
1207 # Loads a list of docfiles from file FILES.txt
1208 function(OCCDoc_LoadFilesList)
1209 OCCDoc_GetDoxDir(INPUTDIR)
1212 set (available_docfiles "")
1213 # Read data from file
1214 if ( EXISTS "${INPUTDIR}/FILES_HTML.txt" )
1215 file (STRINGS "${INPUTDIR}/FILES_HTML.txt" available_docfiles REGEX "^[^#]+")
1217 error("File FILES_HTML.txt was not found on this computer.\nAborting...")
1219 set(available_docfiles "${available_docfiles}" PARENT_SCOPE)
1222 set(available_pdf "")
1223 # Read data from file
1224 if ( EXISTS "${INPUTDIR}/FILES_PDF.txt" )
1225 file (STRINGS "${INPUTDIR}/FILES_PDF.txt" available_pdf REGEX "^[^#]+")
1227 error("File FILES_PDF.txt was not found on this computer.\nAborting...")
1229 set(available_pdf "${available_pdf}" PARENT_SCOPE)
1232 # Writes new TeX file for conversion from tex to pdf for a specific doc
1233 function(OCCDoc_MakeRefmanTex fileName latexDir verboseMode latexFilesList)
1234 set(latexFilesList ${${latexFilesList}})
1235 if ( "${verboseMode}" STREQUAL "YES")
1236 puts ("Info: Making refman.tex file for ${fileName}...")
1238 set (DOCNAME "${latexDir}/refman.tex")
1239 if (EXISTS ${DOCNAME})
1240 file(REMOVE ${DOCNAME})
1243 # Copy template file to latex folder
1244 OCCDoc_GetDoxDir(temp_path)
1246 configure_file("${temp_path}/resources/occt_pdf_template.tex" "${DOCNAME}" COPYONLY)
1248 # Get templatized data
1249 file(READ ${DOCNAME} texfile_loaded)
1251 # Replace dummy values
1252 OCCDoc_DetectCasVersion(casVersion)
1254 # Get name of the document
1256 foreach (aFileName ${latexFilesList})
1257 # Find the file in FILES_PDF.txt
1258 string(REPLACE "/" ";" parsedFileName "${aFileName}")
1259 separate_arguments(parsedFileName)
1260 string(FIND "${fileName}" "__" aFirst)
1261 math(EXPR aFirst "${aFirst} + 2")
1262 string(SUBSTRING "${fileName}" ${aFirst} -1 newfileName)
1263 list(FIND parsedFileName "${newfileName}.md" isFOUND)
1264 if (NOT ${isFOUND} EQUAL -1)
1265 OCCDoc_GetDoxDir(temp_path)
1266 set (filepath "${temp_path}/${aFileName}")
1267 if (EXISTS ${filepath})
1268 file(STRINGS "${filepath}" MDFile LIMIT_COUNT 1)
1269 string(REPLACE "{" ";" MDFile "${MDFile}")
1270 separate_arguments(MDFile)
1271 list(GET MDFile 0 label)
1272 set (docLabel "${label}")
1277 string(TIMESTAMP curYear "%Y")
1278 string(REPLACE "DEFDOCLABEL" "${docLabel}" texfile_loaded "${texfile_loaded}")
1279 string(REPLACE "DEFCASVERSION" "${casVersion}" texfile_loaded "${texfile_loaded}")
1280 string(REPLACE "DEFFILENAME" "${fileName}" texfile_loaded "${texfile_loaded}")
1281 string(REPLACE "DEFYEAR" "${curYear}" texfile_loaded "${texfile_loaded}")
1283 file(WRITE ${DOCNAME} "${texfile_loaded}")
1286 # Postprocesses generated TeX files
1287 function(OCCDoc_ProcessTex texFiles latexDir verboseMode)
1288 set(texFiles ${${texFiles}})
1289 foreach (TEX ${texFiles})
1290 if ("${verboseMode}" STREQUAL "YES")
1291 puts("Info: Preprocessing file ${TEX}...")
1294 if (NOT EXISTS ${latexDir}/${TEX})
1295 error("Error: file ${TEX} does not exist.")
1298 file(STRINGS "${latexDir}/${TEX}" IN_F)
1300 foreach(line ${IN_F})
1301 string(FIND "${line}" "\\includegraphics" includegraphicsPos)
1302 string(FIND "${line}" "\\subsection" subsectionPos)
1303 string(FIND "${line}" "\\subsubsection" subsubsectionPos)
1304 string(FIND "${line}" "\\paragraph" paragraphPos)
1306 if (NOT ${includegraphicsPos} EQUAL -1)
1307 # replace svg extension by pdf
1308 string(REPLACE ".svg" ".pdf" line "${line}")
1309 # Center images in TeX files
1310 set(line "\\begin{center}\n ${line}\n\\end{center}")
1311 elseif (NOT ${subsectionPos} EQUAL -1)
1312 # Replace \subsection with \section tag
1313 string(REPLACE "\\\\subsection" "\\\\section" line "${line}")
1314 elseif (NOT ${subsubsectionPos} EQUAL -1)
1315 # Replace \subsubsection with \subsection tag
1316 string(REPLACE "\\\\subsubsection" "\\\\subsection" line "${line}")
1317 elseif (NOT ${paragraphPos} EQUAL -1)
1318 # Replace \paragraph with \subsubsection tag
1319 string(REPLACE "\\\\paragraph" "\\\\subsubsection" line "${line}")
1321 list(APPEND TEMP_LIST "${line}")
1323 file(WRITE "${latexDir}/${TEX}" ${TEMP_LIST})