Skip to content

Commit

Permalink
Reimplement doxygen target & workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eoan-ermine committed Mar 22, 2024
1 parent 036e6c3 commit 118e414
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 39 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/build_docs.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Documentation

on:
push:
branches:
- master
paths-ignore:
- ".github/**"
- "cmake/**"
- "examples/**"
- "tests/**"

jobs:
build:
name: Build and publish documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt install doxygen
sudo apt install graphviz
- name: Generate docs
run: |
cmake -S . -B building_docs
cmake --build building_docs --target docs
- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/html
23 changes: 3 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(tftp_common
)

include(cmake/ClangFormat.cmake)
include(cmake/Doxygen.cmake)

set(ALL_SOURCES
tftp_common/details/packets.hpp
Expand Down Expand Up @@ -71,25 +72,6 @@ if (MAIN_PROJECT)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/tftp_common/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
endif()

option(BUILD_DOC "Build documentation" OFF)

if (BUILD_DOCS)
find_package(Doxygen)

if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs)
add_custom_target(doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_IN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif (BUILD_DOCS)

option(BUILD_TESTS "Build tests" OFF)

if (BUILD_TESTS)
Expand All @@ -106,4 +88,5 @@ endif (BUILD_EXAMPLES)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Packing)

add_clang_format_target()
add_clang_format_target()
add_docs_target()
17 changes: 17 additions & 0 deletions cmake/Doxygen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Add a target for generating docs for the project using `doxygen` (i.e: cmake --build build --target docs)
#

function(add_docs_target)
find_package(Doxygen COMPONENTS dot)

if(Doxygen_FOUND)
set(DOXYGEN_CALLER_GRAPH YES)
set(DOXYGEN_CALL_GRAPH YES)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs)
doxygen_add_docs(docs ${PROJECT_SOURCE_DIR})
message(STATUS "Doxygen has been setup and docs target is now available.")
endif()
endfunction()

0 comments on commit 118e414

Please sign in to comment.