Skip to content

Commit ad72092

Browse files
committed
Use cmake for docs
1 parent 6d21a85 commit ad72092

File tree

7 files changed

+71
-83
lines changed

7 files changed

+71
-83
lines changed

Diff for: .github/workflows/pages.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,23 @@ jobs:
2121
with:
2222
python-version: '3.13'
2323
- name: Install dependencies
24-
working-directory: ./docs
2524
run: |
26-
python3 -m pip install -r requirements.txt
25+
python3 -m pip install -r docs/requirements.txt
26+
- name: Configure project
27+
run: >
28+
cmake -S . -B build -D USE_DOCS=ON
2729
- name: Build i18n
28-
working-directory: ./docs
2930
run: |
30-
make gettext
31-
sphinx-build -b gettext . _build/gettext
32-
sphinx-intl update -p _build/gettext -l en -l ru
31+
cmake --build build -t docs_gettext
32+
cmake --build build -t docs_update
3333
- name: Build documentation
34-
working-directory: ./docs
3534
run: |
36-
make html
35+
cmake --build build -t docs_html
3736
- name: Upload artifact
3837
uses: actions/upload-artifact@v4
3938
with:
4039
name: sphinx-documentation
41-
path: ./docs/_build/html
40+
path: ./build/docs/_build/html
4241
build-scoreboard:
4342
runs-on: ubuntu-24.04
4443
steps:

Diff for: CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ message( STATUS "PPC step: Setup external projects" )
2424
include(cmake/opencv.cmake)
2525
include(cmake/gtest.cmake)
2626

27+
########################### Documentation ###########################
28+
29+
message( STATUS "PPC step: Setup documentation generation" )
30+
include(cmake/sphinx.cmake)
31+
add_subdirectory(docs)
32+
2733
############################ Scoreboard #############################
2834

2935
message( STATUS "PPC step: Setup scoreboard generator" )

Diff for: cmake/sphinx.cmake

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
option(USE_DOCS OFF)
2+
if( USE_DOCS )
3+
set(SPHINXBUILD "sphinx-build")
4+
set(SPHINXINTL "sphinx-intl")
5+
set(SPHINXOPTS "-W" "--keep-going" "-n")
6+
endif( USE_DOCS )

Diff for: docs/CMakeLists.txt

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
if (NOT USE_DOCS)
2+
return()
3+
endif()
4+
5+
set(SOURCEDIR "${CMAKE_CURRENT_SOURCE_DIR}")
6+
set(BUILDDIR "${CMAKE_CURRENT_BINARY_DIR}/_build/html")
7+
set(GETTEXTDIR "${CMAKE_CURRENT_BINARY_DIR}/_build/gettext")
8+
9+
add_custom_target(docs_help
10+
COMMAND ${SPHINXBUILD} -M help "${SOURCEDIR}" "${BUILDDIR}/en" ${SPHINXOPTS}
11+
WORKING_DIRECTORY "${SOURCEDIR}"
12+
COMMENT "Displaying Sphinx Makefile help"
13+
)
14+
15+
# 'gettext' target: generate gettext catalogs.
16+
add_custom_target(docs_gettext
17+
COMMAND ${SPHINXBUILD} -b gettext "${SOURCEDIR}" "${GETTEXTDIR}" ${SPHINXOPTS}
18+
WORKING_DIRECTORY "${SOURCEDIR}"
19+
COMMENT "Generating gettext output"
20+
)
21+
22+
# 'update' target: update translations for the specified languages.
23+
add_custom_target(docs_update
24+
COMMAND ${SPHINXINTL} update -p "${GETTEXTDIR}" -l en -l ru
25+
WORKING_DIRECTORY "${SOURCEDIR}"
26+
COMMENT "Updating Sphinx translations"
27+
)
28+
29+
# 'html' target: build the HTML documentation in both English and Russian.
30+
add_custom_target(docs_html
31+
# Build English documentation.
32+
COMMAND ${SPHINXBUILD} -b html -D language=en "${SOURCEDIR}" "${BUILDDIR}/en" ${SPHINXOPTS}
33+
# Build Russian documentation.
34+
COMMAND ${SPHINXBUILD} -b html -D language=ru "${SOURCEDIR}" "${BUILDDIR}/ru" ${SPHINXOPTS}
35+
WORKING_DIRECTORY "${SOURCEDIR}"
36+
COMMENT "Building HTML documentation for English and Russian"
37+
)

Diff for: docs/Makefile

-29
This file was deleted.

Diff for: docs/README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,35 @@ python3 -m venv venv
1717
pip install -r requirements.txt
1818
```
1919

20-
4. Build the documentation:
20+
4. Configure the documentation build:
2121
```bash
22-
make html
22+
cmake -S . -B build -DUSE_DOCS=ON
2323
```
2424

25-
5. Update the documentation:
25+
5. Build the documentation:
2626
```bash
27-
make gettext
27+
cmake --build build -t docs_html
28+
```
29+
30+
6. Update the documentation:
31+
```bash
32+
cmake --build build -t docs_gettext
2833
# update documentation
29-
make update
34+
cmake --build build -t docs_update
3035
```
3136

32-
6. Re-build the documentation:
37+
7. Re-build the documentation:
3338
```bash
34-
make html
39+
cmake --build build -t docs_html
3540
```
3641

37-
7. Make local deployment of the changes:
42+
8. Make local deployment of the changes:
3843
```bash
3944
cd _build/html
4045
python3 -m http.server 8080
4146
```
4247

43-
8. Open the documentation in your browser:
48+
9. Open the documentation in your browser:
4449
```bash
4550
open http://localhost:8080/en
4651
open http://localhost:8080/ru

Diff for: docs/make.bat

-36
This file was deleted.

0 commit comments

Comments
 (0)