From 0ccfc5c2523f80d8fe6fff6e30148e62a7eff62e Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 3 Oct 2025 21:08:09 +0200 Subject: [PATCH] meson: build docs with meson Introduce a custom target `build-docs` to build the sphinx documentation. --- Makefile | 7 ------- meson.build | 14 ++++++++++++++ meson.options | 3 +++ 3 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 meson.options diff --git a/Makefile b/Makefile index 6d055ca..162d82a 100644 --- a/Makefile +++ b/Makefile @@ -43,13 +43,6 @@ clean: distclean: clean rm -rf dist MANIFEST -SPHINXOPTS += -D version=$(VERSION) -D release=$(VERSION) -sphinx-%: install - mkdir $(BUILD_DIR) && cd $(BUILD_DIR) && $(PYTHON) -m sphinx -b $* $(SPHINXOPTS) ../docs $* - @echo Output has been generated in $(BUILD_DIR)/$* - -doc: sphinx-html - check: build install ($(PYTHON) -m pytest src/systemd/test docs $(TESTFLAGS)) diff --git a/meson.build b/meson.build index 590f929..45ccdf6 100644 --- a/meson.build +++ b/meson.build @@ -21,3 +21,17 @@ common_c_args = [ ] subdir('src/systemd') + +# Docs +sphinx_build = find_program('sphinx-build', disabler: true, required: get_option('docs')) +if get_option('docs') + sphinx_args = ['-Dversion=' + meson.project_version(), '-Drelease=' + meson.project_version()] + input_dir = meson.current_source_dir() / 'docs' + output_dir = meson.current_build_dir() / 'html' + output_file = output_dir / 'index.html' + custom_target('build-docs', + output: 'index.html', + input: files('docs/conf.py'), + command: [sphinx_build, '-b', 'html', sphinx_args, input_dir, output_dir], + ) +endif diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..38dcb92 --- /dev/null +++ b/meson.options @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +option('docs', type : 'boolean', value : false)