Skip to content

Commit 0ccfc5c

Browse files
committed
meson: build docs with meson
Introduce a custom target `build-docs` to build the sphinx documentation.
1 parent a32fcd0 commit 0ccfc5c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ clean:
4343
distclean: clean
4444
rm -rf dist MANIFEST
4545

46-
SPHINXOPTS += -D version=$(VERSION) -D release=$(VERSION)
47-
sphinx-%: install
48-
mkdir $(BUILD_DIR) && cd $(BUILD_DIR) && $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $*
49-
@echo Output has been generated in $(BUILD_DIR)/$*
50-
51-
doc: sphinx-html
52-
5346
check: build install
5447
($(PYTHON) -m pytest src/systemd/test docs $(TESTFLAGS))
5548

meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,17 @@ common_c_args = [
2121
]
2222

2323
subdir('src/systemd')
24+
25+
# Docs
26+
sphinx_build = find_program('sphinx-build', disabler: true, required: get_option('docs'))
27+
if get_option('docs')
28+
sphinx_args = ['-Dversion=' + meson.project_version(), '-Drelease=' + meson.project_version()]
29+
input_dir = meson.current_source_dir() / 'docs'
30+
output_dir = meson.current_build_dir() / 'html'
31+
output_file = output_dir / 'index.html'
32+
custom_target('build-docs',
33+
output: 'index.html',
34+
input: files('docs/conf.py'),
35+
command: [sphinx_build, '-b', 'html', sphinx_args, input_dir, output_dir],
36+
)
37+
endif

meson.options

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
option('docs', type : 'boolean', value : false)

0 commit comments

Comments
 (0)