1# Sphinx build 2sphinx = find_program('sphinx-build-3', 'sphinx-build', required : false) 3if not sphinx.found() 4 error('Program "sphinx-build" not found or not executable. Try building with -Ddocumentation=false') 5endif 6 7yq = find_program('yq', required : false) 8if not yq.found() 9 warning('Program "yq" not found or not executable. Dependency list will not be built.') 10endif 11 12sphinx_config = configuration_data() 13sphinx_config.set('PROJECT_NAME', meson.project_name()) 14sphinx_config.set('PROJECT_VERSION', meson.project_version()) 15sphinx_config.set('BUILDDIR', meson.current_build_dir()) 16sphinx_config.set('HTTP_DOC_LINK', doc_url) 17 18git_version_page = vcs_tag(command : ['git', 'log', '-1', '--format=%H'], 19 fallback : 'unknown', 20 input : 'git_version.py.in', 21 output : 'git_version.py', 22 replace_string: '__GIT_VERSION__') 23 24sphinx_conf_py = configure_file(input : 'conf.py.in', 25 output : 'conf.py', 26 configuration : sphinx_config) 27 28# 404 replacements for old URLs 29# The switch to sphinx caused a few pages to be renamed, sphinx uses 30# filename.html whereas doxygen used whatever the @page foo was. So old docs 31# *mostly* used underscores, now we're consistent with dashes. 32# We can't use htaccess on the server, so let's auto-generate a 404 list 33# with a basic page telling users that the link has moved. This can be 34# removed in a few months, towards the end of 2018. 35# 36# File list is: [current-sphinx-input-file, old-generated-page] 37# If they're the same they'll be ignored. 38src_404s = [ 39 [ 'absolute-axes.rst', 'absolute_axes.html'], 40 [ 'absolute-coordinate-ranges.rst', 'absolute_coordinate_ranges.html'], 41 [ 'architecture.rst', 'architecture.html'], 42 [ 'building.rst', 'building_libinput.html'], 43 [ 'button-debouncing.rst', 'button_debouncing.html'], 44 [ 'clickpad-softbuttons.rst', 'clickpad_softbuttons.html'], 45 [ 'configuration.rst', 'config_options.html'], 46 [ 'contributing.rst', 'contributing.html'], 47 [ 'development.rst', 'development.html'], 48 [ 'device-configuration-via-udev.rst', 'udev_config.html'], 49 [ 'device-quirks.rst', 'device-quirks.html'], 50 [ 'faqs.rst', 'faq.html'], 51 [ 'features.rst', 'features.html'], 52 [ 'gestures.rst', 'gestures.html'], 53 [ 'incorrectly-enabled-hires.rst', 'incorrectly-enabled-hires.html'], 54 [ 'middle-button-emulation.rst', 'middle_button_emulation.html'], 55 [ 'normalization-of-relative-motion.rst', 'motion_normalization.html'], 56 [ 'palm-detection.rst', 'palm_detection.html'], 57 [ 'pointer-acceleration.rst', 'pointer-acceleration.html'], 58 [ 'reporting-bugs.rst', 'reporting_bugs.html'], 59 [ 'scrolling.rst', 'scrolling.html'], 60 [ 'seats.rst', 'seats.html'], 61 [ 'switches.rst', 'switches.html'], 62 [ 't440-support.rst', 't440_support.html'], 63 [ 'tablet-support.rst', 'tablet-support.html'], 64 [ 'tapping.rst', 'tapping.html'], 65 [ 'test-suite.rst', 'test-suite.html'], 66 [ 'timestamps.rst', 'timestamps.html'], 67 [ 'tools.rst', 'tools.html'], 68 [ 'touchpad-jitter.rst', 'touchpad_jitter.html'], 69 [ 'touchpad-jumping-cursors.rst', 'touchpad_jumping_cursor.html'], 70 [ 'touchpad-pressure.rst', 'touchpad_pressure.html'], 71 [ 'touchpads.rst', 'touchpads.html'], 72 [ 'trackpoints.rst', 'trackpoints.html'], 73 [ 'troubleshooting.rst', 'troubleshooting.html'], 74 [ 'what-is-libinput.rst', 'what_is_libinput.html'], 75] 76 77dst_404s = [] 78foreach s404 : src_404s 79 target = s404[0] 80 oldpage = s404[1] 81 tname = target.split('.rst')[0] 82 oname = oldpage.split('.html')[0] 83 84 if tname != oname 85 config_404 = configuration_data() 86 config_404.set('TARGET', '@0@.html'.format(tname)) 87 c = configure_file(input : '404.rst', 88 output : '@0@.rst'.format(oname), 89 configuration : config_404) 90 dst_404s += [c] 91 endif 92endforeach 93 94src_rst = files( 95 # dot drawings 96 'dot/seats-sketch.gv', 97 'dot/seats-sketch-libinput.gv', 98 'dot/libinput-stack-wayland.gv', 99 'dot/libinput-stack-xorg.gv', 100 'dot/libinput-stack-gnome.gv', 101 'dot/evemu.gv', 102 'dot/libinput-record.gv', 103 # svgs 104 'svg/button-debouncing-wave-diagram.svg', 105 'svg/button-scrolling.svg', 106 'svg/clickfinger.svg', 107 'svg/clickfinger-distance.svg', 108 'svg/edge-scrolling.svg', 109 'svg/gesture-2fg-ambiguity.svg', 110 'svg/palm-detection.svg', 111 'svg/pinch-gestures.svg', 112 'svg/pinch-gestures-softbuttons.svg', 113 'svg/ptraccel-custom.svg', 114 'svg/ptraccel-linear.svg', 115 'svg/ptraccel-low-dpi.svg', 116 'svg/ptraccel-touchpad.svg', 117 'svg/ptraccel-trackpoint.svg', 118 'svg/software-buttons.svg', 119 'svg/software-buttons-conditions.svg', 120 'svg/software-buttons-thumbpress.svg', 121 'svg/software-buttons-visualized.svg', 122 'svg/swipe-gestures.svg', 123 'svg/tablet-axes.svg', 124 'svg/tablet-cintiq24hd-modes.svg', 125 'svg/tablet-interfaces.svg', 126 'svg/tablet-intuos-modes.svg', 127 'svg/tablet-left-handed.svg', 128 'svg/tablet-out-of-bounds.svg', 129 'svg/tablet.svg', 130 'svg/tap-n-drag.svg', 131 'svg/thumb-detection.svg', 132 'svg/top-software-buttons.svg', 133 'svg/touchscreen-gestures.svg', 134 'svg/trackpoint-delta-illustration.svg', 135 'svg/twofinger-scrolling.svg', 136 # rst files 137 'absolute-axes.rst', 138 'absolute-coordinate-ranges.rst', 139 'architecture.rst', 140 'building.rst', 141 'button-debouncing.rst', 142 'clickpad-softbuttons.rst', 143 'clickpad-with-right-button.rst', 144 'contributing.rst', 145 'device-configuration-via-udev.rst', 146 'device-quirks.rst', 147 'faqs.rst', 148 'gestures.rst', 149 'incorrectly-enabled-hires.rst', 150 'ignoring-devices.rst', 151 'middle-button-emulation.rst', 152 'normalization-of-relative-motion.rst', 153 'palm-detection.rst', 154 'pointer-acceleration.rst', 155 'reporting-bugs.rst', 156 'scrolling.rst', 157 'seats.rst', 158 'switches.rst', 159 't440-support.rst', 160 'tablet-support.rst', 161 'tapping.rst', 162 'test-suite.rst', 163 'timestamps.rst', 164 'tablet-debugging.rst', 165 'tools.rst', 166 'touchpad-jumping-cursors.rst', 167 'touchpad-pressure.rst', 168 'touchpad-pressure-debugging.rst', 169 'touchpad-jitter.rst', 170 'touchpad-thumb-detection.rst', 171 'touchpads.rst', 172 'trackpoints.rst', 173 'trackpoint-configuration.rst', 174 'what-is-libinput.rst', 175 'wheel-api.rst', 176 'features.rst', 177 'development.rst', 178 'troubleshooting.rst', 179 'configuration.rst', 180) 181 182src_sphinx = [] 183foreach f : src_rst 184 sf = configure_file(input: f, 185 output: '@PLAINNAME@', 186 copy : true) 187 src_sphinx += [ sf ] 188endforeach 189 190configure_file(input: 'index.rst', 191 output: 'index.rst', 192 configuration: sphinx_config) 193 194dependencies_config = configuration_data() 195if yq.found() 196 distributions = ['fedora', 'ubuntu', 'debian', 'arch', 'alpine'] 197 foreach distro : distributions 198 yq_filter = '.distributions[] | select(.name == "@0@") | .packages | join(" ")'.format(distro) 199 deps = run_command(yq, '-r', yq_filter, 200 dir_gitlab_ci / 'config.yml', 201 check: true).stdout() 202 dependencies_config.set('@0@_PACKAGES'.format(distro.to_upper()), deps) 203endforeach 204endif 205configure_file(input: 'dependencies.rst', 206 output: 'dependencies.rst', 207 configuration: dependencies_config) 208 209# do not use -j, it breaks on Ubuntu 210sphinx_output_dir = 'Documentation' 211custom_target('sphinx', 212 input : [ sphinx_conf_py, git_version_page ] + src_sphinx + dst_404s, 213 output : [ sphinx_output_dir ], 214 command : [ sphinx, '-q', '-b', 'html', 215 '-d', meson.current_build_dir() / 'doctrees', 216 meson.current_build_dir(), sphinx_output_dir], 217 build_by_default : true) 218