docs_enabled = get_option('valadocs')
valadoc = find_program('valadoc', required: docs_enabled)
vala_doc_sources = vala_sources
vala_doc_sources += config_data_file
if docs_enabled
	valadocs_deps = get_option('valadocs_deps')
	docs_deps = ['--pkg=gtk+-3.0']
	docs_deps += ['--pkg=libpq']
	docs_deps += ['--pkg=posix']
	if valadocs_deps
		docs_deps += ['--deps']
	endif
	custom_target('valadoc',
		input: vala_doc_sources,
		output: 'valadoc',
		command: [ valadoc,
			docs_deps,
			'--doclet=html',
			'--internal',
			'--private',
			'--force',
			'--package-name=@0@'.format(meson.project_name()),
			'--package-version=@0@'.format(meson.project_version()),
			'--vapidir=@0@'.format(join_paths(meson.source_root(), 'vapi')),
			'--directory=@OUTDIR@/valadoc',
			vala_doc_sources,
		],
		build_by_default: true,
		install: true,
		install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())
	)
endif
