Debian Codegraph @

doc/meson.build

raw
1 # Copyright 2021-2022 David Robillard <[email protected]>
2 # SPDX-License-Identifier: 0BSD OR ISC
3
4 docdir = get_option('datadir') / 'doc'
5
6 #############
7 # Reference #
8 #############
9
10 # Find required programs
11 doxygen = find_program('doxygen', required: get_option('docs'))
12 sphinx_build = find_program('sphinx-build', required: get_option('docs'))
13
14 # Find sphinxygen or fall back to subproject
15 sphinxygen = disabler()
16 if doxygen.found() and sphinx_build.found()
17 sphinxygen = find_program('sphinxygen', required: false)
18 if not sphinxygen.found()
19 subproject('sphinxygen')
20 sphinxygen = find_program('sphinxygen', required: get_option('docs'))
21 endif
22 endif
23
24 # Build documentation if all required tools are found
25 build_docs = doxygen.found() and sphinxygen.found() and sphinx_build.found()
26 if build_docs
27 # Warn if the "official" theme isn't present
28 pymod = import('python')
29 doc_modules = ['sphinx_lv2_theme']
30 py = pymod.find_installation('python3', modules: doc_modules, required: false)
31 if not py.found()
32 warning('Missing sphinx_lv2_theme module, falling back to alabaster')
33 endif
34
35 # Configure conf.py for Sphinx
36 conf_config = configuration_data()
37 conf_config.set('SRATOM_SRCDIR', sratom_src_root)
38 conf_config.set('SRATOM_TITLE', get_option('title'))
39 conf_config.set('SRATOM_VERSION', meson.project_version())
40 conf_py = configure_file(
41 configuration: conf_config,
42 input: files('conf.py.in'),
43 output: 'conf.py',
44 )
45
46 # Copy hand-written documentation files
47 rst_sources = files('index.rst', 'overview.rst')
48 sphinx_input = []
49 foreach f : rst_sources
50 sphinx_input += [
51 configure_file(copy: true, input: f, output: '@PLAINNAME@'),
52 ]
53 endforeach
54
55 # Generate reference documentation input with Doxygen and Sphinxygen
56 subdir('xml')
57 subdir('api')
58
59 # Build strict Sphinx flags, with termination on warnings if werror=true
60 sphinx_in_dir = meson.current_build_dir()
61 sphinx_flags = ['-E', '-a', '-q']
62 if get_option('werror')
63 sphinx_flags += ['-W']
64 endif
65
66 # Run Sphinx to generate final documentation for each format
67 sphinx_build_command = [sphinx_build] + sphinx_flags
68 foreach format : ['html', 'singlehtml']
69 if not get_option(format).disabled()
70 subdir(format)
71 endif
72 endforeach
73 endif
74
75 if not meson.is_subproject()
76 summary('Documentation', build_docs, bool_yn: true, section: 'Components')
77 endif