Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build Documentation in CMake #90

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4.1.1

- name: Install Dependencies
run: |
sudo apt-get install -y doxygen
pip3 install -r docs/requirements.txt
- name: Install Doxygen
run: sudo apt-get install -y doxygen

- name: Configure Project
uses: threeal/cmake-action@v1.3.0
with:
options: BUILD_DOCS=ON

- name: Build Documentation
run: sphinx-build -b html docs build/docs -W --keep-going
run: cmake --build build --target docs

- name: Upload Documentation
uses: actions/upload-pages-artifact@v3.0.0
with:
path: build/docs
path: build/docs/html
15 changes: 9 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ jobs:
- name: Checkout
uses: actions/checkout@v4.1.1

- name: Install Dependencies
run: |
sudo apt-get install -y doxygen
pip3 install -r docs/requirements.txt
- name: Install Doxygen
run: sudo apt-get install -y doxygen

- name: Configure Project
uses: threeal/cmake-action@v1.3.0
with:
options: BUILD_DOCS=ON

- name: Build Documentation
run: sphinx-build -b html docs docs/build -W --keep-going
run: cmake --build build --target docs

- name: Upload Documentation
uses: actions/upload-pages-artifact@v3.0.0
with:
path: docs/build
path: build/docs/html

- name: Deploy Pages
id: deploy-pages
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ if(NOT_SUBPROJECT)
endif()

add_subdirectory(components)

if(NOT_SUBPROJECT AND BUILD_DOCS)
add_subdirectory(docs)
endif()
28 changes: 28 additions & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
find_package(Python REQUIRED)

message(STATUS "Installing Python dependencies")
execute_process(
COMMAND ${Python_EXECUTABLE} -m pip install -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt
RESULT_VARIABLE RES
ERROR_VARIABLE ERR
OUTPUT_QUIET
)
if(NOT RES EQUAL 0 )
message(FATAL_ERROR "Failed to install Python dependencies:\n${ERR}")
endif()

get_target_property(errors_docs_BINARY_DIR errors_docs BINARY_DIR)
get_target_property(errors_format_docs_BINARY_DIR errors_format_docs BINARY_DIR)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
COMMAND ${Python_EXECUTABLE} -m sphinx -b html ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/html -W --keep-going
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/conf.py
${CMAKE_CURRENT_SOURCE_DIR}/index.rst
${errors_docs_BINARY_DIR}/errors_docs.stamp
${errors_format_docs_BINARY_DIR}/errors_format_docs.stamp
)

add_custom_target(docs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
add_dependencies(docs errors_docs errors_format_docs)