From cf54d425e2d38231fb65453c5d462ae79678914a Mon Sep 17 00:00:00 2001 From: kirillin Date: Mon, 4 Aug 2025 21:01:08 +0300 Subject: [PATCH] Add Doxygen --- .github/workflows/ci.yml | 2 +- .github/workflows/docs.yaml | 34 +++++++++++++++++++++++++ .gitignore | 2 ++ CMakeLists.txt | 51 +++++++++++++++---------------------- docs/Doxyfile | 29 +++++++++++++++++++++ 5 files changed, 86 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/docs.yaml create mode 100644 docs/Doxyfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe26c36..4458122 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: mystd ci +name: CI on: push: diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..a588022 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,34 @@ +name: deploy doxygen to github pages + +on: + push: + branches: [ docs ] + workflow_dispatch: + +permissions: + contents: write + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Doxygen + run: sudo apt-get install -y doxygen graphviz + + - name: Generate Doxygen docs + run: | + mkdir -p docs/output + doxygen docs/Doxyfile + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/html/ + destination_dir: . + keep_files: false diff --git a/.gitignore b/.gitignore index 5acb669..2173a27 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build .vscode +docs/doxygen/ +docs/sphinx/_build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index fb50829..04d7196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,37 +1,6 @@ cmake_minimum_required(VERSION 3.14) project(mystd) -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_EXPORT_COMPILE_COMMAND on) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug) -endif() -message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") - -# Compiler flags -if(CMAKE_BUILD_TYPE STREQUAL Release) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") -elseif(CMAKE_BUILD_TYPE STREQUAL Debug) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g0 -O0 -fsanitize=address,undefined -fno-omit-frame-pointer") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined") -endif() - -# Coverage flags -option(ENABLE_COVERAGE "Enable code coverage" OFF) -if(ENABLE_COVERAGE AND CMAKE_BUILD_TYPE STREQUAL Debug) - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") - else() - message(WARNING "Coverage is only supported with GCC or Clang") - endif() -endif() - -cmake_minimum_required(VERSION 3.14) -project(mystd) - set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -75,6 +44,13 @@ if(NOT Catch2_FOUND) message(FATAL_ERROR "Catch2 not found") endif() +find_package(Doxygen REQUIRED) +configure_file( + docs/Doxyfile + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + @ONLY +) + include_directories(include) add_library(mystd INTERFACE) @@ -116,3 +92,16 @@ if(ENABLE_COVERAGE) message(WARNING "lcov or genhtml not found, coverage report generation disabled") endif() endif() + +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/docs/doxygen/xml/index.xml + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/docs/doxygen + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + DEPENDS ${CMAKE_SOURCE_DIR}/include/mystd/ + COMMENT "Generating Doxygen XML..." +) + +add_custom_target(docs + DEPENDS ${CMAKE_BINARY_DIR}/docs/doxygen/xml/index.xml + COMMAND ${SPHINX_EXECUTABLE} -M html ${CMAKE_SOURCE_DIR}/docs/sphinx ${CMAKE_BINARY_DIR}/docs/sphinx +) diff --git a/docs/Doxyfile b/docs/Doxyfile new file mode 100644 index 0000000..54e88ae --- /dev/null +++ b/docs/Doxyfile @@ -0,0 +1,29 @@ +PROJECT_NAME = "mystd" +PROJECT_NUMBER = "1.0" +PROJECT_BRIEF = "a stl-like library" + +OUTPUT_DIRECTORY = docs/ +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = YES + +INPUT = include/ src/ +RECURSIVE = YES +EXCLUDE_PATTERNS = */tests/* */third_party/* + +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_PACKAGE = YES + +GENERATE_HTML = YES +HTML_OUTPUT = html + +GENERATE_LATEX = NO + +HAVE_DOT = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES + +OPTIMIZE_OUTPUT_FOR_C = NO +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES