<commit_before>find_package(Sphinx)
find_package(LATEX)

set(DOC_LATEX_DIR ${PROJECT_BINARY_DIR}/doc_latex)
set(DOC_HTML_DIR ${PROJECT_BINARY_DIR}/doc)
set(DOC_SRC_DIR ${PROJECT_BINARY_DIR}/doc_src)

make_directory(${DOC_SRC_DIR})

# Copy all files from /doc dir to the /doc_src dir. doc_src is used to compile the documentation.
# Use custom copy command to make sure files are correctly updated when they are changed.
file(GLOB DOC_SRC "${PROJECT_SOURCE_DIR}/doc/*")
list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/conf.py")
list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/CMakeLists.txt")
string(REPLACE "${PROJECT_SOURCE_DIR}/doc" "${DOC_SRC_DIR}" DOC_TARGET "${DOC_SRC}")
file(COPY ${DOC_SRC} DESTINATION ${DOC_SRC_DIR})

configure_file("${PROJECT_SOURCE_DIR}/doc/conf.py" "${DOC_SRC_DIR}/conf.py")


list(APPEND GENERATED_RST "")

macro(generate_rst in out)
    add_custom_command(OUTPUT ${out}
                       DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
                       PRE_BUILD
                       COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
    list(APPEND GENERATED_RST "${out}")
endmacro()


# Doc from headers
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/types.h ${DOC_SRC_DIR}/types.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/constants.h ${DOC_SRC_DIR}/constants.rst)
generate_rst(${PROJECT_BINARY_DIR}/src_generated/open62541/statuscodes.h ${DOC_SRC_DIR}/statuscodes.rst)
generate_rst(${PROJECT_BINARY_DIR}/src_generated/open62541/types_generated.h ${DOC_SRC_DIR}/types_generated.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server_config.h ${DOC_SRC_DIR}/server_config.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server.h ${DOC_SRC_DIR}/server.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_config.h ${DOC_SRC_DIR}/client_config.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_subscriptions.h ${DOC_SRC_DIR}/client_subscriptions.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client.h ${DOC_SRC_DIR}/client.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/log.h ${DOC_SRC_DIR}/plugin_log.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/network.h ${DOC_SRC_DIR}/plugin_network.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/accesscontrol.h ${DOC_SRC_DIR}/plugin_accesscontrol.rst)
generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/pubsub.h ${DOC_SRC_DIR}/plugin_pubsub_connection.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server_pubsub.h ${DOC_SRC_DIR}/pubsub.rst)

# Doc from tutorial code
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_datatypes.c ${DOC_SRC_DIR}/tutorial_datatypes.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_firststeps.c ${DOC_SRC_DIR}/tutorial_server_firststeps.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variable.c ${DOC_SRC_DIR}/tutorial_server_variable.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variabletype.c ${DOC_SRC_DIR}/tutorial_server_variabletype.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_datasource.c ${DOC_SRC_DIR}/tutorial_server_datasource.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_events.c ${DOC_SRC_DIR}/tutorial_server_events.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_monitoreditems.c ${DOC_SRC_DIR}/tutorial_server_monitoreditems.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_object.c ${DOC_SRC_DIR}/tutorial_server_object.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_method.c ${DOC_SRC_DIR}/tutorial_server_method.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_client_firststeps.c ${DOC_SRC_DIR}/tutorial_client_firststeps.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/pubsub/tutorial_pubsub_publish.c ${DOC_SRC_DIR}/tutorial_pubsub_publish.rst)


# Doc targets

add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
                  -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_DIR}"
                  DEPENDS ${GENERATED_RST} ${DOC_TARGET}
                  COMMENT "Building LaTeX sources for documentation with Sphinx")
add_dependencies(doc_latex open62541)

add_custom_target(doc_pdf ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
                  WORKING_DIRECTORY ${DOC_LATEX_DIR}
                  # compile it twice so that the contents pages are correct
                  COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
                  DEPENDS ${PDFLATEX_COMPILER}
                  COMMENT "Generating PDF documentation from LaTeX sources")
add_dependencies(doc_pdf doc_latex)

