diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1fe1fe6..1146abb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -48,8 +48,10 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.1 - - name: Install Requirements - run: pip3 install -r docs/requirements.txt + - name: Install Dependencies + run: | + sudo apt-get install -y doxygen + pip3 install -r docs/requirements.txt - name: Build Documentation run: sphinx-build -b html docs build/docs -W --keep-going diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e484c7e..0fbd1d2 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -23,8 +23,10 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.1 - - name: Install Requirements - run: pip3 install -r docs/requirements.txt + - name: Install Dependencies + run: | + sudo apt-get install -y doxygen + pip3 install -r docs/requirements.txt - name: Build Documentation run: sphinx-build -b html docs docs/build -W --keep-going diff --git a/CMakeLists.txt b/CMakeLists.txt index a67adf7..d3d8cb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,10 +71,9 @@ if(NOT_SUBPROJECT) catch_discover_tests(errors_test) endif() - # Build XML documentation if(BUILD_DOCS) - include(cmake/add_xml_docs.cmake) - add_xml_docs(errors_docs include/errors/error.hpp) + include(cmake/GenerateDocs.cmake) + target_generate_xml_docs(errors) endif() if(BUILD_EXAMPLES) diff --git a/cmake/GenerateDocs.cmake b/cmake/GenerateDocs.cmake new file mode 100644 index 0000000..a762237 --- /dev/null +++ b/cmake/GenerateDocs.cmake @@ -0,0 +1,14 @@ +# Function to generate an XML documentation of a specific target. +# Arguments: +# - TARGET: The target for which to generate an XML documentation. +function(target_generate_xml_docs TARGET) + find_package(Doxygen REQUIRED) + + # Configure Doxygen to generate an XML documentation. + set(DOXYGEN_GENERATE_HTML NO) + set(DOXYGEN_GENERATE_XML YES) + set(DOXYGEN_XML_OUTPUT ${TARGET}_docs) + + get_target_property(TARGET_HEADER_SET ${TARGET} HEADER_SET) + doxygen_add_docs(${TARGET}_docs ${TARGET_HEADER_SET} USE_STAMP_FILE) +endfunction() diff --git a/cmake/add_xml_docs.cmake b/cmake/add_xml_docs.cmake deleted file mode 100644 index dfd02c3..0000000 --- a/cmake/add_xml_docs.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# A function that generates XML documentation from the specified source files. -function(add_xml_docs TARGET_NAME) - # Try to install Doxygen if not found - find_program(DOXYGEN_PROGRAM doxygen) - if(NOT DOXYGEN_PROGRAM) - find_program(APT_GET_PROGRAM apt-get) - if(APT_GET_PROGRAM) - message(STATUS "Doxygen could not be found, installing...") - execute_process(COMMAND sudo ${APT_GET_PROGRAM} install -y doxygen) - endif() - - find_program(BREW_PROGRAM brew) - if(BREW_PROGRAM) - message(STATUS "Doxygen could not be found, installing...") - execute_process(COMMAND ${BREW_PROGRAM} install doxygen) - endif() - endif() - - # Try to find Doxygen - find_package(Doxygen) - if(DOXYGEN_FOUND) - # Configure Doxygen to generate XML documentation - set(DOXYGEN_GENERATE_HTML NO) - set(DOXYGEN_GENERATE_XML YES) - set(DOXYGEN_XML_OUTPUT ${TARGET_NAME}) - - # Generate XML documentation for the target - doxygen_add_docs(${TARGET_NAME} ${ARGN} USE_STAMP_FILE) - endif() -endfunction() diff --git a/components/format/CMakeLists.txt b/components/format/CMakeLists.txt index 718ca93..722759f 100644 --- a/components/format/CMakeLists.txt +++ b/components/format/CMakeLists.txt @@ -39,8 +39,7 @@ if(NOT_SUBPROJECT) catch_discover_tests(errors_format_test) endif() - # Build XML documentation if(BUILD_DOCS) - add_xml_docs(errors_format_docs include/errors/format.hpp) + target_generate_xml_docs(errors_format) endif() endif()