diff --git a/.github/workflows/publish_doc.yml b/.github/workflows/publish_doc.yml index 69fe23f..496bfcd 100644 --- a/.github/workflows/publish_doc.yml +++ b/.github/workflows/publish_doc.yml @@ -18,13 +18,14 @@ jobs: submodules: 'true' - name: run doxygen run: | - brew install doxygen graphviz - mkdir -p build - doxygen + brew install doxygen graphviz python3 cmake ninja + python3 -m pip install --upgrade pip + pip install sphinx breathe sphinx-rtd-theme + cmake --workflow --preset build-doc - uses: actions/upload-pages-artifact@v3 with: - path: build/html + path: build/doc/sphinx retention-days: 1 deploy-doc: diff --git a/CMakeLists.txt b/CMakeLists.txt index f979429..5d390cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.28) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) include(option_settings) + set(ENV{CMAKE_ENABLE_TEST} ${ENABLE_TEST}) project( @@ -10,25 +11,31 @@ project( VERSION 0.1.1 LANGUAGES CXX C) -include(install_config) -include(project_config) -include(check_compilers) - -set(CMAKE_CXX_STANDARD 23) -set(CMAKE_CXX_EXTENSIONS ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_CXX_SCAN_FOR_MODULES OFF) - -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - list(APPEND CMAKE_CXX_FLAGS "-fexperimental-library") -endif() - -include(import_packages) - -add_subdirectory(frontend) -add_subdirectory(backend) -add_subdirectory(examples) -add_subdirectory(doc) -if(ENABLE_TEST) - add_subdirectory(test) +if(BUILD_ONLY_DOC) + add_subdirectory(doc) +else() + if(BUILD_DOC) + add_subdirectory(doc) + endif() + include(install_config) + include(project_config) + include(check_compilers) + + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_CXX_EXTENSIONS ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + set(CMAKE_CXX_SCAN_FOR_MODULES OFF) + + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + list(APPEND CMAKE_CXX_FLAGS "-fexperimental-library") + endif() + + include(import_packages) + + add_subdirectory(frontend) + add_subdirectory(backend) + add_subdirectory(examples) + if(ENABLE_TEST) + add_subdirectory(test) + endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json index 458b7eb..53e423b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -30,6 +30,15 @@ "CONAN_INSTALL_ARGS": "--build=missing;-scompiler.cppstd=gnu20", "BUILD_STATIC": "ON" } + }, + { + "name": "build-doc", + "displayName": "build-doc", + "description": "Documentation only build", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "BUILD_ONLY_DOC": "ON" + } } ], "buildPresets": [ @@ -40,6 +49,11 @@ { "name": "static", "configurePreset": "static" + }, + { + "name": "build-doc", + "configurePreset": "build-doc", + "targets": "doc" } ], "workflowPresets": [ @@ -68,6 +82,19 @@ "name": "static" } ] + }, + { + "name": "build-doc", + "steps": [ + { + "type": "configure", + "name": "build-doc" + }, + { + "type": "build", + "name": "build-doc" + } + ] } ] } diff --git a/cmake/option_settings.cmake b/cmake/option_settings.cmake index e1ffd4e..e1c2287 100644 --- a/cmake/option_settings.cmake +++ b/cmake/option_settings.cmake @@ -2,6 +2,8 @@ option(USE_ROOT "Force to use ROOT dependency." OFF) option(NO_ROOT "Disable the usage of ROOT dependency." OFF) option(BUILD_STATIC "Enable static linking of libstdc++." OFF) option(ENABLE_TEST "Enable testing framework of the project." ON) +option(BUILD_DOC "Build the documentation for this project." OFF) +option(BUILD_ONLY_DOC "Only build the documentation for this project." OFF) set(SPHINX_BUILDER "html" diff --git a/doc/conf.py.in b/doc/conf.py.in index 80bc3f4..a786809 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -7,8 +7,8 @@ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = '@CMAKE_PROJECT_NAME@' -copyright = '2024, Yanzhao Wang' -author = 'Yanzhao Wang' +copyright = '2024, Yanzhao Wang (王彥昭)' +author = 'Yanzhao Wang (王彥昭)' release = '@CMAKE_PROJECT_VERSION@' # -- General configuration --------------------------------------------------- @@ -23,7 +23,7 @@ html_context = { 'display_github': True, 'github_user': 'YanzhaoW', 'github_repo': 'srs-daq', - 'github_version': 'dev', + 'github_version': 'dev/doc/', } source_suffix = ['.rst' ] diff --git a/doc/index.rst b/doc/index.rst index fc79d71..d1a5836 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -7,7 +7,6 @@ install_conda build_source - Source Code @ GitHub .. toctree:: :maxdepth: 2