<commit_before>##
# StdAir documentation (HTML, PDF, RTF), to be generated by Doxygen
#

# Define the substitutes for the variables present in the Doxygen
# configuration file. Note that PACKAGE, PACKAGE_NAME and PACKAGE_VERSION
# are defined in the main CMakeLists.txt (of the top root directory).
set (OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set (top_srcdir       ${CMAKE_SOURCE_DIR})
set (srcdir           ${CMAKE_CURRENT_SOURCE_DIR})

# Convert the Doxygen configuration files (basically, just replace
# the @<variable>@ variables).
set (DOXYGEN_CFG_SRC doxygen_html.cfg.in)
set (DOXYGEN_CFG ${CMAKE_CURRENT_BINARY_DIR}/doxygen_html.cfg)
configure_file (${DOXYGEN_CFG_SRC} ${DOXYGEN_CFG} @ONLY)

## Documentation sources
# (CSS) Style sheets
set (docstyles_DIR ${CMAKE_CURRENT_SOURCE_DIR}/styles)
set (style_SOURCES ${CPACK_PACKAGE_NAME}.css)
# Images
set (docimages_DIR ${CMAKE_CURRENT_SOURCE_DIR}/images)
set (image_SOURCES ${CPACK_PACKAGE_NAME}_logo.png sfx_logo.png favicon.ico)
# Tutorial
FILE (GLOB doctutorial_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/*.doc)
# Local
FILE (GLOB doclocaldoc_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/local/*.doc)
FILE (GLOB doclocalhtml_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/local/*.html)
set (doclocal_SOURCES ${doclocaldoc_SOURCES} ${doclocalhtml_SOURCES})
# Aggregating all the documentation sources
set (doc_SOURCES ${doctutorial_SOURCES} ${doclocal_SOURCES})

# Latex reference manual source (.tex file), generated by Doxygen
set (REFMAN refman)
set (TEX_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)
set (REFMAN_TEX ${REFMAN}.tex)
set (REFMAN_TEX_FULL ${TEX_GEN_DIR}/${REFMAN_TEX})

# Add the build rule for Doxygen
set (DOXYGEN_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
add_custom_command (OUTPUT ${DOXYGEN_OUTPUT} ${REFMAN_TEX_FULL}
  COMMAND ${DOXYGEN_EXECUTABLE} ARGS ${DOXYGEN_CFG}
  DEPENDS ${DOXYGEN_CFG} ${doc_SOURCES}
  COMMENT "Generating documentation with Doxygen, from '${DOXYGEN_CFG}'...")
# Add the 'doc' target, depending on the generated HTML documentation
add_custom_target (doc ALL DEPENDS ${DOXYGEN_OUTPUT})

##
# Copy the needed files into the generated HTML directory
set (htmldoc_DIR ${CMAKE_CURRENT_BINARY_DIR}/html)
set (pdfdoc_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)

# (CSS) Style sheets 
foreach (style_SRC ${style_SOURCES})
  set (CSS_SRC_FULL_DIR ${docstyles_DIR}/${style_SRC})
  set (CSS_GEN_FULL_DIR ${htmldoc_DIR}/${style_SRC})
  add_custom_command (OUTPUT ${CSS_GEN_FULL_DIR}
	COMMAND ${CMAKE_COMMAND} 
	ARGS -E copy ${CSS_SRC_FULL_DIR} ${CSS_GEN_FULL_DIR}
	DEPENDS ${DOXYGEN_OUTPUT} ${CSS_SRC_FULL_DIR}
	COMMENT "Copying style '${CSS_SRC_FULL_DIR}' into '${htmldoc_DIR}'...")
  add_custom_target (css_${style_SRC} ALL DEPENDS ${CSS_GEN_FULL_DIR})
endforeach (style_SRC)

# Images
foreach (image_SRC ${image_SOURCES})
  set (IMG_SRC_FULL_DIR ${docimages_DIR}/${image_SRC})
  set (IMG_GEN_FULL_DIR ${htmldoc_DIR}/${image_SRC})
  add_custom_command (OUTPUT ${IMG_GEN_FULL_DIR}
	COMMAND ${CMAKE_COMMAND} 
	ARGS -E copy ${IMG_SRC_FULL_DIR} ${IMG_GEN_FULL_DIR}
	DEPENDS ${DOXYGEN_OUTPUT} ${IMG_SRC_FULL_DIR}
	COMMENT "Copying image '${IMG_SRC_FULL_DIR}' into '${htmldoc_DIR}'...")
  add_custom_target (img_${image_SRC} ALL DEPENDS ${IMG_GEN_FULL_DIR})
endforeach (image_SRC)

##
# PDF, generated by (Pdf)Latex from the Latex source file, itself generated
# by Doxygen (see above)
set (REFMAN_IDX ${REFMAN}.idx)
set (REFMAN_PDF ${REFMAN}.pdf)
set (REFMAN_PDF_FULL ${TEX_GEN_DIR}/${REFMAN_PDF})
# Note the "|| echo" addition to the pdflatex command, as that latter returns
# as if there were an error.
add_custom_command (OUTPUT ${REFMAN_PDF_FULL}
  DEPENDS ${DOXYGEN_OUTPUT} ${REFMAN_TEX_FULL}
  COMMAND ${CMAKE_COMMAND} 
  ARGS -E chdir ${TEX_GEN_DIR} pdflatex -interaction batchmode ${REFMAN_TEX} || echo "First PDF generation done."
  COMMAND ${CMAKE_COMMAND} 
  ARGS -E chdir ${TEX_GEN_DIR} makeindex -q ${REFMAN_IDX}
  COMMAND ${CMAKE_COMMAND} 
  ARGS -E chdir ${TEX_GEN_DIR} pdflatex -interaction batchmode ${REFMAN_TEX} || echo "Second PDF generation done."
  COMMENT "Generating PDF Reference Manual ('${REFMAN_PDF}')...")
# Add the 'pdf' target, depending on the generated PDF manual
add_custom_target (pdf ALL DEPENDS ${REFMAN_PDF_FULL})

# Clean-up $build/html and $build/latex on 'make clean'
set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES 
  ${htmldoc_DIR} ${pdfdoc_DIR})

# Installation of the HTML documentation
set (DOC_PATH share/doc/${PROJECT_NAME}-${CPACK_PACKAGE_VERSION})
install (DIRECTORY ${htmldoc_DIR} DESTINATION ${DOC_PATH})
install (FILES ${TEX_GEN_DIR}/${REFMAN_PDF}
  DESTINATION ${DOC_PATH}/html)<commit_msg>[Doc] Improved the generation of the HTML and PDF documentation.<commit_after>##
# StdAir documentation (HTML, PDF, RTF), to be generated by Doxygen
#

# Define the substitutes for the variables present in the Doxygen
# configuration file. Note that PACKAGE, PACKAGE_NAME and PACKAGE_VERSION
# are defined in the main CMakeLists.txt (of the top root directory).
set (OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set (top_srcdir       ${CMAKE_SOURCE_DIR})
set (srcdir           ${CMAKE_CURRENT_SOURCE_DIR})

# Convert the Doxygen configuration files (basically, just replace
# the @<variable>@ variables).
set (DOXYGEN_CFG_SRC doxygen_html.cfg.in)
set (DOXYGEN_CFG ${CMAKE_CURRENT_BINARY_DIR}/doxygen_html.cfg)
configure_file (${DOXYGEN_CFG_SRC} ${DOXYGEN_CFG} @ONLY)

## Documentation sources
# (CSS) Style sheets
set (docstyles_DIR ${CMAKE_CURRENT_SOURCE_DIR}/styles)
set (style_SOURCES ${CPACK_PACKAGE_NAME}.css)
set (docstyles_SOURCES ${docstyles_DIR}/${style_SOURCES})
# Images
set (docimages_DIR ${CMAKE_CURRENT_SOURCE_DIR}/images)
set (image_SOURCES ${CPACK_PACKAGE_NAME}_logo.png sfx_logo.png favicon.ico)
set (docimages_SOURCES "")
foreach (_doc_img_src ${image_SOURCES})
  list (APPEND docimages_SOURCES ${docimages_DIR}/${_doc_img_src})
endforeach (_doc_img_src ${image_SOURCES})
# Tutorial
FILE (GLOB doctutorial_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tutorial/*.doc)
# Local
FILE (GLOB doclocaldoc_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/local/*.doc)
FILE (GLOB doclocalhtml_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/local/*.html)
set (doclocal_SOURCES ${doclocaldoc_SOURCES} ${doclocalhtml_SOURCES})
# Aggregating all the documentation sources
set (doc_SOURCES ${doctutorial_SOURCES} ${doclocal_SOURCES}
  ${docstyles_SOURCES} ${docimages_SOURCES})

# Latex reference manual source (.tex file), generated by Doxygen
set (REFMAN refman)
set (TEX_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)
set (REFMAN_TEX ${REFMAN}.tex)
set (REFMAN_TEX_FULL ${TEX_GEN_DIR}/${REFMAN_TEX})

# Add the build rule for Doxygen
set (DOXYGEN_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
add_custom_command (OUTPUT ${DOXYGEN_OUTPUT} ${REFMAN_TEX_FULL}
  COMMAND ${DOXYGEN_EXECUTABLE} ARGS ${DOXYGEN_CFG}
  DEPENDS ${DOXYGEN_CFG} ${doc_SOURCES}
  COMMENT "Generating documentation with Doxygen, from '${DOXYGEN_CFG}'...")
# Add the 'doc' target, depending on the generated HTML documentation
add_custom_target (doc ALL DEPENDS ${DOXYGEN_OUTPUT})

##
# Copy the needed files into the generated HTML directory
set (htmldoc_DIR ${CMAKE_CURRENT_BINARY_DIR}/html)
set (pdfdoc_DIR ${CMAKE_CURRENT_BINARY_DIR}/latex)

# (CSS) Style sheets
foreach (style_SRC ${style_SOURCES})
  set (CSS_SRC_FULL_DIR ${docstyles_DIR}/${style_SRC})
  set (CSS_GEN_FULL_DIR ${htmldoc_DIR}/${style_SRC})
  add_custom_command (OUTPUT ${CSS_GEN_FULL_DIR}
	COMMAND ${CMAKE_COMMAND}
	ARGS -E copy ${CSS_SRC_FULL_DIR} ${CSS_GEN_FULL_DIR}
	DEPENDS ${DOXYGEN_OUTPUT} ${CSS_SRC_FULL_DIR}
	COMMENT "Copying style '${CSS_SRC_FULL_DIR}' into '${htmldoc_DIR}'...")
  add_custom_target (css_${style_SRC} ALL DEPENDS ${CSS_GEN_FULL_DIR})
endforeach (style_SRC)

# Images
foreach (image_SRC ${image_SOURCES})
  set (IMG_SRC_FULL_DIR ${docimages_DIR}/${image_SRC})
  set (IMG_GEN_FULL_DIR ${htmldoc_DIR}/${image_SRC})
  add_custom_command (OUTPUT ${IMG_GEN_FULL_DIR}
	COMMAND ${CMAKE_COMMAND} 
	ARGS -E copy ${IMG_SRC_FULL_DIR} ${IMG_GEN_FULL_DIR}
	DEPENDS ${DOXYGEN_OUTPUT} ${IMG_SRC_FULL_DIR}
	COMMENT "Copying image '${IMG_SRC_FULL_DIR}' into '${htmldoc_DIR}'...")
  add_custom_target (img_${image_SRC} ALL DEPENDS ${IMG_GEN_FULL_DIR})
endforeach (image_SRC)

##
# PDF, generated by (Pdf)Latex from the Latex source file, itself generated
# by Doxygen (see above)
set (REFMAN_IDX ${REFMAN}.idx)
set (REFMAN_IDX_FULL ${TEX_GEN_DIR}/${REFMAN_IDX})
set (REFMAN_PDF ${REFMAN}.pdf)
set (REFMAN_PDF_FULL ${TEX_GEN_DIR}/${REFMAN_PDF})
# Note the "|| echo" addition to the pdflatex command, as that latter returns
# as if there were an error.
add_custom_command (OUTPUT ${REFMAN_IDX_FULL} ${REFMAN_PDF_FULL}
  DEPENDS ${DOXYGEN_OUTPUT} ${REFMAN_TEX_FULL}
  COMMAND ${CMAKE_COMMAND}
  ARGS -E chdir ${TEX_GEN_DIR} pdflatex -interaction batchmode ${REFMAN_TEX} || echo "First PDF generation done."
  COMMAND ${CMAKE_COMMAND}
  ARGS -E chdir ${TEX_GEN_DIR} makeindex -q ${REFMAN_IDX}
  COMMAND ${CMAKE_COMMAND}
  ARGS -E chdir ${TEX_GEN_DIR} pdflatex -interaction batchmode ${REFMAN_TEX} || echo "Second PDF generation done."
  COMMENT "Generating PDF Reference Manual ('${REFMAN_PDF}')..."
  COMMAND ${CMAKE_COMMAND}
  ARGS -E chdir ${TEX_GEN_DIR} test -f ${REFMAN_PDF} || echo "Warning: the PDF reference manual \\\('${REFMAN_PDF_FULL}'\\\) has failed to build. You can perform a simple re-build \\\('make' in the 'doc/latex' sub-directory\\\)."
  COMMENT "Checking whether the PDF Reference Manual ('${REFMAN_PDF}') has been built...")
# Add the 'pdf' target, depending on the generated PDF manual
add_custom_target (pdf ALL DEPENDS ${REFMAN_PDF_FULL})

# Clean-up $build/html and $build/latex on 'make clean'
set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES 
  ${htmldoc_DIR} ${pdfdoc_DIR})

##
# Installation of the HTML documentation
set (DOC_PATH share/doc/${PROJECT_NAME}-${CPACK_PACKAGE_VERSION})
# HTML pages
install (DIRECTORY ${htmldoc_DIR} DESTINATION ${DOC_PATH})
# PDF reference manual
# Note: the 'OPTIONAL' ensures that even when the PDF file fails to be
# generated, the install process does not complain. If the PDF build fails,
# a simple re-build ('make' in the 'doc/latex' sub-directory) is usually enough.
install (FILES ${REFMAN_PDF_FULL} DESTINATION ${DOC_PATH}/html OPTIONAL)
{'fraction_non_alphanumeric': 0.11773848843986788, 'fraction_numerical': 0.0, 'mean_word_length': 6.671385991058123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7416696', 'n_tokens_mistral': 3845, 'n_tokens_neox': 3668, 'n_words': 931}