Skip to content

Commit 87d97ad

Browse files
committed
meson: build docs with meson
Introduce a custom target `docs` and a build configuration option `docs` to build the sphinx documentation
1 parent f7883c1 commit 87d97ad

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ clean:
2929
distclean: clean
3030
rm -rf dist MANIFEST
3131

32-
SPHINXOPTS += -D version=$(VERSION) -D release=$(VERSION)
33-
sphinx-%: install
34-
mkdir $(BUILD_DIR) && cd $(BUILD_DIR) && $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $*
35-
@echo Output has been generated in $(BUILD_DIR)/$*
36-
37-
doc: sphinx-html
38-
3932
check: build install
4033
($(PYTHON) -m pytest src/systemd/test docs $(TESTFLAGS))
4134

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ Online documentation can be found at [freedesktop.org](https://www.freedesktop.o
185185

186186
To build it locally run:
187187

188-
make sphinx-html
188+
ninja -C build docs
189189

190-
Or use any other builder, see `man sphinx-build` for a list. The compiled docs will be e.g. in `docs/html`.
190+
Or use any other builder, see `man sphinx-build` for a list. The compiled docs will be e.g. in `build/html`.
191191

192192
Viewing Output
193193
==============

meson.build

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,19 @@ test(
4040
)
4141

4242
alias_target('update-constants', update_constants)
43+
44+
# Docs
45+
sphinx_build = find_program('sphinx-build', disabler: true, required: get_option('docs'))
46+
sphinx_args = ['-Dversion=' + meson.project_version(), '-Drelease=' + meson.project_version()]
47+
48+
input_dir = meson.current_source_dir() / 'docs'
49+
output_dir = meson.current_build_dir() / 'html'
50+
doc_target = custom_target('docs',
51+
output: 'html',
52+
input: files('docs/conf.py'),
53+
command: [sphinx_build, '-b', 'html', sphinx_args, input_dir, output_dir],
54+
env: { 'PYTHONPATH': meson.current_build_dir() / 'src' },
55+
build_by_default: get_option('docs'),
56+
install: get_option('docs'),
57+
install_dir: get_option('datadir') / 'doc' / meson.project_name()
58+
)

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)