Skip to content

Commit 2f33d02

Browse files
committed
add doxygen docs target
1 parent f7bd1a9 commit 2f33d02

4 files changed

Lines changed: 3134 additions & 1 deletion

File tree

‎.github/workflows/deploy-docs.yml‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-26.04
20+
timeout-minutes: 15
21+
22+
steps:
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
26+
- name: Install Doxygen
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y doxygen
30+
31+
- name: Setup Pages
32+
id: pages
33+
uses: actions/configure-pages@v5
34+
35+
- name: Configure CMake
36+
run: cmake -B build -DUBLKCPP_BUILD_DOCS=ON
37+
38+
- name: Build Documentation
39+
run: cmake --build build --target docs
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: ./build/docs/html
45+
46+
deploy:
47+
needs: build
48+
runs-on: ubuntu-26.04
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v4

‎CMakeLists.txt‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
cmake_minimum_required(VERSION 3.13)
22

3-
project(ublkcpp LANGUAGES CXX)
3+
# Version is defined once in the version header.
4+
set(UBLKCPP_VERSION_HEADER include/ublk/version.hpp)
5+
file(READ ${UBLKCPP_VERSION_HEADER} _ublkcpp_version_h)
6+
string(REGEX MATCH "#define UBLKCPP_VERSION_MAJOR ([0-9]+)" _ublkcpp_ver_m "${_ublkcpp_version_h}")
7+
set(UBLKCPP_VERSION_MAJOR ${CMAKE_MATCH_1})
8+
string(REGEX MATCH "#define UBLKCPP_VERSION_MINOR ([0-9]+)" _ublkcpp_ver_m "${_ublkcpp_version_h}")
9+
set(UBLKCPP_VERSION_MINOR ${CMAKE_MATCH_1})
10+
set(UBLKCPP_VERSION_STRING "v${UBLKCPP_VERSION_MAJOR}.${UBLKCPP_VERSION_MINOR}")
11+
12+
project(ublkcpp VERSION ${UBLKCPP_VERSION_MAJOR}.${UBLKCPP_VERSION_MINOR} LANGUAGES CXX)
13+
message(STATUS "Configuring ublkcpp ${UBLKCPP_VERSION_STRING}")
414

515
option(UBLKCPP_BUILD_TESTS "Build tests" OFF)
616
option(UBLKCPP_BUILD_UBLKCTL "Build ublkctl" OFF)
717
option(UBLKCPP_BUILD_EXAMPLES "Build examples" OFF)
18+
option(UBLKCPP_BUILD_DOCS "Build Doxygen documentation" OFF)
819
option(UBLKCPP_USE_URING_CMD128 "Use IORING_OP_URING_CMD128 for control commands" ON)
920
option(UBLKCPP_TESTS_STATIC_LINK "Use static linking for tests" OFF)
1021
option(UBLKCPP_TESTS_ASAN "Enable address and undefined behavior sanitizers for tests" OFF)
@@ -13,6 +24,7 @@ include(FetchContent)
1324

1425
set(DOCTEST_VERSION v2.5.0)
1526
set(CLI11_VERSION v2.7.2)
27+
set(DOXYGEN_AWESOME_CSS_VERSION v2.4.1)
1628

1729
FetchContent_Declare(
1830
doctest
@@ -24,6 +36,11 @@ FetchContent_Declare(
2436
URL https://github.com/CLIUtils/CLI11/releases/download/${CLI11_VERSION}/CLI11.hpp
2537
DOWNLOAD_NO_EXTRACT TRUE
2638
)
39+
FetchContent_Declare(
40+
doxygen-awesome-css
41+
URL https://raw.githubusercontent.com/jothepro/doxygen-awesome-css/${DOXYGEN_AWESOME_CSS_VERSION}/doxygen-awesome.css
42+
DOWNLOAD_NO_EXTRACT TRUE
43+
)
2744

2845
add_library(ublkcpp INTERFACE)
2946
target_include_directories(ublkcpp INTERFACE include)
@@ -51,3 +68,8 @@ if(UBLKCPP_BUILD_EXAMPLES)
5168
message(STATUS "Configuring examples in ${CMAKE_CURRENT_SOURCE_DIR}/examples")
5269
add_subdirectory(examples)
5370
endif()
71+
72+
if(UBLKCPP_BUILD_DOCS)
73+
message(STATUS "Configuring docs in ${CMAKE_CURRENT_SOURCE_DIR}/docs")
74+
add_subdirectory(docs)
75+
endif()

‎docs/CMakeLists.txt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
find_program(DOXYGEN_EXECUTABLE NAMES doxygen REQUIRED)
2+
3+
message(STATUS "Fetching doxygen-awesome-css")
4+
FetchContent_MakeAvailable(doxygen-awesome-css)
5+
FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR)
6+
7+
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
8+
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
9+
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
10+
11+
add_custom_target(docs
12+
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
13+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
14+
COMMENT "Generate Doxygen documentation into ${CMAKE_CURRENT_BINARY_DIR}/html"
15+
VERBATIM)

0 commit comments

Comments
 (0)