add_custom_target(doc ${SPHINX_EXECUTABLE}
                  -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
                  DEPENDS ${GENERATED_RST} ${DOC_TARGET}
                  COMMENT "Building HTML documentation with Sphinx")
add_dependencies(doc open62541)

set_target_properties(doc doc_latex doc_pdf PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
set_target_properties(doc doc_latex doc_pdf PROPERTIES FOLDER "open62541/doc")

if (UA_PACK_DEBIAN)
    set(open62541_install_debdoc_html_dir share/doc/open62541/open62541.html)
    set(open62541_install_debdoc_dir share/doc/open62541)

    set(open62541_debdoc_pdf_files "${DOC_LATEX_DIR}/open62541.pdf")

    install(DIRECTORY ${DOC_HTML_DIR}/
        COMPONENT htmldoc 
        DESTINATION ${open62541_install_debdoc_dir}/open62541.html 
        USE_SOURCE_PERMISSIONS
        FILES_MATCHING 
        PATTERN "*.*"
        PATTERN "_sources" EXCLUDE
        PATTERN "_static/ua-wireshark-pubsub.png" EXCLUDE
        PATTERN "_static/ua-wireshark.png" EXCLUDE
        PATTERN "_static/nodeset_compiler_pump.png" EXCLUDE
        PATTERN ".doctrees" EXCLUDE
        PATTERN ".buildinfo" EXCLUDE
        PATTERN "CMakeFiles" EXCLUDE
        PATTERN "CMakeLists.txt" EXCLUDE
        PATTERN "Makefile" EXCLUDE
        PATTERN "*.map" EXCLUDE
        PATTERN "*.cmake" EXCLUDE
        PATTERN "*.inv" EXCLUDE
        PATTERN "*.py" EXCLUDE
        )
    install(FILES ${open62541_debdoc_pdf_files} COMPONENT pdfdoc DESTINATION ${open62541_install_debdoc_dir})
endif()<commit_msg>remove only leftovers dh_sphinxdoc ignores<commit_after>find_package(Sphinx)
find_package(LATEX)

set(DOC_LATEX_DIR ${PROJECT_BINARY_DIR}/doc_latex)
set(DOC_HTML_DIR ${PROJECT_BINARY_DIR}/doc)
set(DOC_SRC_DIR ${PROJECT_BINARY_DIR}/doc_src)

make_directory(${DOC_SRC_DIR})

# Copy all files from /doc dir to the /doc_src dir. doc_src is used to compile the documentation.
# Use custom copy command to make sure files are correctly updated when they are changed.
file(GLOB DOC_SRC "${PROJECT_SOURCE_DIR}/doc/*")
list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/conf.py")
list(REMOVE_ITEM DOC_SRC "${PROJECT_SOURCE_DIR}/doc/CMakeLists.txt")
string(REPLACE "${PROJECT_SOURCE_DIR}/doc" "${DOC_SRC_DIR}" DOC_TARGET "${DOC_SRC}")
file(COPY ${DOC_SRC} DESTINATION ${DOC_SRC_DIR})

configure_file("${PROJECT_SOURCE_DIR}/doc/conf.py" "${DOC_SRC_DIR}/conf.py")


list(APPEND GENERATED_RST "")

macro(generate_rst in out)
    add_custom_command(OUTPUT ${out}
                       DEPENDS ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in}
                       PRE_BUILD
                       COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tools/c2rst.py ${in} ${out})
    list(APPEND GENERATED_RST "${out}")
endmacro()


# Doc from headers
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/types.h ${DOC_SRC_DIR}/types.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/constants.h ${DOC_SRC_DIR}/constants.rst)
generate_rst(${PROJECT_BINARY_DIR}/src_generated/open62541/statuscodes.h ${DOC_SRC_DIR}/statuscodes.rst)
generate_rst(${PROJECT_BINARY_DIR}/src_generated/open62541/types_generated.h ${DOC_SRC_DIR}/types_generated.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server_config.h ${DOC_SRC_DIR}/server_config.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server.h ${DOC_SRC_DIR}/server.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_config.h ${DOC_SRC_DIR}/client_config.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_subscriptions.h ${DOC_SRC_DIR}/client_subscriptions.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client.h ${DOC_SRC_DIR}/client.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/client_highlevel.h ${DOC_SRC_DIR}/client_highlevel.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/log.h ${DOC_SRC_DIR}/plugin_log.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/network.h ${DOC_SRC_DIR}/plugin_network.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/accesscontrol.h ${DOC_SRC_DIR}/plugin_accesscontrol.rst)
generate_rst(${PROJECT_SOURCE_DIR}/src/server/ua_services.h ${DOC_SRC_DIR}/services.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/nodestore.h ${DOC_SRC_DIR}/nodestore.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/plugin/pubsub.h ${DOC_SRC_DIR}/plugin_pubsub_connection.rst)
generate_rst(${PROJECT_SOURCE_DIR}/include/open62541/server_pubsub.h ${DOC_SRC_DIR}/pubsub.rst)

