Skip to content

Commit cb50f8b

Browse files
jellykeszybz
authored andcommitted
meson: build docs with meson
Introduce a custom target `html` and a build configuration option `docs` to build the sphinx html documentation.
1 parent f7883c1 commit cb50f8b

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-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 html
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,22 @@ 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('html',
51+
output: 'html',
52+
input: files('docs/conf.py',
53+
'docs/daemon.rst', 'docs/id128.rst',
54+
'docs/journal.rst', 'docs/login.rst',
55+
'docs/layout.html', 'docs/default.css'),
56+
command: [sphinx_build, '-b', 'html', sphinx_args, input_dir, output_dir],
57+
env: { 'PYTHONPATH': meson.current_build_dir() / 'src' },
58+
build_by_default: get_option('docs'),
59+
install: get_option('docs'),
60+
install_dir: get_option('datadir') / 'doc' / meson.project_name()
61+
)

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)