# Doc from tutorial code
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_datatypes.c ${DOC_SRC_DIR}/tutorial_datatypes.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_firststeps.c ${DOC_SRC_DIR}/tutorial_server_firststeps.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variable.c ${DOC_SRC_DIR}/tutorial_server_variable.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_variabletype.c ${DOC_SRC_DIR}/tutorial_server_variabletype.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_datasource.c ${DOC_SRC_DIR}/tutorial_server_datasource.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_events.c ${DOC_SRC_DIR}/tutorial_server_events.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_monitoreditems.c ${DOC_SRC_DIR}/tutorial_server_monitoreditems.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_object.c ${DOC_SRC_DIR}/tutorial_server_object.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_server_method.c ${DOC_SRC_DIR}/tutorial_server_method.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/tutorial_client_firststeps.c ${DOC_SRC_DIR}/tutorial_client_firststeps.rst)
generate_rst(${PROJECT_SOURCE_DIR}/examples/pubsub/tutorial_pubsub_publish.c ${DOC_SRC_DIR}/tutorial_pubsub_publish.rst)


# Doc targets

add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
                  -b latex "${DOC_SRC_DIR}" "${DOC_LATEX_DIR}"
                  DEPENDS ${GENERATED_RST} ${DOC_TARGET}
                  COMMENT "Building LaTeX sources for documentation with Sphinx")
add_dependencies(doc_latex open62541)

add_custom_target(doc_pdf ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
                  WORKING_DIRECTORY ${DOC_LATEX_DIR}
                  # compile it twice so that the contents pages are correct
                  COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "open62541.tex"
                  DEPENDS ${PDFLATEX_COMPILER}
                  COMMENT "Generating PDF documentation from LaTeX sources")
add_dependencies(doc_pdf doc_latex)

add_custom_target(doc ${SPHINX_EXECUTABLE}
                  -b html "${DOC_SRC_DIR}" "${DOC_HTML_DIR}"
                  DEPENDS ${GENERATED_RST} ${DOC_TARGET}
                  COMMENT "Building HTML documentation with Sphinx")
add_dependencies(doc open62541)

set_target_properties(doc doc_latex doc_pdf PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
set_target_properties(doc doc_latex doc_pdf PROPERTIES FOLDER "open62541/doc")

if (UA_PACK_DEBIAN)
    set(open62541_install_debdoc_html_dir share/doc/open62541/open62541.html)
    set(open62541_install_debdoc_dir share/doc/open62541)

    set(open62541_debdoc_pdf_files "${DOC_LATEX_DIR}/open62541.pdf")

    install(DIRECTORY ${DOC_HTML_DIR}/
        COMPONENT htmldoc 
        DESTINATION ${open62541_install_debdoc_dir}/open62541.html 
        USE_SOURCE_PERMISSIONS
        FILES_MATCHING 
        PATTERN "*.*"
        PATTERN "_sources" EXCLUDE
        PATTERN "CMakeFiles" EXCLUDE
        PATTERN "cmake_install.cmake" EXCLUDE
        )
    install(FILES ${open62541_debdoc_pdf_files} COMPONENT pdfdoc DESTINATION ${open62541_install_debdoc_dir})
endif()
{'fraction_non_alphanumeric': 0.11117239205798929, 'fraction_numerical': 0.02552789158525055, 'mean_word_length': 5.816863587540279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4508839', 'n_tokens_mistral': 4950, 'n_tokens_neox': 4340, 'n_words': 549}